add coloring
This commit is contained in:
parent
a5170fe906
commit
64c9f16743
22
init.lua
22
init.lua
@ -1,8 +1,10 @@
|
|||||||
local COOLDOWN = 1.8
|
local COOLDOWN = 1.8
|
||||||
local PARTICLE_TIME = COOLDOWN - 0.2
|
local PARTICLE_TIME = COOLDOWN - 0.2
|
||||||
|
|
||||||
local function roll_dice(pos)
|
local function roll_dice(pos, node)
|
||||||
local node = minetest.get_node(pos)
|
if not node then
|
||||||
|
node = minetest.get_node(pos)
|
||||||
|
end
|
||||||
|
|
||||||
local timer = minetest.get_node_timer(pos)
|
local timer = minetest.get_node_timer(pos)
|
||||||
if timer:is_started() then
|
if timer:is_started() then
|
||||||
@ -10,8 +12,9 @@ local function roll_dice(pos)
|
|||||||
end
|
end
|
||||||
timer:start(COOLDOWN)
|
timer:start(COOLDOWN)
|
||||||
|
|
||||||
|
local color = math.floor(node.param2 / 32)
|
||||||
local facedir = math.random(0, 23)
|
local facedir = math.random(0, 23)
|
||||||
node.param2 = facedir
|
node.param2 = color * 32 + facedir
|
||||||
minetest.swap_node(pos, node)
|
minetest.swap_node(pos, node)
|
||||||
|
|
||||||
local spawner_def = {
|
local spawner_def = {
|
||||||
@ -71,20 +74,25 @@ minetest.register_node("yl_dice:dice", {
|
|||||||
description = "Dice",
|
description = "Dice",
|
||||||
drawtype = "mesh",
|
drawtype = "mesh",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "colorfacedir",
|
||||||
mesh = "yl_dice6.obj",
|
mesh = "yl_dice6.obj",
|
||||||
tiles = {
|
tiles = {
|
||||||
"yl_dice_6sides.png",
|
"yl_dice_6sides.png",
|
||||||
},
|
},
|
||||||
drop = "yl_dice:dice",
|
drop = {
|
||||||
|
items = {
|
||||||
|
{ items = { "yl_dice:dice" }, inherit_color = true },
|
||||||
|
}
|
||||||
|
},
|
||||||
inventory_image = "yl_dice_3.png",
|
inventory_image = "yl_dice_3.png",
|
||||||
wield_image = "yl_dice_3.png",
|
wield_image = "yl_dice_3.png",
|
||||||
groups = { dig_immediate = 2 },
|
groups = { dig_immediate = 2 },
|
||||||
|
palette = "yl_dice_6_palette.png",
|
||||||
|
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
roll_dice(pos)
|
roll_dice(pos, node)
|
||||||
end,
|
end,
|
||||||
on_rightclick = function(pos, node, puncher, itemstack, pointed_thing)
|
on_rightclick = function(pos, node, puncher, itemstack, pointed_thing)
|
||||||
roll_dice(pos)
|
roll_dice(pos)
|
||||||
end
|
end,
|
||||||
})
|
})
|
||||||
|
BIN
textures/yl_dice_6_palette.png
Normal file
BIN
textures/yl_dice_6_palette.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 493 B |
Loading…
Reference in New Issue
Block a user