Compare commits
10 Commits
e66f262888
...
c2d82a615f
Author | SHA1 | Date | |
---|---|---|---|
|
c2d82a615f | ||
|
b7bed50ac7 | ||
|
af87d6278c | ||
|
c0cd005c4b | ||
|
d5ae08f8d1 | ||
|
00b14a2c37 | ||
|
e208ad199c | ||
|
0e90cf0a4d | ||
|
3975b970ee | ||
|
599b2c93c6 |
11
README.md
11
README.md
@ -13,14 +13,14 @@ The size of the crane (which is the construction area) and the rope length can b
|
|||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
* Place the crane base block.
|
* Place the crane base block.
|
||||||
The crane arm will later be build in the same direction you are currently looking
|
The crane arm will later be built in the same direction the player is looking.
|
||||||
|
|
||||||
* Right-click the crane base block and set the crane dimensions in height and width (between 8 and 32 by default).
|
* Right-click the crane base block and set the crane dimensions in height and width (between 8 and 32 by default).
|
||||||
The crane will be build according to this settings.
|
The crane will be built according to these settings.
|
||||||
If there is not enough free space for the crane mast/arm or the potential construction area of the
|
If there is not enough free space for the crane mast/arm or the potential construction area of the
|
||||||
crane intersects a protected area from another player, the crane will not be build.
|
crane intersects a protected area from another player, the crane will not be built.
|
||||||
|
|
||||||
* Right-click the crane switch block to start the crane (get fly privs). The player will be placed in front of the crane.
|
* Right-click the crane switch block to start the crane (get fly privs). The player is placed in front of the crane.
|
||||||
|
|
||||||
* To remove the crane, destroy the base block.
|
* To remove the crane, destroy the base block.
|
||||||
|
|
||||||
@ -33,8 +33,9 @@ default
|
|||||||
# License
|
# License
|
||||||
Copyright (C) 2017-2020 Joachim Stolberg
|
Copyright (C) 2017-2020 Joachim Stolberg
|
||||||
Code: Licensed under the GNU LGPL version 2.1 or later. See LICENSE.txt and http://www.gnu.org/licenses/lgpl-2.1.txt
|
Code: Licensed under the GNU LGPL version 2.1 or later. See LICENSE.txt and http://www.gnu.org/licenses/lgpl-2.1.txt
|
||||||
Textures: CC0 (by Ammoth)
|
Textures: Mostly CC0 (by Ammoth)
|
||||||
|
|
||||||
|
* `morelights_extras_blocklight.png`: CC BY-SA 4.0 (by random-geek)
|
||||||
|
|
||||||
# History:
|
# History:
|
||||||
* 2017-06-04 v0.01 first version
|
* 2017-06-04 v0.01 first version
|
||||||
|
@ -11,13 +11,13 @@
|
|||||||
|
|
||||||
|
|
||||||
-- Maximum crane height in blocks (8..n)
|
-- Maximum crane height in blocks (8..n)
|
||||||
towercrane.max_height = tonumber(minetest.setting_get("towercrane_max_height")) or 32
|
towercrane.max_height = tonumber(minetest.settings:get("towercrane_max_height")) or 32
|
||||||
|
|
||||||
-- Maximum crane width in blocks (8..n)
|
-- Maximum crane width in blocks (8..n)
|
||||||
towercrane.max_width = tonumber(minetest.setting_get("towercrane_max_width")) or 32
|
towercrane.max_width = tonumber(minetest.settings:get("towercrane_max_width")) or 32
|
||||||
|
|
||||||
-- Crane rope lenght in block (max_height .. max_height+x)
|
-- Crane rope lenght in block (max_height .. max_height+x)
|
||||||
towercrane.rope_length = tonumber(minetest.setting_get("towercrane_rope_length")) or 40
|
towercrane.rope_length = tonumber(minetest.settings:get("towercrane_rope_length")) or 40
|
||||||
|
|
||||||
-- Recipe available (true/false)
|
-- Recipe available (true/false)
|
||||||
towercrane.recipe = tonumber(minetest.setting_get("towercrane_recipe")) or true
|
towercrane.recipe = tonumber(minetest.settings:get("towercrane_recipe")) or true
|
||||||
|
54
control.lua
54
control.lua
@ -10,6 +10,7 @@
|
|||||||
]]--
|
]]--
|
||||||
|
|
||||||
local DAYS_WITHOUT_USE = 72 * 5
|
local DAYS_WITHOUT_USE = 72 * 5
|
||||||
|
local mod_player_monoids = minetest.get_modpath("player_monoids")
|
||||||
|
|
||||||
-- for lazy programmers
|
-- for lazy programmers
|
||||||
local P2S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
local P2S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||||
@ -69,25 +70,30 @@ end
|
|||||||
|
|
||||||
local function set_operator_privs(player, pos)
|
local function set_operator_privs(player, pos)
|
||||||
local privs = minetest.get_player_privs(player:get_player_name())
|
local privs = minetest.get_player_privs(player:get_player_name())
|
||||||
local physics = player:get_physics_override()
|
|
||||||
local meta = player:get_meta()
|
local meta = player:get_meta()
|
||||||
-- Check access conflicts with other mods
|
-- Check access conflicts with other mods
|
||||||
if meta:get_int("player_physics_locked") == 0 then
|
if meta:get_int("player_physics_locked") == 0 then
|
||||||
if pos and meta and privs and physics then
|
if pos and meta and privs then
|
||||||
meta:set_string("towercrane_pos", P2S(pos))
|
meta:set_string("towercrane_pos", P2S(pos))
|
||||||
-- store the player privs default values
|
-- store the player privs default values
|
||||||
meta:set_string("towercrane_fast", privs["fast"] and "true" or "false")
|
meta:set_string("towercrane_fast", privs["fast"] and "true" or "false")
|
||||||
meta:set_string("towercrane_fly", privs["fly"] and "true" or "false")
|
meta:set_string("towercrane_fly", privs["fly"] and "true" or "false")
|
||||||
meta:set_int("towercrane_speed", physics.speed)
|
|
||||||
-- set operator privs
|
-- set operator privs
|
||||||
meta:set_int("towercrane_isoperator", 1)
|
meta:set_int("towercrane_isoperator", 1)
|
||||||
meta:set_int("player_physics_locked", 1)
|
meta:set_int("player_physics_locked", 1)
|
||||||
privs["fly"] = true
|
privs["fly"] = true
|
||||||
privs["fast"] = nil
|
privs["fast"] = nil
|
||||||
physics.speed = 0.7
|
|
||||||
-- write back
|
|
||||||
player:set_physics_override(physics)
|
|
||||||
minetest.set_player_privs(player:get_player_name(), privs)
|
minetest.set_player_privs(player:get_player_name(), privs)
|
||||||
|
|
||||||
|
if mod_player_monoids then
|
||||||
|
player_monoids.speed:add_change(player, 0.7, "towercrane:crane")
|
||||||
|
else
|
||||||
|
local physics = player:get_physics_override()
|
||||||
|
meta:set_int("towercrane_speed", physics.speed)
|
||||||
|
physics.speed = 0.7
|
||||||
|
-- write back
|
||||||
|
player:set_physics_override(physics)
|
||||||
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -96,24 +102,29 @@ end
|
|||||||
|
|
||||||
local function reset_operator_privs(player)
|
local function reset_operator_privs(player)
|
||||||
local privs = minetest.get_player_privs(player:get_player_name())
|
local privs = minetest.get_player_privs(player:get_player_name())
|
||||||
local physics = player:get_physics_override()
|
|
||||||
local meta = player:get_meta()
|
local meta = player:get_meta()
|
||||||
if meta and privs and physics then
|
if meta and privs and meta:get_int("towercrane_isoperator") ~= 0 then
|
||||||
meta:set_string("towercrane_pos", "")
|
meta:set_string("towercrane_pos", "")
|
||||||
-- restore the player privs default values
|
-- restore the player privs default values
|
||||||
meta:set_int("towercrane_isoperator", 0)
|
meta:set_int("towercrane_isoperator", 0)
|
||||||
meta:set_int("player_physics_locked", 0)
|
meta:set_int("player_physics_locked", 0)
|
||||||
privs["fast"] = meta:get_string("towercrane_fast") == "true" or nil
|
privs["fast"] = meta:get_string("towercrane_fast") == "true" or nil
|
||||||
privs["fly"] = meta:get_string("towercrane_fly") == "true" or nil
|
privs["fly"] = meta:get_string("towercrane_fly") == "true" or nil
|
||||||
physics.speed = meta:get_int("towercrane_speed")
|
minetest.set_player_privs(player:get_player_name(), privs)
|
||||||
if physics.speed == 0 then physics.speed = 1 end
|
|
||||||
-- delete stored default values
|
-- delete stored default values
|
||||||
meta:set_string("towercrane_fast", "")
|
meta:set_string("towercrane_fast", "")
|
||||||
meta:set_string("towercrane_fly", "")
|
meta:set_string("towercrane_fly", "")
|
||||||
meta:set_string("towercrane_speed", "")
|
|
||||||
-- write back
|
if mod_player_monoids then
|
||||||
player:set_physics_override(physics)
|
player_monoids.speed:del_change(player, "towercrane:crane")
|
||||||
minetest.set_player_privs(player:get_player_name(), privs)
|
else
|
||||||
|
local physics = player:get_physics_override()
|
||||||
|
physics.speed = meta:get_int("towercrane_speed")
|
||||||
|
meta:set_string("towercrane_speed", "")
|
||||||
|
if physics.speed == 0 then physics.speed = 1 end
|
||||||
|
-- write back
|
||||||
|
player:set_physics_override(physics)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -259,6 +270,7 @@ minetest.register_node("towercrane:mast_ctrl_on", {
|
|||||||
meta:set_string("infotext", S("Switch crane on/off"))
|
meta:set_string("infotext", S("Switch crane on/off"))
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
drop = "",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
light_source = 3,
|
light_source = 3,
|
||||||
@ -284,8 +296,14 @@ minetest.register_node("towercrane:mast_ctrl_off", {
|
|||||||
if set_operator_privs(clicker, pos) then
|
if set_operator_privs(clicker, pos) then
|
||||||
start_crane(pos, clicker)
|
start_crane(pos, clicker)
|
||||||
local pos1, pos2 = calc_construction_area(pos)
|
local pos1, pos2 = calc_construction_area(pos)
|
||||||
-- control player every second
|
if pos1 and pos2 then
|
||||||
minetest.after(1, control_player, pos, pos1, pos2, clicker:get_player_name())
|
-- control player every second
|
||||||
|
minetest.after(1, control_player, pos, pos1, pos2, clicker:get_player_name())
|
||||||
|
else
|
||||||
|
-- Something weird happened, restore privileges
|
||||||
|
stop_crane(pos, clicker)
|
||||||
|
reset_operator_privs(clicker)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@ -296,6 +314,7 @@ minetest.register_node("towercrane:mast_ctrl_off", {
|
|||||||
meta:set_string("infotext", S("Switch crane on/off"))
|
meta:set_string("infotext", S("Switch crane on/off"))
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
drop = "",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
@ -306,9 +325,10 @@ minetest.register_node("towercrane:mast_ctrl_off", {
|
|||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
local pos = get_my_crane_pos(player)
|
local pos = get_my_crane_pos(player)
|
||||||
if pos then
|
if pos then
|
||||||
reset_operator_privs(player)
|
|
||||||
stop_crane(pos, player)
|
stop_crane(pos, player)
|
||||||
end
|
end
|
||||||
|
-- To recover from a crash, this must be done unconditionally
|
||||||
|
reset_operator_privs(player)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_leaveplayer(function(player)
|
minetest.register_on_leaveplayer(function(player)
|
||||||
|
22
init.lua
22
init.lua
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
|
|
||||||
Nodes Meta data
|
Nodes Meta data
|
||||||
+--------+
|
+--------+
|
||||||
| | - last_known_pos as "(x,y,z)"
|
| | - last_known_pos as "(x,y,z)"
|
||||||
| switch | - last_used
|
| switch | - last_used
|
||||||
| | - running
|
| | - running
|
||||||
@ -26,7 +26,7 @@ local P2S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
|||||||
local S2P = minetest.string_to_pos
|
local S2P = minetest.string_to_pos
|
||||||
|
|
||||||
-- crane minimum size
|
-- crane minimum size
|
||||||
local MIN_SIZE = 8
|
local MIN_SIZE = 8
|
||||||
|
|
||||||
towercrane = {}
|
towercrane = {}
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ local function formspec(height, width)
|
|||||||
return "size[5,4]"..
|
return "size[5,4]"..
|
||||||
"label[0,0;"..S("Construction area size").."]" ..
|
"label[0,0;"..S("Construction area size").."]" ..
|
||||||
"field[1,1.5;3,1;size;height,width;"..text.."]" ..
|
"field[1,1.5;3,1;size;height,width;"..text.."]" ..
|
||||||
"button_exit[1,2;2,1;exit;"..S("Build").."]"
|
"button_exit[1,2;2,1;exit;"..S("Build").."]"
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_node_lvm(pos)
|
local function get_node_lvm(pos)
|
||||||
@ -154,7 +154,7 @@ end
|
|||||||
local function construct_crane(pos, dir, height, width)
|
local function construct_crane(pos, dir, height, width)
|
||||||
local add = function(pos, node_name, tArg)
|
local add = function(pos, node_name, tArg)
|
||||||
minetest.add_node(pos, {
|
minetest.add_node(pos, {
|
||||||
name = node_name,
|
name = node_name,
|
||||||
param2 = minetest.dir_to_facedir(tArg.dir)})
|
param2 = minetest.dir_to_facedir(tArg.dir)})
|
||||||
end
|
end
|
||||||
local tArg = {dir = dir}
|
local tArg = {dir = dir}
|
||||||
@ -229,7 +229,7 @@ local function build_crane_up(pos, owner, height, width)
|
|||||||
", "..S("Crane size")..": "..height..","..width)
|
", "..S("Crane size")..": "..height..","..width)
|
||||||
meta:set_string("formspec", formspec(height, width))
|
meta:set_string("formspec", formspec(height, width))
|
||||||
else
|
else
|
||||||
chat(owner, S("Area is protected or too less space for the crane!"))
|
chat(owner, S("Area is protected or not enough space for the crane!"))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -292,7 +292,7 @@ minetest.register_node("towercrane:base", {
|
|||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
|
|
||||||
-- evaluate user input (height, width),
|
-- evaluate user input (height, width),
|
||||||
-- destroy old crane and build a new one with
|
-- destroy old crane and build a new one with
|
||||||
-- the given size
|
-- the given size
|
||||||
on_receive_fields = function(pos, formname, fields, player)
|
on_receive_fields = function(pos, formname, fields, player)
|
||||||
@ -324,7 +324,7 @@ minetest.register_node("towercrane:base", {
|
|||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_destruct = function(pos)
|
on_destruct = function(pos)
|
||||||
towercrane.get_crane_down(pos)
|
towercrane.get_crane_down(pos)
|
||||||
end,
|
end,
|
||||||
@ -333,13 +333,15 @@ minetest.register_node("towercrane:base", {
|
|||||||
minetest.register_node("towercrane:balance", {
|
minetest.register_node("towercrane:balance", {
|
||||||
description = S("Tower Crane Balance"),
|
description = S("Tower Crane Balance"),
|
||||||
tiles = {
|
tiles = {
|
||||||
"towercrane_base.png^towercrane_screws.png",
|
"towercrane_base.png^towercrane_screws.png^morelights_extras_blocklight.png",
|
||||||
},
|
},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
|
light_source = 12,
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
groups = {crumbly=0, not_in_creative_inventory=1},
|
groups = {crumbly=0, not_in_creative_inventory=1},
|
||||||
|
drop = "",
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("towercrane:mast", {
|
minetest.register_node("towercrane:mast", {
|
||||||
@ -357,6 +359,7 @@ minetest.register_node("towercrane:mast", {
|
|||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
groups = {crumbly=0, not_in_creative_inventory=1},
|
groups = {crumbly=0, not_in_creative_inventory=1},
|
||||||
|
drop = "",
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("towercrane:arm", {
|
minetest.register_node("towercrane:arm", {
|
||||||
@ -374,6 +377,7 @@ minetest.register_node("towercrane:arm", {
|
|||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
groups = {crumbly=0, not_in_creative_inventory=1},
|
groups = {crumbly=0, not_in_creative_inventory=1},
|
||||||
|
drop = "",
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("towercrane:arm2", {
|
minetest.register_node("towercrane:arm2", {
|
||||||
@ -391,6 +395,7 @@ minetest.register_node("towercrane:arm2", {
|
|||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
groups = {crumbly=0, not_in_creative_inventory=1},
|
groups = {crumbly=0, not_in_creative_inventory=1},
|
||||||
|
drop = "",
|
||||||
})
|
})
|
||||||
|
|
||||||
if towercrane.recipe then
|
if towercrane.recipe then
|
||||||
@ -411,4 +416,3 @@ towercrane.turnright = turnright
|
|||||||
towercrane.turnleft = turnleft
|
towercrane.turnleft = turnleft
|
||||||
towercrane.is_my_crane = is_my_crane
|
towercrane.is_my_crane = is_my_crane
|
||||||
towercrane.get_crane_data = get_crane_data
|
towercrane.get_crane_data = get_crane_data
|
||||||
|
|
||||||
|
16
locale/template.txt
Normal file
16
locale/template.txt
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# textdomain: towercrane
|
||||||
|
Area is protected.=
|
||||||
|
Tower Crane Mast Ctrl On=
|
||||||
|
Switch crane on/off=
|
||||||
|
Tower Crane Mast Ctrl Off=
|
||||||
|
Construction area size=
|
||||||
|
Build=
|
||||||
|
Owner=
|
||||||
|
Crane size=
|
||||||
|
Area is protected or too less space for the crane!=
|
||||||
|
Invalid input!=
|
||||||
|
Tower Crane Base=
|
||||||
|
Tower Crane Balance=
|
||||||
|
Tower Crane Mast=
|
||||||
|
Tower Crane Arm=
|
||||||
|
Tower Crane Arm2=
|
16
locale/towercrane.eo.tr
Normal file
16
locale/towercrane.eo.tr
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# textdomain: towercrane
|
||||||
|
Area is protected.=Areo estas protektita.
|
||||||
|
Tower Crane Mast Ctrl On=Turgruomasta Kontrolo Enŝaltita
|
||||||
|
Switch crane on/off=Ŝaltu/malŝaltu gruon
|
||||||
|
Tower Crane Mast Ctrl Off=Turgruomasta Kontrolo Malŝaltita
|
||||||
|
Construction area size=Konstrua area grandeco
|
||||||
|
Build=Konstruita
|
||||||
|
Owner=Posedanto
|
||||||
|
Crane size=Gruo grandeco
|
||||||
|
Area is protected or not enough space for the crane!=Areo estas protektita aŭ ne sufice da spaco por la gruo!
|
||||||
|
Invalid input!=Nevalida enigo!
|
||||||
|
Tower Crane Base=Bazo de Turgruo
|
||||||
|
Tower Crane Balance=Ekvilibro de Turgruo
|
||||||
|
Tower Crane Mast=Masto de Turgruo
|
||||||
|
Tower Crane Arm=Brako de Turgruo
|
||||||
|
Tower Crane Arm2=Brako2 de Turgruo
|
1
mod.conf
1
mod.conf
@ -1,3 +1,4 @@
|
|||||||
name = towercrane
|
name = towercrane
|
||||||
depends = default
|
depends = default
|
||||||
|
optional_depends = player_monoids
|
||||||
description = A crane for easier construction of buildings. The crane forms a working area in which the player gets fly privs.
|
description = A crane for easier construction of buildings. The crane forms a working area in which the player gets fly privs.
|
BIN
textures/morelights_extras_blocklight.png
Normal file
BIN
textures/morelights_extras_blocklight.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 204 B |
Loading…
x
Reference in New Issue
Block a user