Replace minetest.env: with minetest.
This commit is contained in:
parent
dfad095884
commit
31a74ede18
@ -2,7 +2,7 @@
|
|||||||
-- See README.txt for licensing and other information.
|
-- See README.txt for licensing and other information.
|
||||||
|
|
||||||
local function is_owner(pos, name)
|
local function is_owner(pos, name)
|
||||||
local owner = minetest.env:get_meta(pos):get_string("owner")
|
local owner = minetest.get_meta(pos):get_string("owner")
|
||||||
if owner == "" or owner == name then
|
if owner == "" or owner == name then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -26,7 +26,7 @@ minetest.register_node("bones:bones", {
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
can_dig = function(pos, player)
|
can_dig = function(pos, player)
|
||||||
local inv = minetest.env:get_meta(pos):get_inventory()
|
local inv = minetest.get_meta(pos):get_inventory()
|
||||||
return is_owner(pos, player:get_player_name()) and inv:is_empty("main")
|
return is_owner(pos, player:get_player_name()) and inv:is_empty("main")
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ minetest.register_node("bones:bones", {
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
if meta:get_string("owner") ~= "" and meta:get_inventory():is_empty("main") then
|
if meta:get_string("owner") ~= "" and meta:get_inventory():is_empty("main") then
|
||||||
meta:set_string("infotext", meta:get_string("owner").."'s old bones")
|
meta:set_string("infotext", meta:get_string("owner").."'s old bones")
|
||||||
meta:set_string("formspec", "")
|
meta:set_string("formspec", "")
|
||||||
@ -58,7 +58,7 @@ minetest.register_node("bones:bones", {
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
on_timer = function(pos, elapsed)
|
on_timer = function(pos, elapsed)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local time = meta:get_int("time")+elapsed
|
local time = meta:get_int("time")+elapsed
|
||||||
local publish = 1200
|
local publish = 1200
|
||||||
if tonumber(minetest.setting_get("share_bones_time")) then
|
if tonumber(minetest.setting_get("share_bones_time")) then
|
||||||
@ -87,7 +87,7 @@ minetest.register_on_dieplayer(function(player)
|
|||||||
pos.z = math.floor(pos.z+0.5)
|
pos.z = math.floor(pos.z+0.5)
|
||||||
local param2 = minetest.dir_to_facedir(player:get_look_dir())
|
local param2 = minetest.dir_to_facedir(player:get_look_dir())
|
||||||
|
|
||||||
local nn = minetest.env:get_node(pos).name
|
local nn = minetest.get_node(pos).name
|
||||||
if minetest.registered_nodes[nn].can_dig and
|
if minetest.registered_nodes[nn].can_dig and
|
||||||
not minetest.registered_nodes[nn].can_dig(pos, player) then
|
not minetest.registered_nodes[nn].can_dig(pos, player) then
|
||||||
local player_inv = player:get_inventory()
|
local player_inv = player:get_inventory()
|
||||||
@ -101,10 +101,10 @@ minetest.register_on_dieplayer(function(player)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.env:dig_node(pos)
|
minetest.dig_node(pos)
|
||||||
minetest.env:add_node(pos, {name="bones:bones", param2=param2})
|
minetest.add_node(pos, {name="bones:bones", param2=param2})
|
||||||
|
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
local player_inv = player:get_inventory()
|
local player_inv = player:get_inventory()
|
||||||
inv:set_size("main", 8*4)
|
inv:set_size("main", 8*4)
|
||||||
@ -125,6 +125,6 @@ minetest.register_on_dieplayer(function(player)
|
|||||||
meta:set_string("owner", player:get_player_name())
|
meta:set_string("owner", player:get_player_name())
|
||||||
meta:set_int("time", 0)
|
meta:set_int("time", 0)
|
||||||
|
|
||||||
local timer = minetest.env:get_node_timer(pos)
|
local timer = minetest.get_node_timer(pos)
|
||||||
timer:start(10)
|
timer:start(10)
|
||||||
end)
|
end)
|
||||||
|
@ -47,7 +47,7 @@ function bucket.register_liquid(source, flowing, itemname, inventory_image, name
|
|||||||
|
|
||||||
local place_liquid = function(pos, node, source, flowing, fullness)
|
local place_liquid = function(pos, node, source, flowing, fullness)
|
||||||
if math.floor(fullness/128) == 1 or (not minetest.setting_getbool("liquid_finite")) then
|
if math.floor(fullness/128) == 1 or (not minetest.setting_getbool("liquid_finite")) then
|
||||||
minetest.env:add_node(pos, {name=source, param2=fullness})
|
minetest.add_node(pos, {name=source, param2=fullness})
|
||||||
return
|
return
|
||||||
elseif node.name == flowing then
|
elseif node.name == flowing then
|
||||||
fullness = fullness + node.param2
|
fullness = fullness + node.param2
|
||||||
@ -56,14 +56,14 @@ function bucket.register_liquid(source, flowing, itemname, inventory_image, name
|
|||||||
end
|
end
|
||||||
|
|
||||||
if fullness >= LIQUID_MAX then
|
if fullness >= LIQUID_MAX then
|
||||||
minetest.env:add_node(pos, {name=source, param2=LIQUID_MAX})
|
minetest.add_node(pos, {name=source, param2=LIQUID_MAX})
|
||||||
else
|
else
|
||||||
minetest.env:add_node(pos, {name=flowing, param2=fullness})
|
minetest.add_node(pos, {name=flowing, param2=fullness})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check if pointing to a buildable node
|
-- Check if pointing to a buildable node
|
||||||
local node = minetest.env:get_node(pointed_thing.under)
|
local node = minetest.get_node(pointed_thing.under)
|
||||||
local fullness = tonumber(itemstack:get_metadata())
|
local fullness = tonumber(itemstack:get_metadata())
|
||||||
if not fullness then fullness = LIQUID_MAX end
|
if not fullness then fullness = LIQUID_MAX end
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ function bucket.register_liquid(source, flowing, itemname, inventory_image, name
|
|||||||
else
|
else
|
||||||
-- not buildable to; place the liquid above
|
-- not buildable to; place the liquid above
|
||||||
-- check if the node above can be replaced
|
-- check if the node above can be replaced
|
||||||
local node = minetest.env:get_node(pointed_thing.above)
|
local node = minetest.get_node(pointed_thing.above)
|
||||||
if minetest.registered_nodes[node.name].buildable_to then
|
if minetest.registered_nodes[node.name].buildable_to then
|
||||||
place_liquid(pointed_thing.above, node, source, flowing, fullness)
|
place_liquid(pointed_thing.above, node, source, flowing, fullness)
|
||||||
else
|
else
|
||||||
@ -98,12 +98,12 @@ minetest.register_craftitem("bucket:bucket_empty", {
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
-- Check if pointing to a liquid source
|
-- Check if pointing to a liquid source
|
||||||
node = minetest.env:get_node(pointed_thing.under)
|
node = minetest.get_node(pointed_thing.under)
|
||||||
liquiddef = bucket.liquids[node.name]
|
liquiddef = bucket.liquids[node.name]
|
||||||
if liquiddef ~= nil and liquiddef.itemname ~= nil and (node.name == liquiddef.source or
|
if liquiddef ~= nil and liquiddef.itemname ~= nil and (node.name == liquiddef.source or
|
||||||
(node.name == liquiddef.flowing and minetest.setting_getbool("liquid_finite"))) then
|
(node.name == liquiddef.flowing and minetest.setting_getbool("liquid_finite"))) then
|
||||||
|
|
||||||
minetest.env:add_node(pointed_thing.under, {name="air"})
|
minetest.add_node(pointed_thing.under, {name="air"})
|
||||||
|
|
||||||
if node.name == liquiddef.source then node.param2 = LIQUID_MAX end
|
if node.name == liquiddef.source then node.param2 = LIQUID_MAX end
|
||||||
return ItemStack({name = liquiddef.itemname, metadata = tostring(node.param2)})
|
return ItemStack({name = liquiddef.itemname, metadata = tostring(node.param2)})
|
||||||
|
@ -123,11 +123,11 @@ minetest.register_on_punchnode(on_punchnode)
|
|||||||
--
|
--
|
||||||
|
|
||||||
default.cool_lava_source = function(pos)
|
default.cool_lava_source = function(pos)
|
||||||
minetest.env:set_node(pos, {name="default:obsidian"})
|
minetest.set_node(pos, {name="default:obsidian"})
|
||||||
end
|
end
|
||||||
|
|
||||||
default.cool_lava_flowing = function(pos)
|
default.cool_lava_flowing = function(pos)
|
||||||
minetest.env:set_node(pos, {name="default:stone"})
|
minetest.set_node(pos, {name="default:stone"})
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
@ -161,17 +161,17 @@ minetest.register_abm({
|
|||||||
chance = 20,
|
chance = 20,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
pos.y = pos.y-1
|
pos.y = pos.y-1
|
||||||
local name = minetest.env:get_node(pos).name
|
local name = minetest.get_node(pos).name
|
||||||
if minetest.get_item_group(name, "sand") ~= 0 then
|
if minetest.get_item_group(name, "sand") ~= 0 then
|
||||||
pos.y = pos.y+1
|
pos.y = pos.y+1
|
||||||
local height = 0
|
local height = 0
|
||||||
while minetest.env:get_node(pos).name == "default:cactus" and height < 4 do
|
while minetest.get_node(pos).name == "default:cactus" and height < 4 do
|
||||||
height = height+1
|
height = height+1
|
||||||
pos.y = pos.y+1
|
pos.y = pos.y+1
|
||||||
end
|
end
|
||||||
if height < 4 then
|
if height < 4 then
|
||||||
if minetest.env:get_node(pos).name == "air" then
|
if minetest.get_node(pos).name == "air" then
|
||||||
minetest.env:set_node(pos, {name="default:cactus"})
|
minetest.set_node(pos, {name="default:cactus"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -185,20 +185,20 @@ minetest.register_abm({
|
|||||||
chance = 20,
|
chance = 20,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
pos.y = pos.y-1
|
pos.y = pos.y-1
|
||||||
local name = minetest.env:get_node(pos).name
|
local name = minetest.get_node(pos).name
|
||||||
if name == "default:dirt" or name == "default:dirt_with_grass" then
|
if name == "default:dirt" or name == "default:dirt_with_grass" then
|
||||||
if minetest.env:find_node_near(pos, 3, {"group:water"}) == nil then
|
if minetest.find_node_near(pos, 3, {"group:water"}) == nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
pos.y = pos.y+1
|
pos.y = pos.y+1
|
||||||
local height = 0
|
local height = 0
|
||||||
while minetest.env:get_node(pos).name == "default:papyrus" and height < 4 do
|
while minetest.get_node(pos).name == "default:papyrus" and height < 4 do
|
||||||
height = height+1
|
height = height+1
|
||||||
pos.y = pos.y+1
|
pos.y = pos.y+1
|
||||||
end
|
end
|
||||||
if height < 4 then
|
if height < 4 then
|
||||||
if minetest.env:get_node(pos).name == "air" then
|
if minetest.get_node(pos).name == "air" then
|
||||||
minetest.env:set_node(pos, {name="default:papyrus"})
|
minetest.set_node(pos, {name="default:papyrus"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -246,7 +246,7 @@ minetest.register_abm({
|
|||||||
--print("not groups.leafdecay")
|
--print("not groups.leafdecay")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local n0 = minetest.env:get_node(p0)
|
local n0 = minetest.get_node(p0)
|
||||||
if n0.param2 ~= 0 then
|
if n0.param2 ~= 0 then
|
||||||
--print("param2 ~= 0")
|
--print("param2 ~= 0")
|
||||||
return
|
return
|
||||||
@ -256,7 +256,7 @@ minetest.register_abm({
|
|||||||
p0_hash = minetest.hash_node_position(p0)
|
p0_hash = minetest.hash_node_position(p0)
|
||||||
local trunkp = default.leafdecay_trunk_cache[p0_hash]
|
local trunkp = default.leafdecay_trunk_cache[p0_hash]
|
||||||
if trunkp then
|
if trunkp then
|
||||||
local n = minetest.env:get_node(trunkp)
|
local n = minetest.get_node(trunkp)
|
||||||
local reg = minetest.registered_nodes[n.name]
|
local reg = minetest.registered_nodes[n.name]
|
||||||
-- Assume ignore is a trunk, to make the thing work at the border of the active area
|
-- Assume ignore is a trunk, to make the thing work at the border of the active area
|
||||||
if n.name == "ignore" or (reg and reg.groups.tree and reg.groups.tree ~= 0) then
|
if n.name == "ignore" or (reg and reg.groups.tree and reg.groups.tree ~= 0) then
|
||||||
@ -274,7 +274,7 @@ minetest.register_abm({
|
|||||||
default.leafdecay_trunk_find_allow_accumulator =
|
default.leafdecay_trunk_find_allow_accumulator =
|
||||||
default.leafdecay_trunk_find_allow_accumulator - 1
|
default.leafdecay_trunk_find_allow_accumulator - 1
|
||||||
-- Assume ignore is a trunk, to make the thing work at the border of the active area
|
-- Assume ignore is a trunk, to make the thing work at the border of the active area
|
||||||
local p1 = minetest.env:find_node_near(p0, d, {"ignore", "group:tree"})
|
local p1 = minetest.find_node_near(p0, d, {"ignore", "group:tree"})
|
||||||
if p1 then
|
if p1 then
|
||||||
do_preserve = true
|
do_preserve = true
|
||||||
if default.leafdecay_enable_cache then
|
if default.leafdecay_enable_cache then
|
||||||
@ -294,11 +294,11 @@ minetest.register_abm({
|
|||||||
y = p0.y - 0.5 + math.random(),
|
y = p0.y - 0.5 + math.random(),
|
||||||
z = p0.z - 0.5 + math.random(),
|
z = p0.z - 0.5 + math.random(),
|
||||||
}
|
}
|
||||||
minetest.env:add_item(p_drop, itemname)
|
minetest.add_item(p_drop, itemname)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Remove node
|
-- Remove node
|
||||||
minetest.env:remove_node(p0)
|
minetest.remove_node(p0)
|
||||||
nodeupdate(p0)
|
nodeupdate(p0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -300,8 +300,8 @@ function default.generate_ore(name, wherein, minp, maxp, seed, chunks_per_volume
|
|||||||
local y2 = y0+y1
|
local y2 = y0+y1
|
||||||
local z2 = z0+z1
|
local z2 = z0+z1
|
||||||
local p2 = {x=x2, y=y2, z=z2}
|
local p2 = {x=x2, y=y2, z=z2}
|
||||||
if minetest.env:get_node(p2).name == wherein then
|
if minetest.get_node(p2).name == wherein then
|
||||||
minetest.env:set_node(p2, {name=name})
|
minetest.set_node(p2, {name=name})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -315,10 +315,10 @@ end
|
|||||||
function default.make_papyrus(pos, size)
|
function default.make_papyrus(pos, size)
|
||||||
for y=0,size-1 do
|
for y=0,size-1 do
|
||||||
local p = {x=pos.x, y=pos.y+y, z=pos.z}
|
local p = {x=pos.x, y=pos.y+y, z=pos.z}
|
||||||
local nn = minetest.env:get_node(p).name
|
local nn = minetest.get_node(p).name
|
||||||
if minetest.registered_nodes[nn] and
|
if minetest.registered_nodes[nn] and
|
||||||
minetest.registered_nodes[nn].buildable_to then
|
minetest.registered_nodes[nn].buildable_to then
|
||||||
minetest.env:set_node(p, {name="default:papyrus"})
|
minetest.set_node(p, {name="default:papyrus"})
|
||||||
else
|
else
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -328,10 +328,10 @@ end
|
|||||||
function default.make_cactus(pos, size)
|
function default.make_cactus(pos, size)
|
||||||
for y=0,size-1 do
|
for y=0,size-1 do
|
||||||
local p = {x=pos.x, y=pos.y+y, z=pos.z}
|
local p = {x=pos.x, y=pos.y+y, z=pos.z}
|
||||||
local nn = minetest.env:get_node(p).name
|
local nn = minetest.get_node(p).name
|
||||||
if minetest.registered_nodes[nn] and
|
if minetest.registered_nodes[nn] and
|
||||||
minetest.registered_nodes[nn].buildable_to then
|
minetest.registered_nodes[nn].buildable_to then
|
||||||
minetest.env:set_node(p, {name="default:cactus"})
|
minetest.set_node(p, {name="default:cactus"})
|
||||||
else
|
else
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -356,11 +356,11 @@ function default.make_nyancat(pos, facedir, length)
|
|||||||
tailvec.z = 1
|
tailvec.z = 1
|
||||||
end
|
end
|
||||||
local p = {x=pos.x, y=pos.y, z=pos.z}
|
local p = {x=pos.x, y=pos.y, z=pos.z}
|
||||||
minetest.env:set_node(p, {name="default:nyancat", param2=facedir})
|
minetest.set_node(p, {name="default:nyancat", param2=facedir})
|
||||||
for i=1,length do
|
for i=1,length do
|
||||||
p.x = p.x + tailvec.x
|
p.x = p.x + tailvec.x
|
||||||
p.z = p.z + tailvec.z
|
p.z = p.z + tailvec.z
|
||||||
minetest.env:set_node(p, {name="default:nyancat_rainbow"})
|
minetest.set_node(p, {name="default:nyancat_rainbow"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -396,17 +396,17 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
for divz=0+1,divs-1-1 do
|
for divz=0+1,divs-1-1 do
|
||||||
local cx = minp.x + math.floor((divx+0.5)*divlen)
|
local cx = minp.x + math.floor((divx+0.5)*divlen)
|
||||||
local cz = minp.z + math.floor((divz+0.5)*divlen)
|
local cz = minp.z + math.floor((divz+0.5)*divlen)
|
||||||
if minetest.env:get_node({x=cx,y=1,z=cz}).name == "default:water_source" and
|
if minetest.get_node({x=cx,y=1,z=cz}).name == "default:water_source" and
|
||||||
minetest.env:get_node({x=cx,y=0,z=cz}).name == "default:sand" then
|
minetest.get_node({x=cx,y=0,z=cz}).name == "default:sand" then
|
||||||
local is_shallow = true
|
local is_shallow = true
|
||||||
local num_water_around = 0
|
local num_water_around = 0
|
||||||
if minetest.env:get_node({x=cx-divlen*2,y=1,z=cz+0}).name == "default:water_source" then
|
if minetest.get_node({x=cx-divlen*2,y=1,z=cz+0}).name == "default:water_source" then
|
||||||
num_water_around = num_water_around + 1 end
|
num_water_around = num_water_around + 1 end
|
||||||
if minetest.env:get_node({x=cx+divlen*2,y=1,z=cz+0}).name == "default:water_source" then
|
if minetest.get_node({x=cx+divlen*2,y=1,z=cz+0}).name == "default:water_source" then
|
||||||
num_water_around = num_water_around + 1 end
|
num_water_around = num_water_around + 1 end
|
||||||
if minetest.env:get_node({x=cx+0,y=1,z=cz-divlen*2}).name == "default:water_source" then
|
if minetest.get_node({x=cx+0,y=1,z=cz-divlen*2}).name == "default:water_source" then
|
||||||
num_water_around = num_water_around + 1 end
|
num_water_around = num_water_around + 1 end
|
||||||
if minetest.env:get_node({x=cx+0,y=1,z=cz+divlen*2}).name == "default:water_source" then
|
if minetest.get_node({x=cx+0,y=1,z=cz+divlen*2}).name == "default:water_source" then
|
||||||
num_water_around = num_water_around + 1 end
|
num_water_around = num_water_around + 1 end
|
||||||
if num_water_around >= 2 then
|
if num_water_around >= 2 then
|
||||||
is_shallow = false
|
is_shallow = false
|
||||||
@ -414,8 +414,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
if is_shallow then
|
if is_shallow then
|
||||||
for x1=-divlen,divlen do
|
for x1=-divlen,divlen do
|
||||||
for z1=-divlen,divlen do
|
for z1=-divlen,divlen do
|
||||||
if minetest.env:get_node({x=cx+x1,y=0,z=cz+z1}).name == "default:sand" then
|
if minetest.get_node({x=cx+x1,y=0,z=cz+z1}).name == "default:sand" then
|
||||||
minetest.env:set_node({x=cx+x1,y=0,z=cz+z1}, {name="default:clay"})
|
minetest.set_node({x=cx+x1,y=0,z=cz+z1}, {name="default:clay"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -424,7 +424,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Generate papyrus
|
-- Generate papyrus
|
||||||
local perlin1 = minetest.env:get_perlin(354, 3, 0.7, 100)
|
local perlin1 = minetest.get_perlin(354, 3, 0.7, 100)
|
||||||
-- Assume X and Z lengths are equal
|
-- Assume X and Z lengths are equal
|
||||||
local divlen = 8
|
local divlen = 8
|
||||||
local divs = (maxp.x-minp.x)/divlen+1;
|
local divs = (maxp.x-minp.x)/divlen+1;
|
||||||
@ -441,15 +441,15 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
for i=0,papyrus_amount do
|
for i=0,papyrus_amount do
|
||||||
local x = pr:next(x0, x1)
|
local x = pr:next(x0, x1)
|
||||||
local z = pr:next(z0, z1)
|
local z = pr:next(z0, z1)
|
||||||
if minetest.env:get_node({x=x,y=1,z=z}).name == "default:dirt_with_grass" and
|
if minetest.get_node({x=x,y=1,z=z}).name == "default:dirt_with_grass" and
|
||||||
minetest.env:find_node_near({x=x,y=1,z=z}, 1, "default:water_source") then
|
minetest.find_node_near({x=x,y=1,z=z}, 1, "default:water_source") then
|
||||||
default.make_papyrus({x=x,y=2,z=z}, pr:next(2, 4))
|
default.make_papyrus({x=x,y=2,z=z}, pr:next(2, 4))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Generate cactuses
|
-- Generate cactuses
|
||||||
local perlin1 = minetest.env:get_perlin(230, 3, 0.6, 100)
|
local perlin1 = minetest.get_perlin(230, 3, 0.6, 100)
|
||||||
-- Assume X and Z lengths are equal
|
-- Assume X and Z lengths are equal
|
||||||
local divlen = 16
|
local divlen = 16
|
||||||
local divs = (maxp.x-minp.x)/divlen+1;
|
local divs = (maxp.x-minp.x)/divlen+1;
|
||||||
@ -469,20 +469,20 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
-- Find ground level (0...15)
|
-- Find ground level (0...15)
|
||||||
local ground_y = nil
|
local ground_y = nil
|
||||||
for y=30,0,-1 do
|
for y=30,0,-1 do
|
||||||
if minetest.env:get_node({x=x,y=y,z=z}).name ~= "air" then
|
if minetest.get_node({x=x,y=y,z=z}).name ~= "air" then
|
||||||
ground_y = y
|
ground_y = y
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- If desert sand, make cactus
|
-- If desert sand, make cactus
|
||||||
if ground_y and minetest.env:get_node({x=x,y=ground_y,z=z}).name == "default:desert_sand" then
|
if ground_y and minetest.get_node({x=x,y=ground_y,z=z}).name == "default:desert_sand" then
|
||||||
default.make_cactus({x=x,y=ground_y+1,z=z}, pr:next(3, 4))
|
default.make_cactus({x=x,y=ground_y+1,z=z}, pr:next(3, 4))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Generate grass
|
-- Generate grass
|
||||||
local perlin1 = minetest.env:get_perlin(329, 3, 0.6, 100)
|
local perlin1 = minetest.get_perlin(329, 3, 0.6, 100)
|
||||||
-- Assume X and Z lengths are equal
|
-- Assume X and Z lengths are equal
|
||||||
local divlen = 16
|
local divlen = 16
|
||||||
local divs = (maxp.x-minp.x)/divlen+1;
|
local divs = (maxp.x-minp.x)/divlen+1;
|
||||||
@ -502,7 +502,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
-- Find ground level (0...15)
|
-- Find ground level (0...15)
|
||||||
local ground_y = nil
|
local ground_y = nil
|
||||||
for y=30,0,-1 do
|
for y=30,0,-1 do
|
||||||
if minetest.env:get_node({x=x,y=y,z=z}).name ~= "air" then
|
if minetest.get_node({x=x,y=y,z=z}).name ~= "air" then
|
||||||
ground_y = y
|
ground_y = y
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
@ -510,18 +510,18 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
|
|
||||||
if ground_y then
|
if ground_y then
|
||||||
local p = {x=x,y=ground_y+1,z=z}
|
local p = {x=x,y=ground_y+1,z=z}
|
||||||
local nn = minetest.env:get_node(p).name
|
local nn = minetest.get_node(p).name
|
||||||
-- Check if the node can be replaced
|
-- Check if the node can be replaced
|
||||||
if minetest.registered_nodes[nn] and
|
if minetest.registered_nodes[nn] and
|
||||||
minetest.registered_nodes[nn].buildable_to then
|
minetest.registered_nodes[nn].buildable_to then
|
||||||
nn = minetest.env:get_node({x=x,y=ground_y,z=z}).name
|
nn = minetest.get_node({x=x,y=ground_y,z=z}).name
|
||||||
-- If desert sand, add dry shrub
|
-- If desert sand, add dry shrub
|
||||||
if nn == "default:desert_sand" then
|
if nn == "default:desert_sand" then
|
||||||
minetest.env:set_node(p,{name="default:dry_shrub"})
|
minetest.set_node(p,{name="default:dry_shrub"})
|
||||||
|
|
||||||
-- If dirt with grass, add grass
|
-- If dirt with grass, add grass
|
||||||
elseif nn == "default:dirt_with_grass" then
|
elseif nn == "default:dirt_with_grass" then
|
||||||
minetest.env:set_node(p,{name="default:grass_"..pr:next(1, 5)})
|
minetest.set_node(p,{name="default:grass_"..pr:next(1, 5)})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -584,14 +584,14 @@ minetest.register_node("default:sign_wall", {
|
|||||||
legacy_wallmounted = true,
|
legacy_wallmounted = true,
|
||||||
sounds = default.node_sound_defaults(),
|
sounds = default.node_sound_defaults(),
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
--local n = minetest.env:get_node(pos)
|
--local n = minetest.get_node(pos)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("formspec", "field[text;;${text}]")
|
meta:set_string("formspec", "field[text;;${text}]")
|
||||||
meta:set_string("infotext", "\"\"")
|
meta:set_string("infotext", "\"\"")
|
||||||
end,
|
end,
|
||||||
on_receive_fields = function(pos, formname, fields, sender)
|
on_receive_fields = function(pos, formname, fields, sender)
|
||||||
--print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields))
|
--print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields))
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
fields.text = fields.text or ""
|
fields.text = fields.text or ""
|
||||||
print((sender:get_player_name() or "").." wrote \""..fields.text..
|
print((sender:get_player_name() or "").." wrote \""..fields.text..
|
||||||
"\" to sign at "..minetest.pos_to_string(pos))
|
"\" to sign at "..minetest.pos_to_string(pos))
|
||||||
@ -609,7 +609,7 @@ minetest.register_node("default:chest", {
|
|||||||
legacy_facedir_simple = true,
|
legacy_facedir_simple = true,
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("formspec",
|
meta:set_string("formspec",
|
||||||
"size[8,9]"..
|
"size[8,9]"..
|
||||||
"list[current_name;main;0,0;8,4;]"..
|
"list[current_name;main;0,0;8,4;]"..
|
||||||
@ -619,7 +619,7 @@ minetest.register_node("default:chest", {
|
|||||||
inv:set_size("main", 8*4)
|
inv:set_size("main", 8*4)
|
||||||
end,
|
end,
|
||||||
can_dig = function(pos,player)
|
can_dig = function(pos,player)
|
||||||
local meta = minetest.env:get_meta(pos);
|
local meta = minetest.get_meta(pos);
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
return inv:is_empty("main")
|
return inv:is_empty("main")
|
||||||
end,
|
end,
|
||||||
@ -653,25 +653,25 @@ minetest.register_node("default:chest_locked", {
|
|||||||
legacy_facedir_simple = true,
|
legacy_facedir_simple = true,
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
after_place_node = function(pos, placer)
|
after_place_node = function(pos, placer)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("owner", placer:get_player_name() or "")
|
meta:set_string("owner", placer:get_player_name() or "")
|
||||||
meta:set_string("infotext", "Locked Chest (owned by "..
|
meta:set_string("infotext", "Locked Chest (owned by "..
|
||||||
meta:get_string("owner")..")")
|
meta:get_string("owner")..")")
|
||||||
end,
|
end,
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("infotext", "Locked Chest")
|
meta:set_string("infotext", "Locked Chest")
|
||||||
meta:set_string("owner", "")
|
meta:set_string("owner", "")
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
inv:set_size("main", 8*4)
|
inv:set_size("main", 8*4)
|
||||||
end,
|
end,
|
||||||
can_dig = function(pos,player)
|
can_dig = function(pos,player)
|
||||||
local meta = minetest.env:get_meta(pos);
|
local meta = minetest.get_meta(pos);
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
return inv:is_empty("main") and has_locked_chest_privilege(meta, player)
|
return inv:is_empty("main") and has_locked_chest_privilege(meta, player)
|
||||||
end,
|
end,
|
||||||
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
if not has_locked_chest_privilege(meta, player) then
|
if not has_locked_chest_privilege(meta, player) then
|
||||||
minetest.log("action", player:get_player_name()..
|
minetest.log("action", player:get_player_name()..
|
||||||
" tried to access a locked chest belonging to "..
|
" tried to access a locked chest belonging to "..
|
||||||
@ -682,7 +682,7 @@ minetest.register_node("default:chest_locked", {
|
|||||||
return count
|
return count
|
||||||
end,
|
end,
|
||||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
if not has_locked_chest_privilege(meta, player) then
|
if not has_locked_chest_privilege(meta, player) then
|
||||||
minetest.log("action", player:get_player_name()..
|
minetest.log("action", player:get_player_name()..
|
||||||
" tried to access a locked chest belonging to "..
|
" tried to access a locked chest belonging to "..
|
||||||
@ -693,7 +693,7 @@ minetest.register_node("default:chest_locked", {
|
|||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
end,
|
end,
|
||||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
if not has_locked_chest_privilege(meta, player) then
|
if not has_locked_chest_privilege(meta, player) then
|
||||||
minetest.log("action", player:get_player_name()..
|
minetest.log("action", player:get_player_name()..
|
||||||
" tried to access a locked chest belonging to "..
|
" tried to access a locked chest belonging to "..
|
||||||
@ -716,7 +716,7 @@ minetest.register_node("default:chest_locked", {
|
|||||||
" takes stuff from locked chest at "..minetest.pos_to_string(pos))
|
" takes stuff from locked chest at "..minetest.pos_to_string(pos))
|
||||||
end,
|
end,
|
||||||
on_rightclick = function(pos, node, clicker)
|
on_rightclick = function(pos, node, clicker)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
if has_locked_chest_privilege(meta, clicker) then
|
if has_locked_chest_privilege(meta, clicker) then
|
||||||
local pos = pos.x .. "," .. pos.y .. "," ..pos.z
|
local pos = pos.x .. "," .. pos.y .. "," ..pos.z
|
||||||
minetest.show_formspec(clicker:get_player_name(), "default:chest_locked",
|
minetest.show_formspec(clicker:get_player_name(), "default:chest_locked",
|
||||||
@ -744,7 +744,7 @@ minetest.register_node("default:furnace", {
|
|||||||
legacy_facedir_simple = true,
|
legacy_facedir_simple = true,
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("formspec", default.furnace_inactive_formspec)
|
meta:set_string("formspec", default.furnace_inactive_formspec)
|
||||||
meta:set_string("infotext", "Furnace")
|
meta:set_string("infotext", "Furnace")
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
@ -753,7 +753,7 @@ minetest.register_node("default:furnace", {
|
|||||||
inv:set_size("dst", 4)
|
inv:set_size("dst", 4)
|
||||||
end,
|
end,
|
||||||
can_dig = function(pos,player)
|
can_dig = function(pos,player)
|
||||||
local meta = minetest.env:get_meta(pos);
|
local meta = minetest.get_meta(pos);
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
if not inv:is_empty("fuel") then
|
if not inv:is_empty("fuel") then
|
||||||
return false
|
return false
|
||||||
@ -765,7 +765,7 @@ minetest.register_node("default:furnace", {
|
|||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
if listname == "fuel" then
|
if listname == "fuel" then
|
||||||
if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
|
if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
|
||||||
@ -783,7 +783,7 @@ minetest.register_node("default:furnace", {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
local stack = inv:get_stack(from_list, from_index)
|
local stack = inv:get_stack(from_list, from_index)
|
||||||
if to_list == "fuel" then
|
if to_list == "fuel" then
|
||||||
@ -814,7 +814,7 @@ minetest.register_node("default:furnace_active", {
|
|||||||
legacy_facedir_simple = true,
|
legacy_facedir_simple = true,
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("formspec", default.furnace_inactive_formspec)
|
meta:set_string("formspec", default.furnace_inactive_formspec)
|
||||||
meta:set_string("infotext", "Furnace");
|
meta:set_string("infotext", "Furnace");
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
@ -823,7 +823,7 @@ minetest.register_node("default:furnace_active", {
|
|||||||
inv:set_size("dst", 4)
|
inv:set_size("dst", 4)
|
||||||
end,
|
end,
|
||||||
can_dig = function(pos,player)
|
can_dig = function(pos,player)
|
||||||
local meta = minetest.env:get_meta(pos);
|
local meta = minetest.get_meta(pos);
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
if not inv:is_empty("fuel") then
|
if not inv:is_empty("fuel") then
|
||||||
return false
|
return false
|
||||||
@ -835,7 +835,7 @@ minetest.register_node("default:furnace_active", {
|
|||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
if listname == "fuel" then
|
if listname == "fuel" then
|
||||||
if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
|
if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
|
||||||
@ -853,7 +853,7 @@ minetest.register_node("default:furnace_active", {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
local stack = inv:get_stack(from_list, from_index)
|
local stack = inv:get_stack(from_list, from_index)
|
||||||
if to_list == "fuel" then
|
if to_list == "fuel" then
|
||||||
@ -874,16 +874,16 @@ minetest.register_node("default:furnace_active", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
function hacky_swap_node(pos,name)
|
function hacky_swap_node(pos,name)
|
||||||
local node = minetest.env:get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local meta0 = meta:to_table()
|
local meta0 = meta:to_table()
|
||||||
if node.name == name then
|
if node.name == name then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
node.name = name
|
node.name = name
|
||||||
local meta0 = meta:to_table()
|
local meta0 = meta:to_table()
|
||||||
minetest.env:set_node(pos,node)
|
minetest.set_node(pos,node)
|
||||||
meta = minetest.env:get_meta(pos)
|
meta = minetest.get_meta(pos)
|
||||||
meta:from_table(meta0)
|
meta:from_table(meta0)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -892,7 +892,7 @@ minetest.register_abm({
|
|||||||
interval = 1.0,
|
interval = 1.0,
|
||||||
chance = 1,
|
chance = 1,
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
for i, name in ipairs({
|
for i, name in ipairs({
|
||||||
"fuel_totaltime",
|
"fuel_totaltime",
|
||||||
"fuel_time",
|
"fuel_time",
|
||||||
@ -1129,7 +1129,7 @@ minetest.register_node("default:apple", {
|
|||||||
sounds = default.node_sound_defaults(),
|
sounds = default.node_sound_defaults(),
|
||||||
after_place_node = function(pos, placer, itemstack)
|
after_place_node = function(pos, placer, itemstack)
|
||||||
if placer:is_player() then
|
if placer:is_player() then
|
||||||
minetest.env:set_node(pos, {name="default:apple", param2=1})
|
minetest.set_node(pos, {name="default:apple", param2=1})
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
@ -1280,8 +1280,8 @@ minetest.register_node("default:snow", {
|
|||||||
}),
|
}),
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
pos.y = pos.y - 1
|
pos.y = pos.y - 1
|
||||||
if minetest.env:get_node(pos).name == "default:dirt_with_grass" then
|
if minetest.get_node(pos).name == "default:dirt_with_grass" then
|
||||||
minetest.env:set_node(pos, {name="default:dirt_with_snow"})
|
minetest.set_node(pos, {name="default:dirt_with_snow"})
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
@ -43,7 +43,7 @@ function doors:register_door(name, def)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local ptu = pointed_thing.under
|
local ptu = pointed_thing.under
|
||||||
local nu = minetest.env:get_node(ptu)
|
local nu = minetest.get_node(ptu)
|
||||||
if minetest.registered_nodes[nu.name].on_rightclick then
|
if minetest.registered_nodes[nu.name].on_rightclick then
|
||||||
return minetest.registered_nodes[nu.name].on_rightclick(ptu, nu, placer, itemstack)
|
return minetest.registered_nodes[nu.name].on_rightclick(ptu, nu, placer, itemstack)
|
||||||
end
|
end
|
||||||
@ -52,8 +52,8 @@ function doors:register_door(name, def)
|
|||||||
local pt2 = {x=pt.x, y=pt.y, z=pt.z}
|
local pt2 = {x=pt.x, y=pt.y, z=pt.z}
|
||||||
pt2.y = pt2.y+1
|
pt2.y = pt2.y+1
|
||||||
if
|
if
|
||||||
not minetest.registered_nodes[minetest.env:get_node(pt).name].buildable_to or
|
not minetest.registered_nodes[minetest.get_node(pt).name].buildable_to or
|
||||||
not minetest.registered_nodes[minetest.env:get_node(pt2).name].buildable_to or
|
not minetest.registered_nodes[minetest.get_node(pt2).name].buildable_to or
|
||||||
not placer or
|
not placer or
|
||||||
not placer:is_player()
|
not placer:is_player()
|
||||||
then
|
then
|
||||||
@ -71,20 +71,20 @@ function doors:register_door(name, def)
|
|||||||
elseif p2 == 3 then
|
elseif p2 == 3 then
|
||||||
pt3.z = pt3.z-1
|
pt3.z = pt3.z-1
|
||||||
end
|
end
|
||||||
if not string.find(minetest.env:get_node(pt3).name, name.."_b_") then
|
if not string.find(minetest.get_node(pt3).name, name.."_b_") then
|
||||||
minetest.env:set_node(pt, {name=name.."_b_1", param2=p2})
|
minetest.set_node(pt, {name=name.."_b_1", param2=p2})
|
||||||
minetest.env:set_node(pt2, {name=name.."_t_1", param2=p2})
|
minetest.set_node(pt2, {name=name.."_t_1", param2=p2})
|
||||||
else
|
else
|
||||||
minetest.env:set_node(pt, {name=name.."_b_2", param2=p2})
|
minetest.set_node(pt, {name=name.."_b_2", param2=p2})
|
||||||
minetest.env:set_node(pt2, {name=name.."_t_2", param2=p2})
|
minetest.set_node(pt2, {name=name.."_t_2", param2=p2})
|
||||||
end
|
end
|
||||||
|
|
||||||
if def.only_placer_can_open then
|
if def.only_placer_can_open then
|
||||||
local pn = placer:get_player_name()
|
local pn = placer:get_player_name()
|
||||||
local meta = minetest.env:get_meta(pt)
|
local meta = minetest.get_meta(pt)
|
||||||
meta:set_string("doors_owner", pn)
|
meta:set_string("doors_owner", pn)
|
||||||
meta:set_string("infotext", "Owned by "..pn)
|
meta:set_string("infotext", "Owned by "..pn)
|
||||||
meta = minetest.env:get_meta(pt2)
|
meta = minetest.get_meta(pt2)
|
||||||
meta:set_string("doors_owner", pn)
|
meta:set_string("doors_owner", pn)
|
||||||
meta:set_string("infotext", "Owned by "..pn)
|
meta:set_string("infotext", "Owned by "..pn)
|
||||||
end
|
end
|
||||||
@ -100,34 +100,34 @@ function doors:register_door(name, def)
|
|||||||
local tb = def.tiles_bottom
|
local tb = def.tiles_bottom
|
||||||
|
|
||||||
local function after_dig_node(pos, name)
|
local function after_dig_node(pos, name)
|
||||||
if minetest.env:get_node(pos).name == name then
|
if minetest.get_node(pos).name == name then
|
||||||
minetest.env:remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function on_rightclick(pos, dir, check_name, replace, replace_dir, params)
|
local function on_rightclick(pos, dir, check_name, replace, replace_dir, params)
|
||||||
pos.y = pos.y+dir
|
pos.y = pos.y+dir
|
||||||
if not minetest.env:get_node(pos).name == check_name then
|
if not minetest.get_node(pos).name == check_name then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local p2 = minetest.env:get_node(pos).param2
|
local p2 = minetest.get_node(pos).param2
|
||||||
p2 = params[p2+1]
|
p2 = params[p2+1]
|
||||||
|
|
||||||
local meta = minetest.env:get_meta(pos):to_table()
|
local meta = minetest.get_meta(pos):to_table()
|
||||||
minetest.env:set_node(pos, {name=replace_dir, param2=p2})
|
minetest.set_node(pos, {name=replace_dir, param2=p2})
|
||||||
minetest.env:get_meta(pos):from_table(meta)
|
minetest.get_meta(pos):from_table(meta)
|
||||||
|
|
||||||
pos.y = pos.y-dir
|
pos.y = pos.y-dir
|
||||||
meta = minetest.env:get_meta(pos):to_table()
|
meta = minetest.get_meta(pos):to_table()
|
||||||
minetest.env:set_node(pos, {name=replace, param2=p2})
|
minetest.set_node(pos, {name=replace, param2=p2})
|
||||||
minetest.env:get_meta(pos):from_table(meta)
|
minetest.get_meta(pos):from_table(meta)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function check_player_priv(pos, player)
|
local function check_player_priv(pos, player)
|
||||||
if not def.only_placer_can_open then
|
if not def.only_placer_can_open then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local pn = player:get_player_name()
|
local pn = player:get_player_name()
|
||||||
return meta:get_string("doors_owner") == pn
|
return meta:get_string("doors_owner") == pn
|
||||||
end
|
end
|
||||||
|
@ -28,28 +28,28 @@ minetest.register_abm({
|
|||||||
chance = 4,
|
chance = 4,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
pos.y = pos.y+1
|
pos.y = pos.y+1
|
||||||
local nn = minetest.env:get_node(pos).name
|
local nn = minetest.get_node(pos).name
|
||||||
pos.y = pos.y-1
|
pos.y = pos.y-1
|
||||||
if minetest.registered_nodes[nn] and minetest.registered_nodes[nn].walkable then
|
if minetest.registered_nodes[nn] and minetest.registered_nodes[nn].walkable then
|
||||||
minetest.env:set_node(pos, {name="default:dirt"})
|
minetest.set_node(pos, {name="default:dirt"})
|
||||||
end
|
end
|
||||||
-- check if there is water nearby
|
-- check if there is water nearby
|
||||||
if minetest.env:find_node_near(pos, 3, {"group:water"}) then
|
if minetest.find_node_near(pos, 3, {"group:water"}) then
|
||||||
-- if it is dry soil turn it into wet soil
|
-- if it is dry soil turn it into wet soil
|
||||||
if node.name == "farming:soil" then
|
if node.name == "farming:soil" then
|
||||||
minetest.env:set_node(pos, {name="farming:soil_wet"})
|
minetest.set_node(pos, {name="farming:soil_wet"})
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- turn it back into dirt if it is already dry
|
-- turn it back into dirt if it is already dry
|
||||||
if node.name == "farming:soil" then
|
if node.name == "farming:soil" then
|
||||||
-- only turn it back if there is no plant on top of it
|
-- only turn it back if there is no plant on top of it
|
||||||
if minetest.get_item_group(nn, "plant") == 0 then
|
if minetest.get_item_group(nn, "plant") == 0 then
|
||||||
minetest.env:set_node(pos, {name="default:dirt"})
|
minetest.set_node(pos, {name="default:dirt"})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- if its wet turn it back into dry soil
|
-- if its wet turn it back into dry soil
|
||||||
elseif node.name == "farming:soil_wet" then
|
elseif node.name == "farming:soil_wet" then
|
||||||
minetest.env:set_node(pos, {name="farming:soil"})
|
minetest.set_node(pos, {name="farming:soil"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@ -69,9 +69,9 @@ local function hoe_on_use(itemstack, user, pointed_thing, uses)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local under = minetest.env:get_node(pt.under)
|
local under = minetest.get_node(pt.under)
|
||||||
local p = {x=pt.under.x, y=pt.under.y+1, z=pt.under.z}
|
local p = {x=pt.under.x, y=pt.under.y+1, z=pt.under.z}
|
||||||
local above = minetest.env:get_node(p)
|
local above = minetest.get_node(p)
|
||||||
|
|
||||||
-- return if any of the nodes is not registered
|
-- return if any of the nodes is not registered
|
||||||
if not minetest.registered_nodes[under.name] then
|
if not minetest.registered_nodes[under.name] then
|
||||||
@ -92,7 +92,7 @@ local function hoe_on_use(itemstack, user, pointed_thing, uses)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- turn the node into soil, wear out item and play sound
|
-- turn the node into soil, wear out item and play sound
|
||||||
minetest.env:set_node(pt.under, {name="farming:soil"})
|
minetest.set_node(pt.under, {name="farming:soil"})
|
||||||
minetest.sound_play("default_dig_crumbly", {
|
minetest.sound_play("default_dig_crumbly", {
|
||||||
pos = pt.under,
|
pos = pt.under,
|
||||||
gain = 0.5,
|
gain = 0.5,
|
||||||
@ -273,8 +273,8 @@ local function place_seed(itemstack, placer, pointed_thing, plantname)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local under = minetest.env:get_node(pt.under)
|
local under = minetest.get_node(pt.under)
|
||||||
local above = minetest.env:get_node(pt.above)
|
local above = minetest.get_node(pt.above)
|
||||||
|
|
||||||
-- return if any of the nodes is not registered
|
-- return if any of the nodes is not registered
|
||||||
if not minetest.registered_nodes[under.name] then
|
if not minetest.registered_nodes[under.name] then
|
||||||
@ -300,7 +300,7 @@ local function place_seed(itemstack, placer, pointed_thing, plantname)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- add the node and remove 1 item from the itemstack
|
-- add the node and remove 1 item from the itemstack
|
||||||
minetest.env:add_node(pt.above, {name=plantname})
|
minetest.add_node(pt.above, {name=plantname})
|
||||||
if not minetest.setting_getbool("creative_mode") then
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
end
|
end
|
||||||
@ -386,23 +386,23 @@ minetest.register_abm({
|
|||||||
|
|
||||||
-- check if on wet soil
|
-- check if on wet soil
|
||||||
pos.y = pos.y-1
|
pos.y = pos.y-1
|
||||||
local n = minetest.env:get_node(pos)
|
local n = minetest.get_node(pos)
|
||||||
if minetest.get_item_group(n.name, "soil") < 3 then
|
if minetest.get_item_group(n.name, "soil") < 3 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
pos.y = pos.y+1
|
pos.y = pos.y+1
|
||||||
|
|
||||||
-- check light
|
-- check light
|
||||||
if not minetest.env:get_node_light(pos) then
|
if not minetest.get_node_light(pos) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if minetest.env:get_node_light(pos) < 13 then
|
if minetest.get_node_light(pos) < 13 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- grow
|
-- grow
|
||||||
local height = minetest.get_item_group(node.name, "wheat") + 1
|
local height = minetest.get_item_group(node.name, "wheat") + 1
|
||||||
minetest.env:set_node(pos, {name="farming:wheat_"..height})
|
minetest.set_node(pos, {name="farming:wheat_"..height})
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -471,22 +471,22 @@ minetest.register_abm({
|
|||||||
|
|
||||||
-- check if on wet soil
|
-- check if on wet soil
|
||||||
pos.y = pos.y-1
|
pos.y = pos.y-1
|
||||||
local n = minetest.env:get_node(pos)
|
local n = minetest.get_node(pos)
|
||||||
if minetest.get_item_group(n.name, "soil") < 3 then
|
if minetest.get_item_group(n.name, "soil") < 3 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
pos.y = pos.y+1
|
pos.y = pos.y+1
|
||||||
|
|
||||||
-- check light
|
-- check light
|
||||||
if not minetest.env:get_node_light(pos) then
|
if not minetest.get_node_light(pos) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if minetest.env:get_node_light(pos) < 13 then
|
if minetest.get_node_light(pos) < 13 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- grow
|
-- grow
|
||||||
local height = minetest.get_item_group(node.name, "cotton") + 1
|
local height = minetest.get_item_group(node.name, "cotton") + 1
|
||||||
minetest.env:set_node(pos, {name="farming:cotton_"..height})
|
minetest.set_node(pos, {name="farming:cotton_"..height})
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
@ -47,7 +47,7 @@ end
|
|||||||
function fire.update_sounds_around(pos)
|
function fire.update_sounds_around(pos)
|
||||||
local p0, p1 = fire.get_area_p0p1(pos)
|
local p0, p1 = fire.get_area_p0p1(pos)
|
||||||
local cp = {x=(p0.x+p1.x)/2, y=(p0.y+p1.y)/2, z=(p0.z+p1.z)/2}
|
local cp = {x=(p0.x+p1.x)/2, y=(p0.y+p1.y)/2, z=(p0.z+p1.z)/2}
|
||||||
local flames_p = minetest.env:find_nodes_in_area(p0, p1, {"fire:basic_flame"})
|
local flames_p = minetest.find_nodes_in_area(p0, p1, {"fire:basic_flame"})
|
||||||
--print("number of flames at "..minetest.pos_to_string(p0).."/"
|
--print("number of flames at "..minetest.pos_to_string(p0).."/"
|
||||||
-- ..minetest.pos_to_string(p1)..": "..#flames_p)
|
-- ..minetest.pos_to_string(p1)..": "..#flames_p)
|
||||||
local should_have_sound = (#flames_p > 0)
|
local should_have_sound = (#flames_p > 0)
|
||||||
@ -91,15 +91,15 @@ function fire.on_flame_remove_at(pos)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function fire.find_pos_for_flame_around(pos)
|
function fire.find_pos_for_flame_around(pos)
|
||||||
return minetest.env:find_node_near(pos, 1, {"air"})
|
return minetest.find_node_near(pos, 1, {"air"})
|
||||||
end
|
end
|
||||||
|
|
||||||
function fire.flame_should_extinguish(pos)
|
function fire.flame_should_extinguish(pos)
|
||||||
if minetest.setting_getbool("disable_fire") then return true end
|
if minetest.setting_getbool("disable_fire") then return true end
|
||||||
--return minetest.env:find_node_near(pos, 1, {"group:puts_out_fire"})
|
--return minetest.find_node_near(pos, 1, {"group:puts_out_fire"})
|
||||||
local p0 = {x=pos.x-2, y=pos.y, z=pos.z-2}
|
local p0 = {x=pos.x-2, y=pos.y, z=pos.z-2}
|
||||||
local p1 = {x=pos.x+2, y=pos.y, z=pos.z+2}
|
local p1 = {x=pos.x+2, y=pos.y, z=pos.z+2}
|
||||||
local ps = minetest.env:find_nodes_in_area(p0, p1, {"group:puts_out_fire"})
|
local ps = minetest.find_nodes_in_area(p0, p1, {"group:puts_out_fire"})
|
||||||
return (#ps ~= 0)
|
return (#ps ~= 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ minetest.register_abm({
|
|||||||
end
|
end
|
||||||
local p = fire.find_pos_for_flame_around(p0)
|
local p = fire.find_pos_for_flame_around(p0)
|
||||||
if p then
|
if p then
|
||||||
minetest.env:set_node(p, {name="fire:basic_flame"})
|
minetest.set_node(p, {name="fire:basic_flame"})
|
||||||
fire.on_flame_add_at(p)
|
fire.on_flame_add_at(p)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@ -134,7 +134,7 @@ minetest.register_abm({
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
local d = reg.groups.igniter
|
local d = reg.groups.igniter
|
||||||
local p = minetest.env:find_node_near(p0, d, {"group:flammable"})
|
local p = minetest.find_node_near(p0, d, {"group:flammable"})
|
||||||
if p then
|
if p then
|
||||||
-- If there is water or stuff like that around flame, don't ignite
|
-- If there is water or stuff like that around flame, don't ignite
|
||||||
if fire.flame_should_extinguish(p) then
|
if fire.flame_should_extinguish(p) then
|
||||||
@ -142,7 +142,7 @@ minetest.register_abm({
|
|||||||
end
|
end
|
||||||
local p2 = fire.find_pos_for_flame_around(p)
|
local p2 = fire.find_pos_for_flame_around(p)
|
||||||
if p2 then
|
if p2 then
|
||||||
minetest.env:set_node(p2, {name="fire:basic_flame"})
|
minetest.set_node(p2, {name="fire:basic_flame"})
|
||||||
fire.on_flame_add_at(p2)
|
fire.on_flame_add_at(p2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -157,7 +157,7 @@ minetest.register_abm({
|
|||||||
action = function(p0, node, _, _)
|
action = function(p0, node, _, _)
|
||||||
-- If there is water or stuff like that around flame, remove flame
|
-- If there is water or stuff like that around flame, remove flame
|
||||||
if fire.flame_should_extinguish(p0) then
|
if fire.flame_should_extinguish(p0) then
|
||||||
minetest.env:remove_node(p0)
|
minetest.remove_node(p0)
|
||||||
fire.on_flame_remove_at(p0)
|
fire.on_flame_remove_at(p0)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -166,25 +166,25 @@ minetest.register_abm({
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
-- If there are no flammable nodes around flame, remove flame
|
-- If there are no flammable nodes around flame, remove flame
|
||||||
if not minetest.env:find_node_near(p0, 1, {"group:flammable"}) then
|
if not minetest.find_node_near(p0, 1, {"group:flammable"}) then
|
||||||
minetest.env:remove_node(p0)
|
minetest.remove_node(p0)
|
||||||
fire.on_flame_remove_at(p0)
|
fire.on_flame_remove_at(p0)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if math.random(1,4) == 1 then
|
if math.random(1,4) == 1 then
|
||||||
-- remove a flammable node around flame
|
-- remove a flammable node around flame
|
||||||
local p = minetest.env:find_node_near(p0, 1, {"group:flammable"})
|
local p = minetest.find_node_near(p0, 1, {"group:flammable"})
|
||||||
if p then
|
if p then
|
||||||
-- If there is water or stuff like that around flame, don't remove
|
-- If there is water or stuff like that around flame, don't remove
|
||||||
if fire.flame_should_extinguish(p0) then
|
if fire.flame_should_extinguish(p0) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
minetest.env:remove_node(p)
|
minetest.remove_node(p)
|
||||||
nodeupdate(p)
|
nodeupdate(p)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- remove flame
|
-- remove flame
|
||||||
minetest.env:remove_node(p0)
|
minetest.remove_node(p0)
|
||||||
fire.on_flame_remove_at(p0)
|
fire.on_flame_remove_at(p0)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
@ -127,40 +127,40 @@ minetest.register_abm({
|
|||||||
chance = 25,
|
chance = 25,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
pos.y = pos.y - 1
|
pos.y = pos.y - 1
|
||||||
local under = minetest.env:get_node(pos)
|
local under = minetest.get_node(pos)
|
||||||
pos.y = pos.y + 1
|
pos.y = pos.y + 1
|
||||||
if under.name == "default:desert_sand" then
|
if under.name == "default:desert_sand" then
|
||||||
minetest.env:set_node(pos, {name="default:dry_shrub"})
|
minetest.set_node(pos, {name="default:dry_shrub"})
|
||||||
elseif under.name ~= "default:dirt_with_grass" then
|
elseif under.name ~= "default:dirt_with_grass" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local light = minetest.env:get_node_light(pos)
|
local light = minetest.get_node_light(pos)
|
||||||
if not light or light < 13 then
|
if not light or light < 13 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local pos0 = {x=pos.x-4,y=pos.y-4,z=pos.z-4}
|
local pos0 = {x=pos.x-4,y=pos.y-4,z=pos.z-4}
|
||||||
local pos1 = {x=pos.x+4,y=pos.y+4,z=pos.z+4}
|
local pos1 = {x=pos.x+4,y=pos.y+4,z=pos.z+4}
|
||||||
if #minetest.env:find_nodes_in_area(pos0, pos1, "group:flora_block") > 0 then
|
if #minetest.find_nodes_in_area(pos0, pos1, "group:flora_block") > 0 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local flowers = minetest.env:find_nodes_in_area(pos0, pos1, "group:flora")
|
local flowers = minetest.find_nodes_in_area(pos0, pos1, "group:flora")
|
||||||
if #flowers > 3 then
|
if #flowers > 3 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local seedling = minetest.env:find_nodes_in_area(pos0, pos1, "default:dirt_with_grass")
|
local seedling = minetest.find_nodes_in_area(pos0, pos1, "default:dirt_with_grass")
|
||||||
if #seedling > 0 then
|
if #seedling > 0 then
|
||||||
seedling = seedling[math.random(#seedling)]
|
seedling = seedling[math.random(#seedling)]
|
||||||
seedling.y = seedling.y + 1
|
seedling.y = seedling.y + 1
|
||||||
light = minetest.env:get_node_light(seedling)
|
light = minetest.get_node_light(seedling)
|
||||||
if not light or light < 13 then
|
if not light or light < 13 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if minetest.env:get_node(seedling).name == "air" then
|
if minetest.get_node(seedling).name == "air" then
|
||||||
minetest.env:set_node(seedling, {name=node.name})
|
minetest.set_node(seedling, {name=node.name})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
minetest.register_on_generated(function(minp, maxp, seed)
|
minetest.register_on_generated(function(minp, maxp, seed)
|
||||||
if maxp.y >= 2 and minp.y <= 0 then
|
if maxp.y >= 2 and minp.y <= 0 then
|
||||||
-- Generate flowers
|
-- Generate flowers
|
||||||
local perlin1 = minetest.env:get_perlin(436, 3, 0.6, 100)
|
local perlin1 = minetest.get_perlin(436, 3, 0.6, 100)
|
||||||
-- Assume X and Z lengths are equal
|
-- Assume X and Z lengths are equal
|
||||||
local divlen = 16
|
local divlen = 16
|
||||||
local divs = (maxp.x-minp.x)/divlen+1;
|
local divs = (maxp.x-minp.x)/divlen+1;
|
||||||
@ -21,7 +21,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
-- Find ground level (0...15)
|
-- Find ground level (0...15)
|
||||||
local ground_y = nil
|
local ground_y = nil
|
||||||
for y=30,0,-1 do
|
for y=30,0,-1 do
|
||||||
if minetest.env:get_node({x=x,y=y,z=z}).name ~= "air" then
|
if minetest.get_node({x=x,y=y,z=z}).name ~= "air" then
|
||||||
ground_y = y
|
ground_y = y
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
@ -29,11 +29,11 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
|
|
||||||
if ground_y then
|
if ground_y then
|
||||||
local p = {x=x,y=ground_y+1,z=z}
|
local p = {x=x,y=ground_y+1,z=z}
|
||||||
local nn = minetest.env:get_node(p).name
|
local nn = minetest.get_node(p).name
|
||||||
-- Check if the node can be replaced
|
-- Check if the node can be replaced
|
||||||
if minetest.registered_nodes[nn] and
|
if minetest.registered_nodes[nn] and
|
||||||
minetest.registered_nodes[nn].buildable_to then
|
minetest.registered_nodes[nn].buildable_to then
|
||||||
nn = minetest.env:get_node({x=x,y=ground_y,z=z}).name
|
nn = minetest.get_node({x=x,y=ground_y,z=z}).name
|
||||||
if nn == "default:dirt_with_grass" then
|
if nn == "default:dirt_with_grass" then
|
||||||
local flower_choice = pr:next(1, 6)
|
local flower_choice = pr:next(1, 6)
|
||||||
local flower
|
local flower
|
||||||
@ -50,7 +50,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
elseif flower_choice == 6 then
|
elseif flower_choice == 6 then
|
||||||
flower = "flowers:viola"
|
flower = "flowers:viola"
|
||||||
end
|
end
|
||||||
minetest.env:set_node(p, {name=flower})
|
minetest.set_node(p, {name=flower})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -79,14 +79,14 @@ minetest.register_craftitem(":rat", {
|
|||||||
description = "Rat",
|
description = "Rat",
|
||||||
inventory_image = "rat.png",
|
inventory_image = "rat.png",
|
||||||
on_drop = function(item, dropper, pos)
|
on_drop = function(item, dropper, pos)
|
||||||
minetest.env:add_rat(pos)
|
minetest.add_rat(pos)
|
||||||
item:take_item()
|
item:take_item()
|
||||||
return item
|
return item
|
||||||
end,
|
end,
|
||||||
on_place = function(item, dropped, pointed)
|
on_place = function(item, dropped, pointed)
|
||||||
pos = minetest.get_pointed_thing_position(pointed, true)
|
pos = minetest.get_pointed_thing_position(pointed, true)
|
||||||
if pos ~= nil then
|
if pos ~= nil then
|
||||||
minetest.env:add_rat(pos)
|
minetest.add_rat(pos)
|
||||||
item:take_item()
|
item:take_item()
|
||||||
return item
|
return item
|
||||||
end
|
end
|
||||||
@ -104,14 +104,14 @@ minetest.register_craftitem(":firefly", {
|
|||||||
inventory_image = "firefly.png",
|
inventory_image = "firefly.png",
|
||||||
groups = {not_in_creative_inventory=1},
|
groups = {not_in_creative_inventory=1},
|
||||||
on_drop = function(item, dropper, pos)
|
on_drop = function(item, dropper, pos)
|
||||||
minetest.env:add_firefly(pos)
|
minetest.add_firefly(pos)
|
||||||
item:take_item()
|
item:take_item()
|
||||||
return item
|
return item
|
||||||
end,
|
end,
|
||||||
on_place = function(item, dropped, pointed)
|
on_place = function(item, dropped, pointed)
|
||||||
pos = minetest.get_pointed_thing_position(pointed, true)
|
pos = minetest.get_pointed_thing_position(pointed, true)
|
||||||
if pos ~= nil then
|
if pos ~= nil then
|
||||||
minetest.env:add_firefly(pos)
|
minetest.add_firefly(pos)
|
||||||
item:take_item()
|
item:take_item()
|
||||||
return item
|
return item
|
||||||
end
|
end
|
||||||
|
@ -61,7 +61,7 @@ function screwdriver_handler (itemstack,user,pointed_thing)
|
|||||||
local mode=tonumber((item["metadata"]))
|
local mode=tonumber((item["metadata"]))
|
||||||
if pointed_thing.type~="node" then return end
|
if pointed_thing.type~="node" then return end
|
||||||
local pos=minetest.get_pointed_thing_position(pointed_thing,above)
|
local pos=minetest.get_pointed_thing_position(pointed_thing,above)
|
||||||
local node=minetest.env:get_node(pos)
|
local node=minetest.get_node(pos)
|
||||||
local node_name=node.name
|
local node_name=node.name
|
||||||
if minetest.registered_nodes[node_name].paramtype2 == "facedir" then
|
if minetest.registered_nodes[node_name].paramtype2 == "facedir" then
|
||||||
if minetest.registered_nodes[node_name].drawtype == "nodebox" then
|
if minetest.registered_nodes[node_name].drawtype == "nodebox" then
|
||||||
@ -113,11 +113,11 @@ function screwdriver_handler (itemstack,user,pointed_thing)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
--print (dump(axisdir..", "..rotation))
|
--print (dump(axisdir..", "..rotation))
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local meta0 = meta:to_table()
|
local meta0 = meta:to_table()
|
||||||
node.param2 = n
|
node.param2 = n
|
||||||
minetest.env:set_node(pos,node)
|
minetest.set_node(pos,node)
|
||||||
meta = minetest.env:get_meta(pos)
|
meta = minetest.get_meta(pos)
|
||||||
meta:from_table(meta0)
|
meta:from_table(meta0)
|
||||||
local item=itemstack:to_table()
|
local item=itemstack:to_table()
|
||||||
local item_wear=tonumber((item["wear"]))
|
local item_wear=tonumber((item["wear"]))
|
||||||
|
@ -105,7 +105,7 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
|
|||||||
local slabnode = nil
|
local slabnode = nil
|
||||||
local p0 = pointed_thing.under
|
local p0 = pointed_thing.under
|
||||||
local p1 = pointed_thing.above
|
local p1 = pointed_thing.above
|
||||||
local n0 = minetest.env:get_node(p0)
|
local n0 = minetest.get_node(p0)
|
||||||
if n0.name == "stairs:slab_" .. subname and
|
if n0.name == "stairs:slab_" .. subname and
|
||||||
p0.y+1 == p1.y then
|
p0.y+1 == p1.y then
|
||||||
slabpos = p0
|
slabpos = p0
|
||||||
@ -113,7 +113,7 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
|
|||||||
end
|
end
|
||||||
if slabpos then
|
if slabpos then
|
||||||
-- Remove the slab at slabpos
|
-- Remove the slab at slabpos
|
||||||
minetest.env:remove_node(slabpos)
|
minetest.remove_node(slabpos)
|
||||||
-- Make a fake stack of a single item and try to place it
|
-- Make a fake stack of a single item and try to place it
|
||||||
local fakestack = ItemStack(recipeitem)
|
local fakestack = ItemStack(recipeitem)
|
||||||
pointed_thing.above = slabpos
|
pointed_thing.above = slabpos
|
||||||
@ -123,7 +123,7 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
|
|||||||
itemstack:take_item(1)
|
itemstack:take_item(1)
|
||||||
-- Else put old node back
|
-- Else put old node back
|
||||||
else
|
else
|
||||||
minetest.env:set_node(slabpos, slabnode)
|
minetest.set_node(slabpos, slabnode)
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
@ -133,7 +133,7 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
|
|||||||
-- Turn into full block if pointing at a existing slab
|
-- Turn into full block if pointing at a existing slab
|
||||||
if n0.name == "stairs:slab_" .. subname.."upside_down" then
|
if n0.name == "stairs:slab_" .. subname.."upside_down" then
|
||||||
-- Remove the slab at the position of the slab
|
-- Remove the slab at the position of the slab
|
||||||
minetest.env:remove_node(p0)
|
minetest.remove_node(p0)
|
||||||
-- Make a fake stack of a single item and try to place it
|
-- Make a fake stack of a single item and try to place it
|
||||||
local fakestack = ItemStack(recipeitem)
|
local fakestack = ItemStack(recipeitem)
|
||||||
pointed_thing.above = p0
|
pointed_thing.above = p0
|
||||||
@ -143,7 +143,7 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
|
|||||||
itemstack:take_item(1)
|
itemstack:take_item(1)
|
||||||
-- Else put old node back
|
-- Else put old node back
|
||||||
else
|
else
|
||||||
minetest.env:set_node(p0, n0)
|
minetest.set_node(p0, n0)
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user