diff options
Diffstat (limited to 'ufos')
-rw-r--r-- | ufos/furnace.lua | 18 | ||||
-rw-r--r-- | ufos/init.lua | 14 |
2 files changed, 17 insertions, 15 deletions
diff --git a/ufos/furnace.lua b/ufos/furnace.lua index 6e3d2a1..bde74ae 100644 --- a/ufos/furnace.lua +++ b/ufos/furnace.lua @@ -20,14 +20,14 @@ minetest.register_node("ufos:furnace", { legacy_facedir_simple = true, sounds = default.node_sound_stone_defaults(), on_construct = function(pos) - local meta = minetest.env:get_meta(pos) + local meta = minetest.get_meta(pos) meta:set_string("formspec", ufos.furnace_inactive_formspec) meta:set_string("infotext", "UFO charging device") local inv = meta:get_inventory() inv:set_size("fuel", 1) end, can_dig = function(pos,player) - local meta = minetest.env:get_meta(pos); + local meta = minetest.get_meta(pos); local inv = meta:get_inventory() if not inv:is_empty("fuel") then return false @@ -47,14 +47,14 @@ minetest.register_node("ufos:furnace_active", { legacy_facedir_simple = true, sounds = default.node_sound_stone_defaults(), on_construct = function(pos) - local meta = minetest.env:get_meta(pos) + local meta = minetest.get_meta(pos) meta:set_string("formspec", ufos.furnace_inactive_formspec) meta:set_string("infotext", "UFO charging device") local inv = meta:get_inventory() inv:set_size("fuel", 1) end, can_dig = function(pos,player) - local meta = minetest.env:get_meta(pos); + local meta = minetest.get_meta(pos); local inv = meta:get_inventory() if not inv:is_empty("fuel") then return false @@ -64,16 +64,16 @@ minetest.register_node("ufos:furnace_active", { }) function hacky_swap_node(pos,name) - local node = minetest.env:get_node(pos) - local meta = minetest.env:get_meta(pos) + local node = minetest.get_node(pos) + local meta = minetest.get_meta(pos) local meta0 = meta:to_table() if node.name == name then return end node.name = name local meta0 = meta:to_table() - minetest.env:set_node(pos,node) - meta = minetest.env:get_meta(pos) + minetest.set_node(pos,node) + meta = minetest.get_meta(pos) meta:from_table(meta0) end @@ -82,7 +82,7 @@ minetest.register_abm({ interval = .25, chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) - local meta = minetest.env:get_meta(pos) + local meta = minetest.get_meta(pos) local inv = meta:get_inventory() local stack = inv:get_stack("fuel",1) if stack:get_name() == ufos.fuel then diff --git a/ufos/init.lua b/ufos/init.lua index cb68e65..40fd241 100644 --- a/ufos/init.lua +++ b/ufos/init.lua @@ -1,6 +1,8 @@ ufos = {} +local e + local floor_pos = function(pos) return {x=math.floor(pos.x),y=math.floor(pos.y),z=math.floor(pos.z)} end @@ -46,7 +48,7 @@ ufos.ufo_from_item = function(itemstack,placer,pointed_thing) local wear = itemstack:get_wear() ufos.set_fuel(ufos.ufo,ufos.fuel_from_wear(wear)) -- add the entity - e = minetest.env:add_entity(pointed_thing.above, "ufos:ufo") + e = minetest.add_entity(pointed_thing.above, "ufos:ufo") -- remove the item itemstack:take_item() -- reset owner for next ufo @@ -162,8 +164,8 @@ function ufos.ufo:on_step (dtime) local t = {{x=2,z=0},{x=-2,z=0},{x=0,z=2},{x=0,z=-2}} for _, i in ipairs(t) do pos.x = pos.x + i.x; pos.z = pos.z + i.z; - if minetest.env:get_node(pos).name == "ufos:furnace" then - meta = minetest.env:get_meta(pos) + if minetest.get_node(pos).name == "ufos:furnace" then + meta = minetest.get_meta(pos) if fuel < 100 and meta:get_int("charge") > 0 then fuel = fuel + 1 meta:set_int("charge",meta:get_int("charge")-1) @@ -235,16 +237,16 @@ minetest.register_node("ufos:box", { tiles = {"ufos_box.png"}, groups = {not_in_creative_inventory=1}, on_rightclick = function(pos, node, clicker, itemstack) - meta = minetest.env:get_meta(pos) + meta = minetest.get_meta(pos) if meta:get_string("owner") == clicker:get_player_name() then -- set owner ufos.next_owner = meta:get_string("owner") -- restore the fuel inside the node ufos.set_fuel(ufos.ufo,meta:get_int("fuel")) -- add the entity - e = minetest.env:add_entity(pos, "ufos:ufo") + e = minetest.add_entity(pos, "ufos:ufo") -- remove the node - minetest.env:remove_node(pos) + minetest.remove_node(pos) -- reset owner for next ufo ufos.next_owner = "" end |