Skip to content

Commit

Permalink
Add [currency] support
Browse files Browse the repository at this point in the history
  • Loading branch information
SwissalpS committed Dec 26, 2024
1 parent 4e62ddb commit 537a061
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ globals = {
}

read_globals = {
"core",
"table.copy",
"table.indexof",
"minetest",
"ItemStack",
"barter",
"digilines",
"drawers",
"mesecon",
Expand Down
1 change: 1 addition & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ local mods = {
"biofuel",
"bones",
"connected_chests",
"currency",
"default",
"digilines",
"digiscreen",
Expand Down
1 change: 1 addition & 0 deletions mod.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ optional_depends = """
biofuel,
bones,
connected_chests,
currency,
default,
digtron,
digilines,
Expand Down
42 changes: 42 additions & 0 deletions nodes/currency.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

-- Register wrench support for the currency mod

wrench.register_node("currency:barter", {
lists = { "pl1", "pl2" },
metas = {
clean = wrench.META_TYPE_INT,
formspec = wrench.META_TYPE_IGNORE,
infotext = wrench.META_TYPE_IGNORE,
pl1 = wrench.META_TYPE_STRING,
pl2 = wrench.META_TYPE_STRING,
pl1step = wrench.META_TYPE_INT,
pl2step = wrench.META_TYPE_INT,
timer = wrench.META_TYPE_INT,
},
timer = true,
after_place = function(pos, player, stack, pointed)
barter.chest.update_formspec(core.get_meta(pos))
end,
})

wrench.register_node("currency:safe", {
lists = { "main" },
metas = {
infotext = wrench.META_TYPE_STRING,
owner = wrench.META_TYPE_STRING,
},
owned = true,
})

-- Unkown what happens if a shop is wrenched while a user is using it.
for _, name in ipairs({ "currency:shop", "currency:shop_empty" }) do
wrench.register_node(name, {
lists = { "customers_gave", "owner_gives", "owner_wants", "stock" },
metas = {
infotext = wrench.META_TYPE_STRING,
owner = wrench.META_TYPE_STRING,
},
owned = true,
})
end

0 comments on commit 537a061

Please sign in to comment.