Fix more bugs
This commit is contained in:
parent
fced29c598
commit
fd8693671d
@ -10,4 +10,5 @@ read_globals = {
|
|||||||
"screwdriver",
|
"screwdriver",
|
||||||
"minetest",
|
"minetest",
|
||||||
"table.copy",
|
"table.copy",
|
||||||
|
"VoxelManip",
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ local validstates = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function celevator.callbutton.setlight(pos,dir,newstate)
|
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 minetest.get_item_group(node.name,"_celevator_callbutton") ~= 1 then return end
|
||||||
if dir == "up" then
|
if dir == "up" then
|
||||||
if minetest.get_item_group(node.name,"_celevator_callbutton_has_up") ~= 1 then return end
|
if minetest.get_item_group(node.name,"_celevator_callbutton_has_up") ~= 1 then return end
|
||||||
|
@ -93,7 +93,7 @@ end
|
|||||||
|
|
||||||
local function controllerleds(pos,running)
|
local function controllerleds(pos,running)
|
||||||
local toppos = vector.add(pos,vector.new(0,1,0))
|
local toppos = vector.add(pos,vector.new(0,1,0))
|
||||||
local node = minetest.get_node(toppos)
|
local node = celevator.get_node(toppos)
|
||||||
local sparams = {
|
local sparams = {
|
||||||
pos = toppos,
|
pos = toppos,
|
||||||
}
|
}
|
||||||
@ -397,12 +397,12 @@ function celevator.controller.iscontroller(pos,call2)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function celevator.controller.finddrive(pos)
|
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 dir = minetest.facedir_to_dir(node.param2)
|
||||||
local drivepos = vector.add(pos,vector.new(0,1,0))
|
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.add(drivepos,vector.rotate_around_axis(dir,vector.new(0,-1,0),math.pi/2))
|
||||||
drivepos = vector.round(drivepos)
|
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
|
return drivepos,minetest.registered_nodes[drivename]._celevator_drive_type
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -440,7 +440,7 @@ function celevator.controller.finish(pos,mem,changedinterrupts)
|
|||||||
end
|
end
|
||||||
end
|
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 oldmem = minetest.deserialize(meta:get_string("mem")) or {}
|
||||||
local oldupbuttonlights = oldmem.upcalls or {}
|
local oldupbuttonlights = oldmem.upcalls or {}
|
||||||
local olddownbuttonlights = oldmem.dncalls or {}
|
local olddownbuttonlights = oldmem.dncalls or {}
|
||||||
|
18
doors.lua
18
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 hwdoors_moving = minetest.deserialize(celevator.storage:get_string("hwdoors_moving")) or {}
|
||||||
local hash = minetest.hash_node_position(pos)
|
local hash = minetest.hash_node_position(pos)
|
||||||
if not hwdoors_moving[hash] then
|
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 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 otherpanel = vector.add(pos,vector.rotate_around_axis(fdir,vector.new(0,1,0),-math.pi/2))
|
||||||
local positions = {
|
local positions = {
|
||||||
@ -201,7 +201,7 @@ function celevator.doors.hwopen(pos,drivepos)
|
|||||||
}
|
}
|
||||||
local oldnodes = {}
|
local oldnodes = {}
|
||||||
for i,position in ipairs(positions) do
|
for i,position in ipairs(positions) do
|
||||||
oldnodes[i] = minetest.get_node(position)
|
oldnodes[i] = celevator.get_node(position)
|
||||||
end
|
end
|
||||||
local erefs = celevator.drives.entity.nodestoentities(positions,"celevator:hwdoor_moving")
|
local erefs = celevator.drives.entity.nodestoentities(positions,"celevator:hwdoor_moving")
|
||||||
hwdoors_moving[hash] = {
|
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("data",minetest.serialize(hwdoors_moving[hash]))
|
||||||
pmeta:set_string("state","opening")
|
pmeta:set_string("state","opening")
|
||||||
local carpos = vector.add(pos,fdir)
|
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)
|
celevator.doors.caropen(carpos)
|
||||||
end
|
end
|
||||||
elseif hwdoors_moving[hash].direction == "close" then
|
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))
|
celevator.storage:set_string("hwdoors_moving",minetest.serialize(hwdoors_moving))
|
||||||
local fdir = minetest.fourdir_to_dir(hwdoors_moving[hash].param2)
|
local fdir = minetest.fourdir_to_dir(hwdoors_moving[hash].param2)
|
||||||
local carpos = vector.add(pos,fdir)
|
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)
|
celevator.doors.caropen(carpos)
|
||||||
end
|
end
|
||||||
minetest.set_node(pos,{name="celevator:hwdoor_placeholder",param2=hwdoors_moving[hash].param2})
|
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 pmeta = minetest.get_meta(pos)
|
||||||
local state = pmeta:get_string("state")
|
local state = pmeta:get_string("state")
|
||||||
if state ~= "open" then return end
|
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)
|
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)
|
celevator.doors.carclose(carpos)
|
||||||
end
|
end
|
||||||
local data = minetest.deserialize(pmeta:get_string("data"))
|
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")
|
minetest.get_meta(data.positions[1]):set_string("doorstate","open")
|
||||||
cardoors_moving[hash] = nil
|
cardoors_moving[hash] = nil
|
||||||
elseif data.direction == "close" then
|
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))
|
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")
|
minetest.get_meta(data.positions[1]):set_string("doorstate","closed")
|
||||||
cardoors_moving[hash] = nil
|
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 cardoors_moving = minetest.deserialize(celevator.storage:get_string("cardoors_moving")) or {}
|
||||||
local hash = minetest.hash_node_position(pos)
|
local hash = minetest.hash_node_position(pos)
|
||||||
if not cardoors_moving[hash] then
|
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 otherpanel = vector.add(pos,vector.rotate_around_axis(fdir,vector.new(0,1,0),-math.pi/2))
|
||||||
local positions = {
|
local positions = {
|
||||||
pos,
|
pos,
|
||||||
@ -504,7 +504,7 @@ function celevator.doors.carclose(pos)
|
|||||||
if state ~= "open" then return end
|
if state ~= "open" then return end
|
||||||
local data = minetest.deserialize(meta:get_string("doordata"))
|
local data = minetest.deserialize(meta:get_string("doordata"))
|
||||||
if not data then return end
|
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.direction = "close"
|
||||||
data.time = 0
|
data.time = 0
|
||||||
local erefs = celevator.doors.spawncardoors(pos,dir)
|
local erefs = celevator.doors.spawncardoors(pos,dir)
|
||||||
|
@ -191,22 +191,22 @@ function celevator.drives.entity.gathercar(pos,yaw,nodes)
|
|||||||
local hash = minetest.hash_node_position(pos)
|
local hash = minetest.hash_node_position(pos)
|
||||||
if nodes[hash] then return nodes end
|
if nodes[hash] then return nodes end
|
||||||
nodes[hash] = true
|
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)
|
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
|
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)
|
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
|
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)
|
celevator.drives.entity.gathercar(vector.add(pos,vector.new(0,1,0)),yaw,nodes)
|
||||||
end
|
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)
|
celevator.drives.entity.gathercar(vector.add(pos,vector.new(0,-1,0)),yaw,nodes)
|
||||||
end
|
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)
|
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
|
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)
|
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
|
end
|
||||||
return nodes
|
return nodes
|
||||||
@ -215,7 +215,7 @@ end
|
|||||||
function celevator.drives.entity.nodestoentities(nodes,ename)
|
function celevator.drives.entity.nodestoentities(nodes,ename)
|
||||||
local refs = {}
|
local refs = {}
|
||||||
for _,pos in ipairs(nodes) do
|
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 attach = minetest.get_objects_inside_radius(pos,0.9)
|
||||||
local eref = minetest.add_entity(pos,(ename or "celevator:car_moving"))
|
local eref = minetest.add_entity(pos,(ename or "celevator:car_moving"))
|
||||||
eref:set_properties({
|
eref:set_properties({
|
||||||
@ -301,7 +301,7 @@ function celevator.drives.entity.step(dtime)
|
|||||||
for i,hash in ipairs(entitydrives_running) do
|
for i,hash in ipairs(entitydrives_running) do
|
||||||
save = true
|
save = true
|
||||||
local pos = minetest.get_position_from_hash(hash)
|
local pos = minetest.get_position_from_hash(hash)
|
||||||
local node = minetest.get_node(pos)
|
local node = celevator.get_node(pos)
|
||||||
local sound = false
|
local sound = false
|
||||||
if node.name == "ignore" then
|
if node.name == "ignore" then
|
||||||
minetest.forceload_block(pos,true)
|
minetest.forceload_block(pos,true)
|
||||||
@ -334,7 +334,7 @@ function celevator.drives.entity.step(dtime)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
local startv = vector.add(origin,vector.new(0,startpos,0))
|
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 = {}
|
local nodes = {}
|
||||||
for carhash in pairs(hashes) do
|
for carhash in pairs(hashes) do
|
||||||
local carpos = minetest.get_position_from_hash(carhash)
|
local carpos = minetest.get_position_from_hash(carhash)
|
||||||
@ -344,7 +344,7 @@ function celevator.drives.entity.step(dtime)
|
|||||||
table.insert(nodes,carpos)
|
table.insert(nodes,carpos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local carparam2 = minetest.get_node(nodes[1]).param2
|
local carparam2 = celevator.get_node(nodes[1]).param2
|
||||||
meta:set_int("carparam2",carparam2)
|
meta:set_int("carparam2",carparam2)
|
||||||
local handles = celevator.drives.entity.nodestoentities(nodes)
|
local handles = celevator.drives.entity.nodestoentities(nodes)
|
||||||
celevator.drives.entity.entityinfo[hash] = {
|
celevator.drives.entity.entityinfo[hash] = {
|
||||||
@ -591,12 +591,12 @@ function celevator.drives.entity.movedoors(drivepos,direction)
|
|||||||
end
|
end
|
||||||
local apos = tonumber(drivemeta:get_string("apos")) or 0
|
local apos = tonumber(drivemeta:get_string("apos")) or 0
|
||||||
local carpos = vector.add(origin,vector.new(0,apos,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))
|
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)
|
celevator.doors.hwopen(hwdoorpos,drivepos)
|
||||||
drivemeta:set_string("doorstate","opening")
|
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)
|
celevator.doors.hwclose(hwdoorpos,drivepos)
|
||||||
drivemeta:set_string("doorstate","closing")
|
drivemeta:set_string("doorstate","closing")
|
||||||
end
|
end
|
||||||
@ -625,7 +625,7 @@ end
|
|||||||
local function carsearch(pos)
|
local function carsearch(pos)
|
||||||
for i=1,500,1 do
|
for i=1,500,1 do
|
||||||
local searchpos = vector.subtract(pos,vector.new(0,i,0))
|
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
|
if minetest.get_item_group(node.name,"_celevator_car") == 1 then
|
||||||
local yaw = minetest.dir_to_yaw(minetest.fourdir_to_dir(node.param2))
|
local yaw = minetest.dir_to_yaw(minetest.fourdir_to_dir(node.param2))
|
||||||
local offsettext = minetest.registered_nodes[node.name]._position
|
local offsettext = minetest.registered_nodes[node.name]._position
|
||||||
@ -661,7 +661,7 @@ local function updatecarpos(pos)
|
|||||||
drivemeta:set_int("carid",carid)
|
drivemeta:set_int("carid",carid)
|
||||||
end
|
end
|
||||||
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)
|
local carnodes = celevator.drives.entity.gathercar(carpos,caryaw)
|
||||||
for hash in pairs(carnodes) do
|
for hash in pairs(carnodes) do
|
||||||
local carmeta = minetest.get_meta(minetest.get_position_from_hash(hash))
|
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)
|
function celevator.drives.entity.sheavetoentity(carid)
|
||||||
local carinfo = minetest.deserialize(celevator.storage:get_string(string.format("car%d",carid)))
|
local carinfo = minetest.deserialize(celevator.storage:get_string(string.format("car%d",carid)))
|
||||||
if not (carinfo and carinfo.machinepos) then return end
|
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 pos = vector.add(carinfo.machinepos,vector.multiply(dir,-1))
|
||||||
minetest.set_node(pos,{
|
minetest.set_node(pos,{
|
||||||
name = "celevator:sheave",
|
name = "celevator:sheave",
|
||||||
@ -842,7 +842,7 @@ end
|
|||||||
function celevator.drives.entity.sheavetonode(carid)
|
function celevator.drives.entity.sheavetonode(carid)
|
||||||
local carinfo = minetest.deserialize(celevator.storage:get_string(string.format("car%d",carid)))
|
local carinfo = minetest.deserialize(celevator.storage:get_string(string.format("car%d",carid)))
|
||||||
if not (carinfo and carinfo.machinepos) then return end
|
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 pos = vector.add(carinfo.machinepos,vector.multiply(dir,-1))
|
||||||
local erefs = celevator.drives.entity.sheaverefs[carid]
|
local erefs = celevator.drives.entity.sheaverefs[carid]
|
||||||
if erefs and erefs[1] then
|
if erefs and erefs[1] then
|
||||||
@ -872,10 +872,10 @@ function celevator.drives.entity.updatecopformspec(drivepos)
|
|||||||
end
|
end
|
||||||
local apos = tonumber(drivemeta:get_string("apos")) or 0
|
local apos = tonumber(drivemeta:get_string("apos")) or 0
|
||||||
local carpos = vector.add(origin,vector.new(0,apos,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
|
for hash in pairs(carnodes) do
|
||||||
local piecepos = minetest.get_position_from_hash(hash)
|
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
|
if piece.name == "celevator:car_010" then
|
||||||
minetest.get_meta(piecepos):set_string("formspec",copformspec)
|
minetest.get_meta(piecepos):set_string("formspec",copformspec)
|
||||||
elseif piece.name == "celevator:car_000" then
|
elseif piece.name == "celevator:car_000" then
|
||||||
|
@ -94,7 +94,7 @@ function celevator.drives.null.step(dtime)
|
|||||||
for i,hash in ipairs(nulldrives_running) do
|
for i,hash in ipairs(nulldrives_running) do
|
||||||
save = true
|
save = true
|
||||||
local pos = minetest.get_position_from_hash(hash)
|
local pos = minetest.get_position_from_hash(hash)
|
||||||
local node = minetest.get_node(pos)
|
local node = celevator.get_node(pos)
|
||||||
local sound = false
|
local sound = false
|
||||||
if node.name == "ignore" then
|
if node.name == "ignore" then
|
||||||
minetest.forceload_block(pos,true)
|
minetest.forceload_block(pos,true)
|
||||||
|
@ -2,3 +2,10 @@ celevator = {
|
|||||||
drives = {},
|
drives = {},
|
||||||
storage = minetest.get_mod_storage(),
|
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
|
||||||
|
@ -70,7 +70,7 @@ function celevator.fs1switch.setled(pos,on)
|
|||||||
["celevator:fs1switch_off"] = "celevator:fs1switch_off_lit",
|
["celevator:fs1switch_off"] = "celevator:fs1switch_off_lit",
|
||||||
["celevator:fs1switch_reset"] = "celevator:fs1switch_reset_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
|
if on and onstates[node.name] then
|
||||||
node.name = onstates[node.name]
|
node.name = onstates[node.name]
|
||||||
minetest.swap_node(pos,node)
|
minetest.swap_node(pos,node)
|
||||||
|
@ -75,13 +75,13 @@ function celevator.pi.updatedisplay(pos)
|
|||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local text = meta:get_string("text")
|
local text = meta:get_string("text")
|
||||||
local entity = minetest.add_entity(pos,"celevator:pi_entity")
|
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 uparrow = meta:get_int("uparrow") > 0
|
||||||
local downarrow = meta:get_int("downarrow") > 0
|
local downarrow = meta:get_int("downarrow") > 0
|
||||||
local flash_fs = meta:get_int("flash_fs") > 0
|
local flash_fs = meta:get_int("flash_fs") > 0
|
||||||
local flash_is = meta:get_int("flash_is") > 0
|
local flash_is = meta:get_int("flash_is") > 0
|
||||||
local flashtimer = meta:get_int("flashtimer") > 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)
|
local etex = celevator.pi.generatetexture(text,uparrow,downarrow,islantern)
|
||||||
if flash_fs then
|
if flash_fs then
|
||||||
if flashtimer then etex = celevator.pi.generatetexture(" FS",uparrow,downarrow,islantern) end
|
if flashtimer then etex = celevator.pi.generatetexture(" FS",uparrow,downarrow,islantern) end
|
||||||
@ -98,7 +98,7 @@ function celevator.pi.updatedisplay(pos)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function celevator.pi.flash(pos,what)
|
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)
|
local meta = minetest.get_meta(pos)
|
||||||
if what == "FS" then
|
if what == "FS" then
|
||||||
meta:set_int("flash_is",0)
|
meta:set_int("flash_is",0)
|
||||||
@ -114,7 +114,7 @@ function celevator.pi.flash(pos,what)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function celevator.pi.settext(pos,text)
|
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)
|
local meta = minetest.get_meta(pos)
|
||||||
if string.len(text) < 3 then
|
if string.len(text) < 3 then
|
||||||
text = string.rep(" ",3-string.len(text))..text
|
text = string.rep(" ",3-string.len(text))..text
|
||||||
@ -124,7 +124,7 @@ function celevator.pi.settext(pos,text)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function celevator.pi.setarrow(pos,which,active)
|
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)
|
local meta = minetest.get_meta(pos)
|
||||||
if which == "up" then
|
if which == "up" then
|
||||||
meta:set_int("uparrow",active and 1 or 0)
|
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)
|
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 minetest.get_item_group(node.name,"_celevator_lantern") ~= 1 then return end
|
||||||
if dir == "up" then
|
if dir == "up" then
|
||||||
if minetest.get_item_group(node.name,"_celevator_lantern_has_up") ~= 1 then return end
|
if minetest.get_item_group(node.name,"_celevator_lantern_has_up") ~= 1 then return end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user