generalized to anycoin as an API

This commit is contained in:
Tai @ Flex 2016-08-25 17:14:23 +01:00
parent c90bd9f7ec
commit 0f8902214f
5 changed files with 65 additions and 59 deletions

65
anycoin/init.lua Normal file
View File

@ -0,0 +1,65 @@
anycoin = {}
local metals = "default:coal_lump"
if minetest.get_modpath("moreores") then
metals = "moreores:tin_ingot"
end
function anycoin:register_coin(coinname,coindesc,cmaterial,overimg,cvalue)
local coinimg = "anycoin_coin.png^"..overimg
local value = cvalue
if not cvalue then
cvalue = 1
end
minetest.register_craft_item("anycoin:coin_"..coinname, {
description = coindesc .. " ("..cvalue.." ac-)",
inventory_image = coingimg,
coinvalue = cvalue
})
if cmaterial =~ nil then
core.register_craft({
type = "shapeless",
output = "anycoin:coin_base "..cvalue,
recipe = {"anycoin:coin_"..coinname}
}
)
end
core.register_craft( {
output = "anycoin:coin_"..coinname,
recipe = {
{metals,cmaterial,metals},
{cmaterial,cmaterial,cmaterial},
{metals,cmaterial,metals},
}
})
end
-- A base coin to serve as an exchange base
anycoin:register_coin("base","AnyCoin",nil,"default_dirt_with_grass.png",1)
local basecoin = "anycoin:coin_base"
core.register_craft( {
output = "anycoin:coin_base9",
recipe = {
{basecoin,basecoin,basecoin},
{basecoin,basecoin,basecoin},
{basecoin,basecoin,basecoin},
}
})
minetest.register_craft_item("anycoin:coin_base", {
description = "AnyCoin9 (9 ac-)",
inventory_image = "default_dirt_with_dry_grass.png",
coinvalue = 9
})

View File

Before

Width:  |  Height:  |  Size: 895 B

After

Width:  |  Height:  |  Size: 895 B

View File

@ -1,59 +0,0 @@
monstercoin = {}
-- +++++++++++++++++++++++++++++++++++++++++
--[[
core.register_craft( {
output = "nssm:surimi",
--type = "shapeless",
recipe = {
{"default:dirt","default:dirt","default:dirt"},
{"default:grass","default:grass","default:grass"}, -- group grass?
{"group:sand","group:sand","group:sand"},
}
})
--]]
local metals = "default:coal_lump"
if minetest.get_modpath("moreores") then
metals = "moreores:tin_ingot"
end
function monstercoin:register_coin(coinname,coindesc,cmaterial,overimg)
local coinimg = "monstercoin_coin.png^"..overimg
minetest.register_craft_item("monstercoin:coin_"..coinname, {
description = coindesc,
inventory_image = coingimg,
})
core.register_craft( {
output = "monstercoin:coin_"..coinname,
recipe = {
{metals,cmaterial,metals},
{cmaterial,cmaterial,cmaterial},
{metals,cmaterial,metals},
}
})
core.register_craft( {
output = cmaterial.." 5",
type = "shapeless",
recipe = {
"monstercoin:coin_"..coinname,
}
})
end
monstercoin:register_coin("nyan","Nyan Coin","default:nyancat","default_nc_front.png")
if minetest.get_modpath("nssm") then
monstercoin:register_coin("ice","Ice Monster Coin","nssm:frosted_amphibian_heart","frosted_amphibian_heart.png")
monstercoin:register_coin("worm","Worms Coin","nssm:worm_flesh","worm_flesh.png")
monstercoin:register_coin("scrausics","Scrausics Coin","nssm:raw_scrausics_wing","raw_scrausics_wing.png")
end