mirror of
https://github.com/minetest-mods/towercrane.git
synced 2024-11-26 09:13:53 +01:00
hook instance and sound switch off bug fixes
This commit is contained in:
parent
dfd91b0c90
commit
95cce060ed
46
init.lua
46
init.lua
@ -3,7 +3,7 @@
|
|||||||
Tower Crane Mod
|
Tower Crane Mod
|
||||||
===============
|
===============
|
||||||
|
|
||||||
v0.09 by JoSt
|
v0.10 by JoSt
|
||||||
|
|
||||||
Copyright (C) 2017 Joachim Stolberg
|
Copyright (C) 2017 Joachim Stolberg
|
||||||
LGPLv2.1+
|
LGPLv2.1+
|
||||||
@ -19,6 +19,7 @@
|
|||||||
2017-07-16 v0.07 crane remove bug fix
|
2017-07-16 v0.07 crane remove bug fix
|
||||||
2017-07-16 v0.08 player times out bugfix
|
2017-07-16 v0.08 player times out bugfix
|
||||||
2017-08-19 v0.09 crane protection area to prevent crane clusters
|
2017-08-19 v0.09 crane protection area to prevent crane clusters
|
||||||
|
2017-08-27 v0.10 hook instance and sound switch off bug fixes
|
||||||
|
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
@ -26,6 +27,7 @@
|
|||||||
MIN_SIZE = 8
|
MIN_SIZE = 8
|
||||||
|
|
||||||
towercrane = {}
|
towercrane = {}
|
||||||
|
towercrane.hook = {}
|
||||||
|
|
||||||
dofile(minetest.get_modpath("towercrane") .. "/config.lua")
|
dofile(minetest.get_modpath("towercrane") .. "/config.lua")
|
||||||
|
|
||||||
@ -323,7 +325,7 @@ local function remove_crane(pos, dir, height, width)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
crane_body_plan(pos, dir, height, width, remove, {})
|
crane_body_plan(table.copy(pos), dir, height, width, remove, {})
|
||||||
end
|
end
|
||||||
|
|
||||||
----------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------
|
||||||
@ -336,6 +338,26 @@ local function place_hook(pos, dir)
|
|||||||
return minetest.add_entity(pos, "towercrane:hook")
|
return minetest.add_entity(pos, "towercrane:hook")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
----------------------------------------------------------------------------------------------------
|
||||||
|
-- Remove hook, reset player and stop sound
|
||||||
|
----------------------------------------------------------------------------------------------------
|
||||||
|
local function remove_hook(player, pos, y_offs)
|
||||||
|
-- determine hook_key
|
||||||
|
pos = table.copy(pos)
|
||||||
|
pos.y = pos.y + y_offs
|
||||||
|
local key = minetest.hash_node_position(pos)
|
||||||
|
default.player_set_animation(player, "stand" , 10)
|
||||||
|
local hook = towercrane.hook[key]
|
||||||
|
if hook then
|
||||||
|
-- remove hook
|
||||||
|
hook:remove()
|
||||||
|
if hook:get_luaentity().sound ~= nil then
|
||||||
|
-- stop sound
|
||||||
|
minetest.sound_stop(hook:get_luaentity().sound)
|
||||||
|
end
|
||||||
|
towercrane.hook[key] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
----------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------
|
||||||
-- Check if the given construction area is not already protected
|
-- Check if the given construction area is not already protected
|
||||||
@ -343,7 +365,6 @@ end
|
|||||||
local function check_area(pos1, pos2, owner)
|
local function check_area(pos1, pos2, owner)
|
||||||
if not areas then return true end
|
if not areas then return true end
|
||||||
for id, a in ipairs(areas:getAreasIntersectingArea(pos1, pos2)) do
|
for id, a in ipairs(areas:getAreasIntersectingArea(pos1, pos2)) do
|
||||||
print(dump(a.owner))
|
|
||||||
if a.owner ~= owner then
|
if a.owner ~= owner then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -471,6 +492,7 @@ minetest.register_node("towercrane:base", {
|
|||||||
remove_crane_data(pos)
|
remove_crane_data(pos)
|
||||||
remove_area(id, owner)
|
remove_area(id, owner)
|
||||||
remove_crane(table.copy(pos), dir, height, width)
|
remove_crane(table.copy(pos), dir, height, width)
|
||||||
|
remove_hook(player, pos, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- evaluate user input
|
-- evaluate user input
|
||||||
@ -519,11 +541,8 @@ minetest.register_node("towercrane:base", {
|
|||||||
remove_crane(pos, dir, height, width)
|
remove_crane(pos, dir, height, width)
|
||||||
end
|
end
|
||||||
-- remove hook
|
-- remove hook
|
||||||
id = minetest.hash_node_position(pos)
|
local player = minetest.get_player_by_name(owner)
|
||||||
if towercrane.id then
|
remove_hook(player, pos, 1)
|
||||||
towercrane.id:remove()
|
|
||||||
towercrane.id = nil
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -591,10 +610,7 @@ minetest.register_node("towercrane:mast_ctrl_on", {
|
|||||||
minetest.swap_node(pos, node)
|
minetest.swap_node(pos, node)
|
||||||
|
|
||||||
local id = minetest.hash_node_position(pos)
|
local id = minetest.hash_node_position(pos)
|
||||||
if towercrane.id then
|
remove_hook(clicker, pos, 0)
|
||||||
towercrane.id:remove()
|
|
||||||
towercrane.id = nil
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
@ -645,7 +661,7 @@ minetest.register_node("towercrane:mast_ctrl_off", {
|
|||||||
if pos ~= nil and dir ~= nil then
|
if pos ~= nil and dir ~= nil then
|
||||||
-- store hook instance in 'towercrane'
|
-- store hook instance in 'towercrane'
|
||||||
local id = minetest.hash_node_position(pos)
|
local id = minetest.hash_node_position(pos)
|
||||||
towercrane.id = place_hook(table.copy(pos), dir)
|
towercrane.hook[id] = place_hook(table.copy(pos), dir)
|
||||||
|
|
||||||
--
|
--
|
||||||
-- calculate the construction area dimension (pos1, pos2)
|
-- calculate the construction area dimension (pos1, pos2)
|
||||||
@ -675,8 +691,8 @@ minetest.register_node("towercrane:mast_ctrl_off", {
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- store pos1/pos2 in the hook (LuaEntitySAO)
|
-- store pos1/pos2 in the hook (LuaEntitySAO)
|
||||||
towercrane.id:get_luaentity().pos1 = pos1
|
towercrane.hook[id]:get_luaentity().pos1 = pos1
|
||||||
towercrane.id:get_luaentity().pos2 = pos2
|
towercrane.hook[id]:get_luaentity().pos2 = pos2
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user