summaryrefslogtreecommitdiff
path: root/drive_null.lua
diff options
context:
space:
mode:
Diffstat (limited to 'drive_null.lua')
-rw-r--r--drive_null.lua66
1 files changed, 33 insertions, 33 deletions
diff --git a/drive_null.lua b/drive_null.lua
index 2664d47..e0607b6 100644
--- a/drive_null.lua
+++ b/drive_null.lua
@@ -7,7 +7,7 @@ celevator.drives.null = {
}
local function update_ui(pos)
- local meta = minetest.get_meta(pos)
+ local meta = core.get_meta(pos)
local apos = tonumber(meta:get_string("apos")) or 0
local status = "Idle"
local vel = tonumber(meta:get_string("vel")) or 0
@@ -20,9 +20,9 @@ local function update_ui(pos)
end
local function playbuzz(pos)
- local hash = minetest.hash_node_position(pos)
+ local hash = core.hash_node_position(pos)
if celevator.drives.null.soundhandles[hash] == "cancel" then return end
- celevator.drives.null.soundhandles[hash] = minetest.sound_play("celevator_drive_run",{
+ celevator.drives.null.soundhandles[hash] = core.sound_play("celevator_drive_run",{
pos = pos,
loop = true,
gain = 0.4,
@@ -30,29 +30,29 @@ local function playbuzz(pos)
end
local function startbuzz(pos)
- local hash = minetest.hash_node_position(pos)
+ local hash = core.hash_node_position(pos)
if celevator.drives.null.soundhandles[hash] == "cancel" then
celevator.drives.null.soundhandles[hash] = nil
return
end
if celevator.drives.null.soundhandles[hash] then return end
celevator.drives.null.soundhandles[hash] = "pending"
- minetest.after(0.5,playbuzz,pos)
+ core.after(0.5,playbuzz,pos)
end
local function stopbuzz(pos)
- local hash = minetest.hash_node_position(pos)
+ local hash = core.hash_node_position(pos)
if not celevator.drives.null.soundhandles[hash] then return end
if celevator.drives.null.soundhandles[hash] == "pending" then
celevator.drives.null.soundhandles[hash] = "cancel"
end
if type(celevator.drives.null.soundhandles[hash]) ~= "string" then
- minetest.sound_stop(celevator.drives.null.soundhandles[hash])
+ core.sound_stop(celevator.drives.null.soundhandles[hash])
celevator.drives.null.soundhandles[hash] = nil
end
end
-minetest.register_node("celevator:drive_null",{
+core.register_node("celevator:drive_null",{
description = celevator.drives.null.name,
groups = {
cracky = 1,
@@ -79,7 +79,7 @@ minetest.register_node("celevator:drive_null",{
},
_celevator_drive_type = "null",
after_place_node = function(pos)
- local meta = minetest.get_meta(pos)
+ local meta = core.get_meta(pos)
meta:set_string("apos","0")
meta:set_string("dpos","0")
meta:set_string("vel","0")
@@ -92,19 +92,19 @@ minetest.register_node("celevator:drive_null",{
function celevator.drives.null.step(dtime)
if not celevator.drives.null.step_enabled then return end
- local nulldrives_running = minetest.deserialize(celevator.storage:get_string("nulldrives_running")) or {}
+ local nulldrives_running = core.deserialize(celevator.storage:get_string("nulldrives_running")) or {}
local save = false
for i,hash in ipairs(nulldrives_running) do
save = true
- local pos = minetest.get_position_from_hash(hash)
+ local pos = core.get_position_from_hash(hash)
local node = celevator.get_node(pos)
local sound = false
if node.name == "ignore" then
- minetest.forceload_block(pos,true)
+ core.forceload_block(pos,true)
elseif node.name ~= "celevator:drive_null" then
table.remove(nulldrives_running,i)
else
- local meta = minetest.get_meta(pos)
+ local meta = core.get_meta(pos)
local apos = tonumber(meta:get_string("apos")) or 0
local dpos = tonumber(meta:get_string("dpos")) or 0
local maxvel = tonumber(meta:get_string("maxvel")) or 0.2
@@ -146,18 +146,18 @@ function celevator.drives.null.step(dtime)
end
end
if save then
- celevator.storage:set_string("nulldrives_running",minetest.serialize(nulldrives_running))
+ celevator.storage:set_string("nulldrives_running",core.serialize(nulldrives_running))
end
celevator.drives.null.step_enabled = save
end
-minetest.register_globalstep(celevator.drives.null.step)
+core.register_globalstep(celevator.drives.null.step)
function celevator.drives.null.moveto(pos,target)
- local meta = minetest.get_meta(pos)
+ local meta = core.get_meta(pos)
meta:set_string("dpos",tostring(target))
- local hash = minetest.hash_node_position(pos)
- local nulldrives_running = minetest.deserialize(celevator.storage:get_string("nulldrives_running")) or {}
+ local hash = core.hash_node_position(pos)
+ local nulldrives_running = core.deserialize(celevator.storage:get_string("nulldrives_running")) or {}
local running = false
for _,dhash in ipairs(nulldrives_running) do
if hash == dhash then
@@ -168,7 +168,7 @@ function celevator.drives.null.moveto(pos,target)
if not running then
celevator.drives.null.step_enabled = true
table.insert(nulldrives_running,hash)
- celevator.storage:set_string("nulldrives_running",minetest.serialize(nulldrives_running))
+ celevator.storage:set_string("nulldrives_running",core.serialize(nulldrives_running))
end
end
@@ -177,13 +177,13 @@ function celevator.drives.null.resetpos(pos)
end
function celevator.drives.null.estop(pos)
- local meta = minetest.get_meta(pos)
+ local meta = core.get_meta(pos)
meta:set_string("dpos",meta:get_string("apos"))
meta:set_string("vel","0")
end
function celevator.drives.null.setmaxvel(pos,maxvel)
- local meta = minetest.get_meta(pos)
+ local meta = core.get_meta(pos)
meta:set_string("maxvel",tostring(maxvel))
end
@@ -192,35 +192,35 @@ function celevator.drives.null.rezero(pos)
end
function celevator.drives.null.movedoors(drivepos,direction)
- local drivehash = minetest.hash_node_position(drivepos)
- local nulldrives_running = minetest.deserialize(celevator.storage:get_string("nulldrives_running")) or {}
+ local drivehash = core.hash_node_position(drivepos)
+ local nulldrives_running = core.deserialize(celevator.storage:get_string("nulldrives_running")) or {}
for _,hash in pairs(nulldrives_running) do
if drivehash == hash then return end
end
- local drivemeta = minetest.get_meta(drivepos)
+ local drivemeta = core.get_meta(drivepos)
if direction == "open" then
drivemeta:set_string("doorstate","opening")
- minetest.after(math.pi+0.5,function()
- minetest.get_meta(drivepos):set_string("doorstate","open")
+ core.after(math.pi+0.5,function()
+ core.get_meta(drivepos):set_string("doorstate","open")
end)
elseif direction == "close" then
drivemeta:set_string("doorstate","closing")
- minetest.after((math.pi/0.66)+0.5,function()
- minetest.get_meta(drivepos):set_string("doorstate","closed")
+ core.after((math.pi/0.66)+0.5,function()
+ core.get_meta(drivepos):set_string("doorstate","closed")
end)
end
end
function celevator.drives.null.getstatus(pos,call2)
- local node = minetest.get_node(pos)
+ local node = core.get_node(pos)
if node.name == "ignore" and not call2 then
- minetest.forceload_block(pos,true)
+ core.forceload_block(pos,true)
return celevator.drives.null.get_status(pos,true)
elseif node.name ~= "celevator:drive_null" then
- minetest.log("error","[celevator] [null drive] Could not load drive status at "..minetest.pos_to_string(pos))
+ core.log("error","[celevator] [null drive] Could not load drive status at "..core.pos_to_string(pos))
return
else
- local meta = minetest.get_meta(pos)
+ local meta = core.get_meta(pos)
local ret = {}
ret.apos = tonumber(meta:get_string("apos")) or 0
ret.dpos = tonumber(meta:get_string("dpos")) or 0
@@ -236,7 +236,7 @@ function celevator.drives.null.resetfault(pos)
--This drive has no possible faults at this time
--(drive communication faults are generated by the controller),
--but the controller expects to be able to call this
- minetest.get_meta(pos):set_string("fault","")
+ core.get_meta(pos):set_string("fault","")
end
function celevator.drives.null.updatecopformspec()