1 minetest.register_on_mods_loaded(function()
2 for nodename, nodedef in pairs(minetest.registered_nodes) do
3 if nodename:find("mcl_signs:") then
4 minetest.override_item(nodename, {
5 on_rightclick = function(pos, node, player, itemstack, pointed_thing)
6 if pos.y < 5000 then return end
7 local text = minetest.get_meta(pos):get_string("text") or ""
8 local lines = text:split("\n")
9 local action, amount, price = lines[1], lines[2], lines[3]
10 print(action, amount, price)
11 if not (action and amount and price) then return end
12 price = string.gsub(price, "%$", "")
13 price = tonumber(price)
14 amount = string.gsub(amount, "x", "")
15 amount = tonumber(amount)
16 print(action, amount, price)
17 if not (amount and price) then return end
18 local func, frameoffset
19 if action == "Buy" then
20 func, frameoffset = skycraft.buy, -1
21 elseif action == "Sell" then
22 func, frameoffset = skycraft.sell, 1
26 local framepos = vector.add(pos, {x = 0, y = frameoffset, z = 0})
27 if minetest.get_node(framepos).name ~= "mcl_itemframes:item_frame" then return end
28 local inv = minetest.get_meta(framepos):get_inventory()
29 if inv:is_empty("main") then return end
30 local itemstack = inv:get_stack("main", 1)
31 func(player, itemstack:get_name() .. " " .. tostring(amount), price)