Version 1.2: Mark 2 and Mark 3
Mark 2 and Mark 3 provide more compact varients of the credit which can be used to store vast amounts of physical credits. (With a ratio of 9 credits to 1 Mk2 credit or 81 credits to 1 Mk3 credit)
This commit is contained in:
parent
f8d20c281a
commit
2f004d404e
@ -1,7 +1,13 @@
|
||||
# Credits
|
||||
# Credits V1.2
|
||||
|
||||
A physical and digital currency.
|
||||
|
||||
## News
|
||||
|
||||
* Version 1.2 introduces 2 other branches of the physical currency (Mk2 and Mk3 are 9:1 to 81:1 credit ratio), currently they can only be crafted by players. (But can be loaded the same)
|
||||
* Plans for Version 1.3:
|
||||
* Improve `/credits dump ##` to allow it to dump any number of credits (and possibly make some form of mathmatics to make use of Mk2 and Mk3 credits too)
|
||||
|
||||
## What's in the box
|
||||
|
||||
* Physical representation of a digital currency. (Use `/credits dump ##` Where # is number of coins to convert to a physical item, limited to 1000 credits per dump command)
|
||||
|
8
init.lua
8
init.lua
@ -5,7 +5,9 @@ credits = {}
|
||||
credits.S = minetest.get_translator("credits")
|
||||
credits.modpath = minetest.get_modpath("credits")
|
||||
credits.store = minetest.get_mod_storage()
|
||||
credits.VERSION = "1.0-dev"
|
||||
credits.VERSION = "1.2"
|
||||
|
||||
minetest.log("action", "[credits] Version: "..credits.VERSION)
|
||||
|
||||
-- Assistants
|
||||
|
||||
@ -37,6 +39,8 @@ else
|
||||
credits.GAMEMODE = "???"
|
||||
end
|
||||
|
||||
minetest.log("action", "[credits] Detected gamemode "..credits.GAMEMODE)
|
||||
|
||||
dofile(credits.modpath.."/settings.lua")
|
||||
|
||||
-- Initalize the physical and digital
|
||||
@ -86,3 +90,5 @@ elseif ir and credits.settings.allow_replication then
|
||||
minetest.log("action", "[credits] Added Replication settings of "..tostring(credits.settings.replication_amount).." amount every "..tostring(credits.settings.replication_time).." seconds.")
|
||||
ir.add("credits:credits", credits.settings.replication_amount, credits.settings.replication_time)
|
||||
end
|
||||
|
||||
minetest.log("action", "[credits] Ready")
|
||||
|
@ -8,6 +8,9 @@ credits.perform_interest = function()
|
||||
local days_off = current_day - last_day
|
||||
minetest.log("action", "Interest last performed "..tostring(days_off).." days ago")
|
||||
local ulist = credits.user_list()
|
||||
if credits.settings.online_get_interest then -- Instead of every account let's get the current connected players
|
||||
ulist = minetest.get_connected_players()
|
||||
end
|
||||
--minetest.log("action", "There are "..tostring(#ulist).." players to perform interst on")
|
||||
for i in ipairs(ulist) do
|
||||
-- Only perform 1 days worth of interest. (While this means more online more money it doesn't ruin servers which have been running a long time)
|
||||
|
80
physical.lua
80
physical.lua
@ -2,15 +2,84 @@
|
||||
-- This is just the physical interface
|
||||
-- See digital.lua for the digital interface
|
||||
|
||||
-- I need to improve the mk2 and mk3 so dump can use them too, since 1000 credits could be represented as about 111 credits_mk2
|
||||
|
||||
-- The physical item
|
||||
minetest.register_craftitem("credits:credits", {
|
||||
description = credits.S("Credit"),
|
||||
inventory_image = "credits_credits.png",
|
||||
inventory_image = "credits_credits_blue.png",
|
||||
stack_max = 1000 -- I add a max of 1000 just because 1k is a fairly large amount (Though it could mean nothing since it's also digital)
|
||||
})
|
||||
|
||||
minetest.register_craftitem("credits:credits_mkii", {
|
||||
description = credits.S("Credit Mk2"),
|
||||
inventory_image = "credits_credits_green.png",
|
||||
stack_max = 1000 -- I add a max of 1000 just because 1k is a fairly large amount (Though it could mean nothing since it's also digital)
|
||||
})
|
||||
|
||||
minetest.register_craftitem("credits:credits_mkiii", {
|
||||
description = credits.S("Credit Mk3"),
|
||||
inventory_image = "credits_credits_red.png",
|
||||
stack_max = 1000 -- I add a max of 1000 just because 1k is a fairly large amount (Though it could mean nothing since it's also digital)
|
||||
})
|
||||
|
||||
-- An alias of the physical item
|
||||
minetest.register_alias("credits", "credits:credits")
|
||||
minetest.register_alias("credits_mk2", "credits:credits_mkii")
|
||||
minetest.register_alias("credits_mk3", "credits:credits_mkiii")
|
||||
|
||||
-- Add Crafts
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "credits:credits",
|
||||
burntime = 1 -- For those who just litteraly want to burn money
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "credits:credits_mkii",
|
||||
burntime = 10 -- For those who just litteraly want to burn money
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "credits:credits_mkiii",
|
||||
burntime = 100 -- For those who just litteraly want to burn money
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "credits:credits_mkii",
|
||||
recipe = { -- 9 credits = 1 mk2 credit
|
||||
{"credits:credits", "credits:credits", "credits:credits"},
|
||||
{"credits:credits", "credits:credits", "credits:credits"},
|
||||
{"credits:credits", "credits:credits", "credits:credits"}
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "credits:credits 9",
|
||||
recipe = { -- 1 mk2 credit = 9 credits
|
||||
"credits:credits_mkii"
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "credits:credits_mkiii",
|
||||
recipe = { -- 9 mk2 credits = 1 mk3 credit
|
||||
{"credits:credits_mkii", "credits:credits_mkii", "credits:credits_mkii"},
|
||||
{"credits:credits_mkii", "credits:credits_mkii", "credits:credits_mkii"},
|
||||
{"credits:credits_mkii", "credits:credits_mkii", "credits:credits_mkii"}
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "credits:credits_mkii 9",
|
||||
recipe = { -- 1 mk3 credit = 9 mk2 credits
|
||||
"credits:credits_mkiii"
|
||||
}
|
||||
})
|
||||
|
||||
-- Checks the player's physical inventory for credits (Given by /credits dump ##)
|
||||
credits.get_balance_physical = function(pname)
|
||||
@ -21,6 +90,10 @@ credits.get_balance_physical = function(pname)
|
||||
for i, stack in ipairs(inv:get_list("main")) do
|
||||
if stack:get_name() == "credits:credits" then
|
||||
bal = bal + stack:get_count()
|
||||
elseif stack:get_name() == "credits:credits_mkii" then
|
||||
bal = bal + (stack:get_count() * 9) -- Each one counts for 9
|
||||
elseif stack:get_name() == "credits:credits_mkiii" then
|
||||
bal = bal + ((stack:get_count() * 9) * 9) -- Each one counts for 81
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -38,6 +111,7 @@ credits.dump = function (name, amount)
|
||||
if bal >= amt then
|
||||
-- Possibly convert this from a bulk or instantanious dump all into one item mabe make it so it can split it into multiple stacks
|
||||
-- Seperate by 1000 (max stack size)
|
||||
-- I need to include usage of mk2 and mk3 into this
|
||||
local stack = ItemStack("credits:credits "..tostring(amt)) -- This doesn't respect max stack size
|
||||
if inv:room_for_item("main", stack) then
|
||||
inv:add_item("main", stack)
|
||||
@ -61,6 +135,10 @@ credits.load = function (name)
|
||||
for i, s in ipairs(inv:get_list("main")) do -- Actually remove them now
|
||||
if s:get_name() == "credits:credits" then
|
||||
inv:set_stack("main", i, nil)
|
||||
elseif s:get_name() == "credits:credits_mkii" then
|
||||
inv:set_stack("main", i, nil)
|
||||
elseif s:get_name() == "credits:credits_mkiii" then
|
||||
inv:set_stack("main", i, nil)
|
||||
end
|
||||
end -- Ha, now we add the digital based on the first dirty and quick check
|
||||
credits.add_coin(name, bal)
|
||||
|
@ -10,3 +10,12 @@ if credits.settings.allow_replication then
|
||||
credits.settings.replication_time = 15 -- Seconds it takes...
|
||||
credits.settings.replication_amount = 1 -- To produce this many
|
||||
end
|
||||
|
||||
credits.settings.online_get_interest = true -- Do player's online get interest or does every account get interest
|
||||
-- If online_get_interest then
|
||||
-- For each player online do
|
||||
-- credits_interest(player)
|
||||
-- Else
|
||||
-- For every player with an account do
|
||||
-- credits_interest(player_account)
|
||||
-- End
|
||||
|
Before Width: | Height: | Size: 249 B After Width: | Height: | Size: 249 B |
BIN
textures/credits_credits_green.png
Normal file
BIN
textures/credits_credits_green.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 249 B |
BIN
textures/credits_credits_red.png
Normal file
BIN
textures/credits_credits_red.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 249 B |
Loading…
x
Reference in New Issue
Block a user