mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-11-07 19:10:23 +01:00
Added basic code of '?' block
This commit is contained in:
parent
bcd1171404
commit
c668e9f1d8
|
@ -11,4 +11,38 @@ minetest.register_tool("eventobjects:spleef_shovel", {
|
|||
},
|
||||
damage_groups = {fleshy=4},
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
minetest.register_node("eventobjects:surprise_node", {
|
||||
description = "'?' block",
|
||||
tiles = {"eventobjects_surprise_node.png"},
|
||||
inventory_image = "eventobjects_surprise_node.png",
|
||||
wield_image = "eventobjects_surprise_node.png",
|
||||
})
|
||||
|
||||
minetest.after(1,function()
|
||||
minetest.override_item("eventobjects:surprise_node", {
|
||||
on_punch = function(pos, node, puncher, pointed_things)
|
||||
-- Spawn betweek 5 and 20 random nodes
|
||||
for cnt = 1,math.random(5,20) do
|
||||
local item = ""
|
||||
local random_num = math.random(1,#minetest.registered_items)+math.random(-cnt,cnt)
|
||||
if random_num <= 0 then random_num = 1 end
|
||||
local random_count = 1
|
||||
for key, value in pairs(minetest.registered_items) do
|
||||
if random_count == random_num then
|
||||
item = key
|
||||
break
|
||||
end
|
||||
random_count = random_count + 1
|
||||
end
|
||||
print(table.getn(minetest.registered_items))
|
||||
local s_count = math.random(1,minetest.registered_items[item].max_count or 99)
|
||||
local obj = minetest.spawn_item({x=pos.x, y = pos.y + 1,z=pos.z},{name = item, count = s_count})
|
||||
if not obj then return end
|
||||
obj:setvelocity({x = 0, y = math.random(2,9), z = 0})
|
||||
end
|
||||
minetest.remove_node(pos)
|
||||
end,
|
||||
})
|
||||
end)
|
||||
|
|
Before Width: | Height: | Size: 256 B After Width: | Height: | Size: 256 B |
Loading…
Reference in New Issue
Block a user