add logging
This commit is contained in:
parent
1f5800ce77
commit
f7d741b2e7
14
init.lua
14
init.lua
@ -77,6 +77,8 @@ local function roll_dice(pos, node)
|
|||||||
pitch = 1.0 + 0.1*math.random(),
|
pitch = 1.0 + 0.1*math.random(),
|
||||||
}
|
}
|
||||||
minetest.sound_play(spec, parameters, true)
|
minetest.sound_play(spec, parameters, true)
|
||||||
|
|
||||||
|
return val
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node("yl_dice:dice", {
|
minetest.register_node("yl_dice:dice", {
|
||||||
@ -99,10 +101,16 @@ minetest.register_node("yl_dice:dice", {
|
|||||||
palette = "yl_dice_6_palette.png",
|
palette = "yl_dice_6_palette.png",
|
||||||
|
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
roll_dice(pos)
|
local val = roll_dice(pos)
|
||||||
|
minetest.log("action", ("[yl_dice] placed d6 has rolled %s at %s"):format(val, minetest.pos_to_string(pos)))
|
||||||
end,
|
end,
|
||||||
on_rightclick = function(pos, node, puncher, itemstack, pointed_thing)
|
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
roll_dice(pos, node)
|
local val = roll_dice(pos, node)
|
||||||
|
if val then
|
||||||
|
-- `val` is nil when cooldown has not ended yet
|
||||||
|
local name = clicker and clicker:is_player() and clicker:get_player_name() or "UNKNOWN"
|
||||||
|
minetest.log("action", ("[yl_dice] %s has rolled %s by using d6 at %s"):format(name, val, minetest.pos_to_string(pos)))
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user