basic version
19
LICENSE.txt
Normal file
@ -0,0 +1,19 @@
|
||||
Copyright (c) 2024 whosit
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
1
README.md
Normal file
@ -0,0 +1 @@
|
||||
Simple dice block. When placed, it will orient in random direction. When block is right-clicked it will rotate itself again.
|
90
init.lua
Normal file
@ -0,0 +1,90 @@
|
||||
local COOLDOWN = 1.8
|
||||
local PARTICLE_TIME = COOLDOWN-0.2
|
||||
|
||||
local function roll_dice(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
if timer:is_started() then
|
||||
return
|
||||
end
|
||||
timer:start(COOLDOWN)
|
||||
|
||||
local facedir = math.random(0, 23)
|
||||
node.param2 = facedir
|
||||
minetest.swap_node(pos, node)
|
||||
|
||||
local spawner_def = {
|
||||
size = 0.6,
|
||||
amount = 42,
|
||||
time = 0.7,
|
||||
glow = 10,
|
||||
pos = {
|
||||
min = vector.add(pos, vector.new(-0.5, -0.5, -0.5)),
|
||||
max = vector.add(pos, vector.new(0.5, 0.5, 0.5)),
|
||||
},
|
||||
vel = {
|
||||
min = { x = 2, y = 3, z = 2 },
|
||||
|
||||
max = { x = -2, y = 1, z = -2 },
|
||||
},
|
||||
acc = {
|
||||
min = { x = 0, y = 10, z = 0 },
|
||||
max = { x = 0, y = 10, z = 0 },
|
||||
},
|
||||
exptime = { min = 0.2, max = 0.5, },
|
||||
vertical = false,
|
||||
texture = "yl_dice_6sides.png",
|
||||
animation = {
|
||||
type = "sheet_2d",
|
||||
frames_w = 2,
|
||||
frames_h = 3,
|
||||
frame_length = 0.1,
|
||||
}
|
||||
}
|
||||
|
||||
-- can't be bothered to figure out math for this
|
||||
local V = {
|
||||
1, 1, 1, 1,
|
||||
2, 3, 4, 5,
|
||||
4, 5, 2, 3,
|
||||
5, 2, 3, 4,
|
||||
3, 4, 5, 2,
|
||||
6, 6, 6, 6,
|
||||
}
|
||||
|
||||
minetest.add_particlespawner(spawner_def)
|
||||
|
||||
local val = V[facedir + 1] or 0
|
||||
local particle_def = {
|
||||
expirationtime = PARTICLE_TIME,
|
||||
pos = vector.add(pos, vector.new(0.0, 0.8, 0.0)),
|
||||
velocity = { x = 0, y = 0.1, z = 0 },
|
||||
glow = 14,
|
||||
texture = ("yl_dice_%d.png"):format(val),
|
||||
size = 4,
|
||||
}
|
||||
minetest.add_particle(particle_def)
|
||||
end
|
||||
|
||||
minetest.register_node("yl_dice:dice", {
|
||||
description = "Dice",
|
||||
drawtype = "mesh",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
mesh = "yl_dice6.obj",
|
||||
tiles = {
|
||||
"yl_dice_6sides.png",
|
||||
},
|
||||
drop = "yl_dice:dice",
|
||||
inventory_image = "yl_dice_3.png",
|
||||
wield_image = "yl_dice_3.png",
|
||||
groups = { dig_immediate = 2 },
|
||||
|
||||
on_construct = function(pos)
|
||||
roll_dice(pos)
|
||||
end,
|
||||
on_rightclick = function(pos, node, puncher, itemstack, pointed_thing)
|
||||
roll_dice(pos)
|
||||
end
|
||||
})
|
117
models/yl_dice6.obj
Normal file
@ -0,0 +1,117 @@
|
||||
# Blender 4.0.2
|
||||
# www.blender.org
|
||||
mtllib yl_dice6.mtl
|
||||
o Cube
|
||||
v 0.435994 0.435994 -0.500000
|
||||
v 0.435994 0.500000 -0.435994
|
||||
v 0.500000 0.435994 -0.435994
|
||||
v 0.435994 -0.500000 -0.435994
|
||||
v 0.435994 -0.435994 -0.500000
|
||||
v 0.500000 -0.435994 -0.435994
|
||||
v 0.500000 0.435994 0.435994
|
||||
v 0.435994 0.500000 0.435994
|
||||
v 0.435994 0.435994 0.500000
|
||||
v 0.500000 -0.435994 0.435994
|
||||
v 0.435994 -0.435994 0.500000
|
||||
v 0.435994 -0.500000 0.435994
|
||||
v -0.435994 0.435994 -0.500000
|
||||
v -0.500000 0.435994 -0.435994
|
||||
v -0.435994 0.500000 -0.435994
|
||||
v -0.500000 -0.435994 -0.435994
|
||||
v -0.435994 -0.435994 -0.500000
|
||||
v -0.435994 -0.500000 -0.435994
|
||||
v -0.500000 0.435994 0.435994
|
||||
v -0.435994 0.435994 0.500000
|
||||
v -0.435994 0.500000 0.435994
|
||||
v -0.435994 -0.500000 0.435994
|
||||
v -0.435994 -0.435994 0.500000
|
||||
v -0.500000 -0.435994 0.435994
|
||||
vn -0.0000 -1.0000 -0.0000
|
||||
vn -1.0000 -0.0000 -0.0000
|
||||
vn -0.0000 -0.0000 1.0000
|
||||
vn -0.0000 1.0000 -0.0000
|
||||
vn 1.0000 -0.0000 -0.0000
|
||||
vn 0.5774 0.5774 -0.5774
|
||||
vn 0.5774 -0.5774 -0.5774
|
||||
vn 0.5774 0.5774 0.5774
|
||||
vn 0.5774 -0.5774 0.5774
|
||||
vn -0.5774 0.5774 -0.5774
|
||||
vn -0.5774 -0.5774 -0.5774
|
||||
vn -0.5774 0.5774 0.5774
|
||||
vn -0.5774 -0.5774 0.5774
|
||||
vn -0.7071 -0.7071 -0.0000
|
||||
vn -0.0000 -0.7071 -0.7071
|
||||
vn 0.7071 -0.0000 -0.7071
|
||||
vn -0.7071 -0.0000 0.7071
|
||||
vn 0.7071 -0.0000 0.7071
|
||||
vn -0.7071 -0.0000 -0.7071
|
||||
vn -0.0000 0.7071 0.7071
|
||||
vn 0.7071 0.7071 -0.0000
|
||||
vn -0.0000 -0.7071 0.7071
|
||||
vn -0.7071 0.7071 -0.0000
|
||||
vn -0.0000 0.7071 -0.7071
|
||||
vn 0.7071 -0.7071 -0.0000
|
||||
vn -0.0000 -0.0000 -1.0000
|
||||
vt 0.031250 0.354167
|
||||
vt 0.468750 0.354167
|
||||
vt 0.468750 0.645833
|
||||
vt 0.031250 0.645833
|
||||
vt 0.031250 0.020833
|
||||
vt 0.468750 0.020833
|
||||
vt 0.468750 0.312500
|
||||
vt 0.031250 0.312500
|
||||
vt 0.531250 0.687500
|
||||
vt 0.968750 0.687500
|
||||
vt 0.968750 0.979167
|
||||
vt 0.531250 0.979167
|
||||
vt 0.031250 0.687500
|
||||
vt 0.468750 0.687500
|
||||
vt 0.468750 0.979167
|
||||
vt 0.031250 0.979167
|
||||
vt 0.531250 0.354167
|
||||
vt 0.968750 0.354167
|
||||
vt 0.968750 0.645833
|
||||
vt 0.531250 0.645833
|
||||
vt 0.968750 0.312500
|
||||
vt 1.000000 0.312500
|
||||
vt 1.000000 0.687500
|
||||
vt 0.968750 0.020833
|
||||
vt 0.968750 -0.000000
|
||||
vt 1.000000 -0.000000
|
||||
vt 0.468750 0.000000
|
||||
vt 0.531250 0.020833
|
||||
vt 0.531250 0.000000
|
||||
vt 0.531250 0.312500
|
||||
vt 0.031250 -0.000000
|
||||
vt 1.000000 0.979167
|
||||
vt 1.000000 0.354167
|
||||
vt 1.000000 0.645833
|
||||
vt 1.000000 0.020833
|
||||
s 0
|
||||
usemtl Material
|
||||
f 18/1/1 4/2/1 12/3/1 22/4/1
|
||||
f 24/5/2 19/6/2 14/7/2 16/8/2
|
||||
f 11/9/3 9/10/3 20/11/3 23/12/3
|
||||
f 2/13/4 15/14/4 21/15/4 8/16/4
|
||||
f 6/17/5 3/18/5 7/19/5 10/20/5
|
||||
f 1/21/6 2/22/6 3/18/6
|
||||
f 4/2/7 5/7/7 6/17/7
|
||||
f 7/19/8 8/23/8 9/10/8
|
||||
f 10/20/9 11/14/9 12/3/9
|
||||
f 13/24/10 14/25/10 15/26/10
|
||||
f 16/14/11 17/20/11 18/9/11
|
||||
f 19/6/12 20/27/12 21/28/12
|
||||
f 22/29/13 23/28/13 24/27/13
|
||||
f 18/9/14 22/12/14 24/15/14 16/14/14
|
||||
f 4/2/15 18/1/15 17/8/15 5/7/15
|
||||
f 3/18/16 6/17/16 5/30/16 1/21/16
|
||||
f 23/31/17 20/27/17 19/6/17 24/5/17
|
||||
f 9/10/18 11/9/18 10/20/18 7/19/18
|
||||
f 13/24/19 17/28/19 16/29/19 14/25/19
|
||||
f 8/23/20 21/32/20 20/11/20 9/10/20
|
||||
f 2/33/21 8/34/21 7/19/21 3/18/21
|
||||
f 22/4/22 12/3/22 11/14/22 23/13/22
|
||||
f 21/28/23 15/30/23 14/7/23 19/6/23
|
||||
f 15/35/24 2/22/24 1/21/24 13/24/24
|
||||
f 12/3/25 4/2/25 6/17/25 10/20/25
|
||||
f 17/28/26 13/24/26 1/21/26 5/30/26
|
BIN
textures/yl_dice_1.png
Normal file
After Width: | Height: | Size: 533 B |
BIN
textures/yl_dice_2.png
Normal file
After Width: | Height: | Size: 542 B |
BIN
textures/yl_dice_3.png
Normal file
After Width: | Height: | Size: 544 B |
BIN
textures/yl_dice_4.png
Normal file
After Width: | Height: | Size: 527 B |
BIN
textures/yl_dice_5.png
Normal file
After Width: | Height: | Size: 540 B |
BIN
textures/yl_dice_6.png
Normal file
After Width: | Height: | Size: 526 B |
BIN
textures/yl_dice_6sides.png
Normal file
After Width: | Height: | Size: 660 B |