add coloring

This commit is contained in:
whosit 2024-02-11 14:40:28 +03:00
parent a5170fe906
commit 64c9f16743
2 changed files with 16 additions and 8 deletions

View File

@ -1,8 +1,10 @@
local COOLDOWN = 1.8
local PARTICLE_TIME = COOLDOWN-0.2
local PARTICLE_TIME = COOLDOWN - 0.2
local function roll_dice(pos)
local node = minetest.get_node(pos)
local function roll_dice(pos, node)
if not node then
node = minetest.get_node(pos)
end
local timer = minetest.get_node_timer(pos)
if timer:is_started() then
@ -10,8 +12,9 @@ local function roll_dice(pos)
end
timer:start(COOLDOWN)
local color = math.floor(node.param2 / 32)
local facedir = math.random(0, 23)
node.param2 = facedir
node.param2 = color * 32 + facedir
minetest.swap_node(pos, node)
local spawner_def = {
@ -71,20 +74,25 @@ minetest.register_node("yl_dice:dice", {
description = "Dice",
drawtype = "mesh",
paramtype = "light",
paramtype2 = "facedir",
paramtype2 = "colorfacedir",
mesh = "yl_dice6.obj",
tiles = {
"yl_dice_6sides.png",
},
drop = "yl_dice:dice",
drop = {
items = {
{ items = { "yl_dice:dice" }, inherit_color = true },
}
},
inventory_image = "yl_dice_3.png",
wield_image = "yl_dice_3.png",
groups = { dig_immediate = 2 },
palette = "yl_dice_6_palette.png",
on_construct = function(pos)
roll_dice(pos)
roll_dice(pos, node)
end,
on_rightclick = function(pos, node, puncher, itemstack, pointed_thing)
roll_dice(pos)
end
end,
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 B