Use moddebug for logging

This commit is contained in:
Ciaran Gultnieks 2014-03-16 16:29:01 +00:00
parent ab2aa322c4
commit fd938eb7f3
2 changed files with 9 additions and 5 deletions

View File

@ -2,3 +2,4 @@ default
pipeworks?
digilines?
currency?
moddebug?

View File

@ -1,4 +1,7 @@
local dbg
if moddebug then dbg=moddebug.dbg("barrel") else dbg={v1=function() end,v2=function() end,v3=function() end} end
barrel = {}
barrel.cur_shop_pos = {}
@ -81,7 +84,7 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields)
meta:set_int("price", fields.price)
meta:set_int("saleunit", fields.saleunit)
barrel.set_infotext(minetest.get_node(pos).name, meta)
minetest.log("action", "BARREL:"..name.." set price "..fields.price..", unit "..fields.saleunit.." at "..minetest.pos_to_string(pos))
dbg.v1(name.." set price "..fields.price..", unit "..fields.saleunit.." at "..minetest.pos_to_string(pos))
end
elseif formname == "barrel:shop_customer_formspec" then
if fields.buy then
@ -181,7 +184,7 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields)
putmoney(playerinv, "payhere", change)
putmoney(shopinv, "money", price)
barrel.set_infotext(minetest.get_node(pos).name, meta)
minetest.log("action", "BARREL:"..name.." bought "..saleunit.." of "..meta:get_string("item")..
dbg.v1(name.." bought "..saleunit.." of "..meta:get_string("item")..
" for ".. price.." at "..minetest.pos_to_string(pos))
end
@ -434,7 +437,7 @@ barrel.digiline = {
effector = {
action = function(pos, node, channel, msg)
if channel ~= "barrel" then return end
minetest.log("info", "BARREL:received digiline message "..dump(msg))
dbg.v2("Received digiline message "..dump(msg))
if type(msg) ~= "table" then return end
if type(msg.item) ~= "string" then return end
local meta = minetest.get_meta(pos);
@ -459,11 +462,11 @@ barrel.digiline = {
if samount <= 0 then return end
-- Launch from bottom if there's a tube connected...
minetest.log("info", "BARREL:Try send at "..pos.x..","..pos.y..","..pos.z)
dbg.v3("Try send at "..pos.x..","..pos.y..","..pos.z)
local exitpos = {x=pos.x,y=pos.y-1,z=pos.z}
local exitnode = minetest.get_node(exitpos)
if minetest.get_item_group(exitnode.name, "tube") ~= 1 then
minetest.log("info", "BARREL:no tube for send")
dbg.v2("no tube for send")
end
dir = {x=exitpos.x-pos.x,y=exitpos.y-pos.y,z=exitpos.z-pos.z}