summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2024-04-18 18:32:58 -0500
committercheapie <no-email-for-you@example.com>2024-04-18 18:32:58 -0500
commitfd8693671d81eda7ab62c397b77d9496c39cc2f2 (patch)
tree6d6a2972a19444cd00d80a28bf238c697c849e7e
parentfced29c598cdcda58aec2e5db4fca19aae06bf45 (diff)
downloadcelevator-fd8693671d81eda7ab62c397b77d9496c39cc2f2.tar
celevator-fd8693671d81eda7ab62c397b77d9496c39cc2f2.tar.gz
celevator-fd8693671d81eda7ab62c397b77d9496c39cc2f2.tar.bz2
celevator-fd8693671d81eda7ab62c397b77d9496c39cc2f2.tar.xz
celevator-fd8693671d81eda7ab62c397b77d9496c39cc2f2.zip
Fix more bugs
-rw-r--r--.luacheckrc1
-rw-r--r--callbuttons.lua2
-rw-r--r--controller.lua8
-rw-r--r--doors.lua18
-rw-r--r--drive_entity.lua38
-rw-r--r--drive_null.lua2
-rw-r--r--framework.lua7
-rw-r--r--fs1switch.lua2
-rw-r--r--pilantern.lua12
9 files changed, 49 insertions, 41 deletions
diff --git a/.luacheckrc b/.luacheckrc
index 15da4af..953d7c3 100644
--- a/.luacheckrc
+++ b/.luacheckrc
@@ -10,4 +10,5 @@ read_globals = {
"screwdriver",
"minetest",
"table.copy",
+ "VoxelManip",
}
diff --git a/callbuttons.lua b/callbuttons.lua
index 080ca54..46875fe 100644
--- a/callbuttons.lua
+++ b/callbuttons.lua
@@ -36,7 +36,7 @@ local validstates = {
}
function celevator.callbutton.setlight(pos,dir,newstate)
- local node = minetest.get_node(pos)
+ local node = celevator.get_node(pos)
if minetest.get_item_group(node.name,"_celevator_callbutton") ~= 1 then return end
if dir == "up" then
if minetest.get_item_group(node.name,"_celevator_callbutton_has_up") ~= 1 then return end
diff --git a/controller.lua b/controller.lua
index d60e2be..cb212ce 100644
--- a/controller.lua
+++ b/controller.lua
@@ -93,7 +93,7 @@ end
local function controllerleds(pos,running)
local toppos = vector.add(pos,vector.new(0,1,0))
- local node = minetest.get_node(toppos)
+ local node = celevator.get_node(toppos)
local sparams = {
pos = toppos,
}
@@ -397,12 +397,12 @@ function celevator.controller.iscontroller(pos,call2)
end
function celevator.controller.finddrive(pos)
- local node = minetest.get_node(pos)
+ local node = celevator.get_node(pos)
local dir = minetest.facedir_to_dir(node.param2)
local drivepos = vector.add(pos,vector.new(0,1,0))
drivepos = vector.add(drivepos,vector.rotate_around_axis(dir,vector.new(0,-1,0),math.pi/2))
drivepos = vector.round(drivepos)
- local drivename = minetest.get_node(drivepos).name
+ local drivename = celevator.get_node(drivepos).name
return drivepos,minetest.registered_nodes[drivename]._celevator_drive_type
end
@@ -440,7 +440,7 @@ function celevator.controller.finish(pos,mem,changedinterrupts)
end
end
end
- local node = minetest.get_node(pos)
+ local node = celevator.get_node(pos)
local oldmem = minetest.deserialize(meta:get_string("mem")) or {}
local oldupbuttonlights = oldmem.upcalls or {}
local olddownbuttonlights = oldmem.dncalls or {}
diff --git a/doors.lua b/doors.lua
index 4a17991..c443347 100644
--- a/doors.lua
+++ b/doors.lua
@@ -188,7 +188,7 @@ function celevator.doors.hwopen(pos,drivepos)
local hwdoors_moving = minetest.deserialize(celevator.storage:get_string("hwdoors_moving")) or {}
local hash = minetest.hash_node_position(pos)
if not hwdoors_moving[hash] then
- local param2 = minetest.get_node(pos).param2
+ local param2 = celevator.get_node(pos).param2
local fdir = minetest.fourdir_to_dir(param2)
local otherpanel = vector.add(pos,vector.rotate_around_axis(fdir,vector.new(0,1,0),-math.pi/2))
local positions = {
@@ -201,7 +201,7 @@ function celevator.doors.hwopen(pos,drivepos)
}
local oldnodes = {}
for i,position in ipairs(positions) do
- oldnodes[i] = minetest.get_node(position)
+ oldnodes[i] = celevator.get_node(position)
end
local erefs = celevator.drives.entity.nodestoentities(positions,"celevator:hwdoor_moving")
hwdoors_moving[hash] = {
@@ -220,7 +220,7 @@ function celevator.doors.hwopen(pos,drivepos)
pmeta:set_string("data",minetest.serialize(hwdoors_moving[hash]))
pmeta:set_string("state","opening")
local carpos = vector.add(pos,fdir)
- if minetest.get_node(carpos).name == "celevator:car_000" then
+ if celevator.get_node(carpos).name == "celevator:car_000" then
celevator.doors.caropen(carpos)
end
elseif hwdoors_moving[hash].direction == "close" then
@@ -229,7 +229,7 @@ function celevator.doors.hwopen(pos,drivepos)
celevator.storage:set_string("hwdoors_moving",minetest.serialize(hwdoors_moving))
local fdir = minetest.fourdir_to_dir(hwdoors_moving[hash].param2)
local carpos = vector.add(pos,fdir)
- if minetest.get_node(carpos).name == "celevator:car_000" then
+ if celevator.get_node(carpos).name == "celevator:car_000" then
celevator.doors.caropen(carpos)
end
minetest.set_node(pos,{name="celevator:hwdoor_placeholder",param2=hwdoors_moving[hash].param2})
@@ -248,9 +248,9 @@ function celevator.doors.hwclose(pos,drivepos)
local pmeta = minetest.get_meta(pos)
local state = pmeta:get_string("state")
if state ~= "open" then return end
- local fdir = minetest.fourdir_to_dir(minetest.get_node(pos).param2)
+ local fdir = minetest.fourdir_to_dir(celevator.get_node(pos).param2)
local carpos = vector.add(pos,fdir)
- if minetest.get_node(carpos).name == "celevator:car_000" then
+ if celevator.get_node(carpos).name == "celevator:car_000" then
celevator.doors.carclose(carpos)
end
local data = minetest.deserialize(pmeta:get_string("data"))
@@ -408,7 +408,7 @@ function celevator.doors.carstep(dtime)
minetest.get_meta(data.positions[1]):set_string("doorstate","open")
cardoors_moving[hash] = nil
elseif data.direction == "close" then
- local fdir = minetest.fourdir_to_dir(minetest.get_node(data.positions[1]).param2)
+ local fdir = minetest.fourdir_to_dir(celevator.get_node(data.positions[1]).param2)
celevator.doors.spawncardoors(data.positions[1],vector.rotate_around_axis(fdir,vector.new(0,1,0),math.pi))
minetest.get_meta(data.positions[1]):set_string("doorstate","closed")
cardoors_moving[hash] = nil
@@ -456,7 +456,7 @@ function celevator.doors.caropen(pos)
local cardoors_moving = minetest.deserialize(celevator.storage:get_string("cardoors_moving")) or {}
local hash = minetest.hash_node_position(pos)
if not cardoors_moving[hash] then
- local fdir = minetest.fourdir_to_dir(minetest.get_node(pos).param2)
+ local fdir = minetest.fourdir_to_dir(celevator.get_node(pos).param2)
local otherpanel = vector.add(pos,vector.rotate_around_axis(fdir,vector.new(0,1,0),-math.pi/2))
local positions = {
pos,
@@ -504,7 +504,7 @@ function celevator.doors.carclose(pos)
if state ~= "open" then return end
local data = minetest.deserialize(meta:get_string("doordata"))
if not data then return end
- local dir = minetest.fourdir_to_dir(minetest.get_node(pos).param2)
+ local dir = minetest.fourdir_to_dir(celevator.get_node(pos).param2)
data.direction = "close"
data.time = 0
local erefs = celevator.doors.spawncardoors(pos,dir)
diff --git a/drive_entity.lua b/drive_entity.lua
index 6378725..7702a92 100644
--- a/drive_entity.lua
+++ b/drive_entity.lua
@@ -191,22 +191,22 @@ function celevator.drives.entity.gathercar(pos,yaw,nodes)
local hash = minetest.hash_node_position(pos)
if nodes[hash] then return nodes end
nodes[hash] = true
- if minetest.get_item_group(minetest.get_node(pos).name,"_connects_xp") == 1 then
+ if minetest.get_item_group(celevator.get_node(pos).name,"_connects_xp") == 1 then
celevator.drives.entity.gathercar(vector.add(pos,vector.rotate_around_axis(vector.new(1,0,0),vector.new(0,1,0),yaw)),yaw,nodes)
end
- if minetest.get_item_group(minetest.get_node(pos).name,"_connects_xm") == 1 then
+ if minetest.get_item_group(celevator.get_node(pos).name,"_connects_xm") == 1 then
celevator.drives.entity.gathercar(vector.add(pos,vector.rotate_around_axis(vector.new(-1,0,0),vector.new(0,1,0),yaw)),yaw,nodes)
end
- if minetest.get_item_group(minetest.get_node(pos).name,"_connects_yp") == 1 then
+ if minetest.get_item_group(celevator.get_node(pos).name,"_connects_yp") == 1 then
celevator.drives.entity.gathercar(vector.add(pos,vector.new(0,1,0)),yaw,nodes)
end
- if minetest.get_item_group(minetest.get_node(pos).name,"_connects_ym") == 1 then
+ if minetest.get_item_group(celevator.get_node(pos).name,"_connects_ym") == 1 then
celevator.drives.entity.gathercar(vector.add(pos,vector.new(0,-1,0)),yaw,nodes)
end
- if minetest.get_item_group(minetest.get_node(pos).name,"_connects_zp") == 1 then
+ if minetest.get_item_group(celevator.get_node(pos).name,"_connects_zp") == 1 then
celevator.drives.entity.gathercar(vector.add(pos,vector.rotate_around_axis(vector.new(0,0,1),vector.new(0,1,0),yaw)),yaw,nodes)
end
- if minetest.get_item_group(minetest.get_node(pos).name,"_connects_zm") == 1 then
+ if minetest.get_item_group(celevator.get_node(pos).name,"_connects_zm") == 1 then
celevator.drives.entity.gathercar(vector.add(pos,vector.rotate_around_axis(vector.new(0,0,-1),vector.new(0,1,0),yaw)),yaw,nodes)
end
return nodes
@@ -215,7 +215,7 @@ end
function celevator.drives.entity.nodestoentities(nodes,ename)
local refs = {}
for _,pos in ipairs(nodes) do
- local node = minetest.get_node(pos)
+ local node = celevator.get_node(pos)
local attach = minetest.get_objects_inside_radius(pos,0.9)
local eref = minetest.add_entity(pos,(ename or "celevator:car_moving"))
eref:set_properties({
@@ -301,7 +301,7 @@ function celevator.drives.entity.step(dtime)
for i,hash in ipairs(entitydrives_running) do
save = true
local pos = minetest.get_position_from_hash(hash)
- local node = minetest.get_node(pos)
+ local node = celevator.get_node(pos)
local sound = false
if node.name == "ignore" then
minetest.forceload_block(pos,true)
@@ -334,7 +334,7 @@ function celevator.drives.entity.step(dtime)
end
end
local startv = vector.add(origin,vector.new(0,startpos,0))
- local hashes = celevator.drives.entity.gathercar(startv,minetest.dir_to_yaw(minetest.fourdir_to_dir(minetest.get_node(startv).param2)))
+ local hashes = celevator.drives.entity.gathercar(startv,minetest.dir_to_yaw(minetest.fourdir_to_dir(celevator.get_node(startv).param2)))
local nodes = {}
for carhash in pairs(hashes) do
local carpos = minetest.get_position_from_hash(carhash)
@@ -344,7 +344,7 @@ function celevator.drives.entity.step(dtime)
table.insert(nodes,carpos)
end
end
- local carparam2 = minetest.get_node(nodes[1]).param2
+ local carparam2 = celevator.get_node(nodes[1]).param2
meta:set_int("carparam2",carparam2)
local handles = celevator.drives.entity.nodestoentities(nodes)
celevator.drives.entity.entityinfo[hash] = {
@@ -591,12 +591,12 @@ function celevator.drives.entity.movedoors(drivepos,direction)
end
local apos = tonumber(drivemeta:get_string("apos")) or 0
local carpos = vector.add(origin,vector.new(0,apos,0))
- local carnode = minetest.get_node(carpos)
+ local carnode = celevator.get_node(carpos)
local hwdoorpos = vector.add(carpos,vector.rotate_around_axis(minetest.fourdir_to_dir(carnode.param2),vector.new(0,1,0),math.pi))
- if direction == "open" and (minetest.get_item_group(minetest.get_node(hwdoorpos).name,"_celevator_hwdoor_root") == 1 or drivemeta:get_string("doorstate") == "closing") then
+ if direction == "open" and (minetest.get_item_group(celevator.get_node(hwdoorpos).name,"_celevator_hwdoor_root") == 1 or drivemeta:get_string("doorstate") == "closing") then
celevator.doors.hwopen(hwdoorpos,drivepos)
drivemeta:set_string("doorstate","opening")
- elseif direction == "close" and minetest.get_node(hwdoorpos).name == "celevator:hwdoor_placeholder" then
+ elseif direction == "close" and celevator.get_node(hwdoorpos).name == "celevator:hwdoor_placeholder" then
celevator.doors.hwclose(hwdoorpos,drivepos)
drivemeta:set_string("doorstate","closing")
end
@@ -625,7 +625,7 @@ end
local function carsearch(pos)
for i=1,500,1 do
local searchpos = vector.subtract(pos,vector.new(0,i,0))
- local node = minetest.get_node(searchpos)
+ local node = celevator.get_node(searchpos)
if minetest.get_item_group(node.name,"_celevator_car") == 1 then
local yaw = minetest.dir_to_yaw(minetest.fourdir_to_dir(node.param2))
local offsettext = minetest.registered_nodes[node.name]._position
@@ -661,7 +661,7 @@ local function updatecarpos(pos)
drivemeta:set_int("carid",carid)
end
end
- local caryaw = minetest.dir_to_yaw(minetest.fourdir_to_dir(minetest.get_node(carpos).param2))
+ local caryaw = minetest.dir_to_yaw(minetest.fourdir_to_dir(celevator.get_node(carpos).param2))
local carnodes = celevator.drives.entity.gathercar(carpos,caryaw)
for hash in pairs(carnodes) do
local carmeta = minetest.get_meta(minetest.get_position_from_hash(hash))
@@ -827,7 +827,7 @@ minetest.register_entity("celevator:sheave_moving",{
function celevator.drives.entity.sheavetoentity(carid)
local carinfo = minetest.deserialize(celevator.storage:get_string(string.format("car%d",carid)))
if not (carinfo and carinfo.machinepos) then return end
- local dir = minetest.fourdir_to_dir(minetest.get_node(carinfo.machinepos).param2)
+ local dir = minetest.fourdir_to_dir(celevator.get_node(carinfo.machinepos).param2)
local pos = vector.add(carinfo.machinepos,vector.multiply(dir,-1))
minetest.set_node(pos,{
name = "celevator:sheave",
@@ -842,7 +842,7 @@ end
function celevator.drives.entity.sheavetonode(carid)
local carinfo = minetest.deserialize(celevator.storage:get_string(string.format("car%d",carid)))
if not (carinfo and carinfo.machinepos) then return end
- local dir = minetest.fourdir_to_dir(minetest.get_node(carinfo.machinepos).param2)
+ local dir = minetest.fourdir_to_dir(celevator.get_node(carinfo.machinepos).param2)
local pos = vector.add(carinfo.machinepos,vector.multiply(dir,-1))
local erefs = celevator.drives.entity.sheaverefs[carid]
if erefs and erefs[1] then
@@ -872,10 +872,10 @@ function celevator.drives.entity.updatecopformspec(drivepos)
end
local apos = tonumber(drivemeta:get_string("apos")) or 0
local carpos = vector.add(origin,vector.new(0,apos,0))
- local carnodes = celevator.drives.entity.gathercar(carpos,minetest.dir_to_yaw(minetest.fourdir_to_dir(minetest.get_node(carpos).param2)))
+ local carnodes = celevator.drives.entity.gathercar(carpos,minetest.dir_to_yaw(minetest.fourdir_to_dir(celevator.get_node(carpos).param2)))
for hash in pairs(carnodes) do
local piecepos = minetest.get_position_from_hash(hash)
- local piece = minetest.get_node(piecepos)
+ local piece = celevator.get_node(piecepos)
if piece.name == "celevator:car_010" then
minetest.get_meta(piecepos):set_string("formspec",copformspec)
elseif piece.name == "celevator:car_000" then
diff --git a/drive_null.lua b/drive_null.lua
index eaf1515..9cf4875 100644
--- a/drive_null.lua
+++ b/drive_null.lua
@@ -94,7 +94,7 @@ function celevator.drives.null.step(dtime)
for i,hash in ipairs(nulldrives_running) do
save = true
local pos = minetest.get_position_from_hash(hash)
- local node = minetest.get_node(pos)
+ local node = celevator.get_node(pos)
local sound = false
if node.name == "ignore" then
minetest.forceload_block(pos,true)
diff --git a/framework.lua b/framework.lua
index 695ac17..b75b41a 100644
--- a/framework.lua
+++ b/framework.lua
@@ -2,3 +2,10 @@ celevator = {
drives = {},
storage = minetest.get_mod_storage(),
}
+
+function celevator.get_node(pos)
+ local node = minetest.get_node_or_nil(pos)
+ if node then return node end
+ VoxelManip(pos,pos)
+ return minetest.get_node(pos)
+end
diff --git a/fs1switch.lua b/fs1switch.lua
index d63d2f1..d0f4349 100644
--- a/fs1switch.lua
+++ b/fs1switch.lua
@@ -70,7 +70,7 @@ function celevator.fs1switch.setled(pos,on)
["celevator:fs1switch_off"] = "celevator:fs1switch_off_lit",
["celevator:fs1switch_reset"] = "celevator:fs1switch_reset_lit",
}
- local node = minetest.get_node(pos)
+ local node = celevator.get_node(pos)
if on and onstates[node.name] then
node.name = onstates[node.name]
minetest.swap_node(pos,node)
diff --git a/pilantern.lua b/pilantern.lua
index 909c68f..3856c5d 100644
--- a/pilantern.lua
+++ b/pilantern.lua
@@ -75,13 +75,13 @@ function celevator.pi.updatedisplay(pos)
local meta = minetest.get_meta(pos)
local text = meta:get_string("text")
local entity = minetest.add_entity(pos,"celevator:pi_entity")
- local fdir = minetest.facedir_to_dir(minetest.get_node(pos).param2)
+ local fdir = minetest.facedir_to_dir(celevator.get_node(pos).param2)
local uparrow = meta:get_int("uparrow") > 0
local downarrow = meta:get_int("downarrow") > 0
local flash_fs = meta:get_int("flash_fs") > 0
local flash_is = meta:get_int("flash_is") > 0
local flashtimer = meta:get_int("flashtimer") > 0
- local islantern = minetest.get_item_group(minetest.get_node(pos).name,"_celevator_lantern") == 1
+ local islantern = minetest.get_item_group(celevator.get_node(pos).name,"_celevator_lantern") == 1
local etex = celevator.pi.generatetexture(text,uparrow,downarrow,islantern)
if flash_fs then
if flashtimer then etex = celevator.pi.generatetexture(" FS",uparrow,downarrow,islantern) end
@@ -98,7 +98,7 @@ function celevator.pi.updatedisplay(pos)
end
function celevator.pi.flash(pos,what)
- if minetest.get_item_group(minetest.get_node(pos).name,"_celevator_pi") ~= 1 then return end
+ if minetest.get_item_group(celevator.get_node(pos).name,"_celevator_pi") ~= 1 then return end
local meta = minetest.get_meta(pos)
if what == "FS" then
meta:set_int("flash_is",0)
@@ -114,7 +114,7 @@ function celevator.pi.flash(pos,what)
end
function celevator.pi.settext(pos,text)
- if minetest.get_item_group(minetest.get_node(pos).name,"_celevator_pi") ~= 1 then return end
+ if minetest.get_item_group(celevator.get_node(pos).name,"_celevator_pi") ~= 1 then return end
local meta = minetest.get_meta(pos)
if string.len(text) < 3 then
text = string.rep(" ",3-string.len(text))..text
@@ -124,7 +124,7 @@ function celevator.pi.settext(pos,text)
end
function celevator.pi.setarrow(pos,which,active)
- if minetest.get_item_group(minetest.get_node(pos).name,"_celevator_pi") ~= 1 then return end
+ if minetest.get_item_group(celevator.get_node(pos).name,"_celevator_pi") ~= 1 then return end
local meta = minetest.get_meta(pos)
if which == "up" then
meta:set_int("uparrow",active and 1 or 0)
@@ -195,7 +195,7 @@ minetest.register_node("celevator:pi",{
})
function celevator.lantern.setlight(pos,dir,newstate)
- local node = minetest.get_node(pos)
+ local node = celevator.get_node(pos)
if minetest.get_item_group(node.name,"_celevator_lantern") ~= 1 then return end
if dir == "up" then
if minetest.get_item_group(node.name,"_celevator_lantern_has_up") ~= 1 then return end