Update infotexts after transforming legacy nodes

master
Wuzzy 2016-09-09 20:30:53 +02:00
parent 7cc5c41384
commit e5a810d254
2 changed files with 18 additions and 7 deletions

View File

@ -371,12 +371,7 @@ easyvend.machine_check = function(pos, node)
end
meta:set_string("status", status)
if not itemstack:is_empty() then
if itemname == nil or itemname == "" then
itemname = itemstack:get_name()
end
meta:set_string("infotext", easyvend.make_infotext(node.name, machine_owner, cost, number, itemname))
end
meta:set_string("infotext", easyvend.make_infotext(node.name, machine_owner, cost, number, itemname))
itemname=itemstack:get_name()
meta:set_string("itemname", itemname)
@ -499,9 +494,17 @@ easyvend.on_receive_fields_config = function(pos, formname, fields, sender)
end
easyvend.make_infotext = function(nodename, owner, cost, number, itemstring)
local d = ""
if itemstring == nil or itemstring == "" or number == 0 or cost == 0 then
if easyvend.buysell(nodename) == "sell" then
d = string.format("Inactive vending machine (owned by %s)", owner)
else
d = string.format("Inactive depositing machine (owned by %s)", owner)
end
return d
end
local iname = minetest.registered_items[itemstring].description
if iname == nil then iname = itemstring end
local d = ""
local printitem, printcost
if number == 1 then
printitem = iname

View File

@ -106,6 +106,7 @@ if minetest.get_modpath("vendor") == nil then
minetest.register_lbm({
name = "easyvend:replace_vendor",
nodenames = { "vendor:vendor", "vendor:depositor" },
run_at_every_load = true,
action = function(pos, node)
local newnodename
if node.name == "vendor:vendor" then
@ -152,6 +153,13 @@ if minetest.get_modpath("vendor") == nil then
configmode = 0
end
local owner = meta:get_string("owner")
if easyvend.buysell(newnodename) == "sell" then
meta:set_string("infotext", string.format("Vending machine (owned by %s)", owner))
else
meta:set_string("infotext", string.format("Depositing machine (owned by %s)", owner))
end
meta:set_int("configmode", configmode)
easyvend.machine_check(pos, node)
end,