summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--car.lua23
-rw-r--r--controllerfw.lua16
-rw-r--r--drive_entity.lua4
3 files changed, 39 insertions, 4 deletions
diff --git a/car.lua b/car.lua
index a2b4a88..26d0fdc 100644
--- a/car.lua
+++ b/car.lua
@@ -56,6 +56,18 @@ local function updatecartopbox(pos)
entity:set_pos(toppos)
end
+local held = {}
+
+minetest.register_globalstep(function()
+ for k,v in ipairs(held) do
+ local player = minetest.get_player_by_name(v.name)
+ if not (player and player:get_player_control()[v.button]) then
+ table.remove(held,k)
+ celevator.controller.handlecartopbox(v.pos,v.control.."_release")
+ end
+ end
+end)
+
local pieces = {
{
_position = "000",
@@ -330,8 +342,13 @@ local pieces = {
"celevator_cabinet_sides.png",
},
on_rightclick = function(pos,node,clicker)
+ local name = clicker:get_player_name()
+ for _,v in ipairs(held) do
+ if name == v.name then return end
+ end
local fdir = minetest.fourdir_to_dir(node.param2)
local control = disambiguatebutton(pos,fdir,clicker)
+ if not control then return end
local meta = minetest.get_meta(pos)
local carid = meta:get_int("carid")
if carid == 0 then return end
@@ -353,6 +370,12 @@ local pieces = {
end
end
celevator.controller.handlecartopbox(carinfo.controllerpos,control)
+ table.insert(held,{
+ pos = carinfo.controllerpos,
+ name = name,
+ button = "place",
+ control = control,
+ })
end,
after_dig_node = function(pos)
local toppos = vector.add(pos,vector.new(0,1.1,0))
diff --git a/controllerfw.lua b/controllerfw.lua
index 398aff7..e0bdc22 100644
--- a/controllerfw.lua
+++ b/controllerfw.lua
@@ -668,7 +668,7 @@ elseif event.type == "cartopbox" then
})
drivecmd({
command = "moveto",
- pos = math.floor(mem.drive.status.apos)+1,
+ pos = gettarget(#mem.params.floornames),
inspection = true,
})
elseif event.control == "down" and mem.carstate == "carinspect" and mem.doorstate == "closed" and mem.drive.status.apos-1 >= 0 then
@@ -680,7 +680,19 @@ elseif event.type == "cartopbox" then
})
drivecmd({
command = "moveto",
- pos = math.floor(mem.drive.status.apos)-1,
+ pos = 0,
+ inspection = true,
+ })
+ elseif event.control == "up_release" and mem.carstate == "carinspect" and mem.drive.status.vel > 0 then
+ drivecmd({
+ command = "moveto",
+ pos = math.ceil(mem.drive.status.apos),
+ inspection = true,
+ })
+ elseif event.control == "down_release" and mem.carstate == "carinspect" and mem.drive.status.vel < 0 then
+ drivecmd({
+ command = "moveto",
+ pos = math.floor(mem.drive.status.apos),
inspection = true,
})
end
diff --git a/drive_entity.lua b/drive_entity.lua
index f26bf11..ecbabdf 100644
--- a/drive_entity.lua
+++ b/drive_entity.lua
@@ -541,9 +541,9 @@ function celevator.drives.entity.moveto(pos,target,inspection)
local apos = tonumber(meta:get_string("apos"))
local vel = tonumber(meta:get_string("vel"))
if vel > 0 then
- if target < apos+(vel*2) then return end
+ if target < apos+(vel*2) and not inspection then return end
elseif vel < 0 then
- if target > apos-(vel*-2) then return end
+ if target > apos-(vel*-2) and not inspection then return end
else
return
end