aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/lua_api.txt7
-rw-r--r--src/client.cpp20
-rw-r--r--src/client.h7
-rw-r--r--src/clientserver.h6
-rw-r--r--src/game.cpp15
-rw-r--r--src/hud.cpp16
-rw-r--r--src/hud.h21
-rw-r--r--src/player.cpp36
-rw-r--r--src/scriptapi_object.cpp41
-rw-r--r--src/scriptapi_object.h4
-rw-r--r--src/server.cpp14
-rw-r--r--src/server.h5
12 files changed, 85 insertions, 107 deletions
diff --git a/doc/lua_api.txt b/doc/lua_api.txt
index 5b1942aef..07fb1ccd6 100644
--- a/doc/lua_api.txt
+++ b/doc/lua_api.txt
@@ -1434,9 +1434,10 @@ Player-only: (no-op for other objects)
- hud_change(id, stat, value): change a value of a previously added HUD element
^ element stat values: position, name, scale, text, number, item, dir
- hud_get(id): gets the HUD element definition structure of the specified ID
-- hud_builtin_enable(what, flag): enable or disable built-in HUD items
- ^ what: "hotbar", "healthbar", "crosshair", "wielditem"
- ^ flag: true/false
+- hud_set_flags(flags): sets specified HUD flags to true/false
+ ^ flags: (is visible) hotbar, healthbar, crosshair, wielditem
+ ^ pass a table containing a true/false value of each flag to be set or unset
+ ^ if a flag is nil, the flag is not modified
InvRef: Reference to an inventory
methods:
diff --git a/src/client.cpp b/src/client.cpp
index 941e9e882..56505c66c 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -2097,8 +2097,8 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
u32 id = readU32(is);
u8 stat = (HudElementStat)readU8(is);
- if (stat == HUD_STAT_POS || stat == HUD_STAT_SCALE
- || stat == HUD_STAT_ALIGN || stat == HUD_STAT_OFFSET)
+ if (stat == HUD_STAT_POS || stat == HUD_STAT_SCALE ||
+ stat == HUD_STAT_ALIGN || stat == HUD_STAT_OFFSET)
v2fdata = readV2F1000(is);
else if (stat == HUD_STAT_NAME || stat == HUD_STAT_TEXT)
sdata = deSerializeString(is);
@@ -2114,19 +2114,19 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
event.hudchange.data = intdata;
m_client_event_queue.push_back(event);
}
- else if(command == TOCLIENT_HUD_BUILTIN_ENABLE)
+ else if(command == TOCLIENT_HUD_SET_FLAGS)
{
std::string datastring((char *)&data[2], datasize - 2);
std::istringstream is(datastring, std::ios_base::binary);
- u32 id = readU8(is);
- bool flag = (readU8(is) ? true : false);
+ Player *player = m_env.getLocalPlayer();
+ assert(player != NULL);
- ClientEvent event;
- event.type = CE_HUD_BUILTIN_ENABLE;
- event.hudbuiltin.id = (HudBuiltinElement)id;
- event.hudbuiltin.flag = flag;
- m_client_event_queue.push_back(event);
+ u32 flags = readU32(is);
+ u32 mask = readU32(is);
+
+ player->hud_flags &= ~mask;
+ player->hud_flags |= flags;
}
else
{
diff --git a/src/client.h b/src/client.h
index 33872864e..67ba6c565 100644
--- a/src/client.h
+++ b/src/client.h
@@ -163,8 +163,7 @@ enum ClientEventType
CE_DELETE_PARTICLESPAWNER,
CE_HUDADD,
CE_HUDRM,
- CE_HUDCHANGE,
- CE_HUD_BUILTIN_ENABLE
+ CE_HUDCHANGE
};
struct ClientEvent
@@ -244,10 +243,6 @@ struct ClientEvent
std::string *sdata;
u32 data;
} hudchange;
- struct{
- u32 id;
- u32 flag;
- } hudbuiltin;
};
};
diff --git a/src/clientserver.h b/src/clientserver.h
index 114b04d13..cfa87ada7 100644
--- a/src/clientserver.h
+++ b/src/clientserver.h
@@ -474,11 +474,11 @@ enum ToClientCommand
u32 data]
*/
- TOCLIENT_HUD_BUILTIN_ENABLE = 0x4c,
+ TOCLIENT_HUD_SET_FLAGS = 0x4c,
/*
u16 command
- u8 id
- u8 flag
+ u32 flags
+ u32 mask
*/
};
diff --git a/src/game.cpp b/src/game.cpp
index e3251bf65..189003e4c 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -2186,14 +2186,6 @@ void the_game(
delete event.hudchange.v2fdata;
delete event.hudchange.sdata;
}
- else if (event.type == CE_HUD_BUILTIN_ENABLE) {
- u32 bit = (u32)event.hudbuiltin.id;
- u32 mask = 1 << bit;
- if (event.hudbuiltin.flag)
- player->hud_flags |= mask;
- else
- player->hud_flags &= ~mask;
- }
}
}
@@ -3078,7 +3070,7 @@ void the_game(
/*
Wielded tool
*/
- if(show_hud && (player->hud_flags & HUD_DRAW_WIELDITEM))
+ if(show_hud && (player->hud_flags & HUD_FLAG_WIELDITEM_VISIBLE))
{
// Warning: This clears the Z buffer.
camera.drawWieldedTool();
@@ -3102,7 +3094,7 @@ void the_game(
/*
Draw crosshair
*/
- if (show_hud && (player->hud_flags & HUD_DRAW_CROSSHAIR))
+ if (show_hud)
hud.drawCrosshair();
} // timer
@@ -3117,8 +3109,7 @@ void the_game(
if (show_hud)
{
hud.drawHotbar(v2s32(displaycenter.X, screensize.Y),
- client.getHP(), client.getPlayerItem(),
- player->hud_flags);
+ client.getHP(), client.getPlayerItem());
}
/*
diff --git a/src/hud.cpp b/src/hud.cpp
index 8daadad37..cf53354b2 100644
--- a/src/hud.cpp
+++ b/src/hud.cpp
@@ -277,7 +277,7 @@ void Hud::drawStatbar(v2s32 pos, u16 corner, u16 drawdir, std::string texture, s
}
-void Hud::drawHotbar(v2s32 centerlowerpos, s32 halfheartcount, u16 playeritem, u32 flags) {
+void Hud::drawHotbar(v2s32 centerlowerpos, s32 halfheartcount, u16 playeritem) {
InventoryList *mainlist = inventory->getList("main");
if (mainlist == NULL) {
errorstream << "draw_hotbar(): mainlist == NULL" << std::endl;
@@ -288,19 +288,21 @@ void Hud::drawHotbar(v2s32 centerlowerpos, s32 halfheartcount, u16 playeritem, u
s32 width = hotbar_itemcount * (hotbar_imagesize + padding * 2);
v2s32 pos = centerlowerpos - v2s32(width / 2, hotbar_imagesize + padding * 2);
- if (flags & HUD_DRAW_HOTBAR)
+ if (player->hud_flags & HUD_FLAG_HOTBAR_VISIBLE)
drawItem(pos, hotbar_imagesize, hotbar_itemcount, mainlist, playeritem + 1, 0);
- if (flags & HUD_DRAW_HEALTHBAR)
+ if (player->hud_flags & HUD_FLAG_HEALTHBAR_VISIBLE)
drawStatbar(pos - v2s32(0, 4), HUD_CORNER_LOWER, HUD_DIR_LEFT_RIGHT,
"heart.png", halfheartcount, v2s32(0, 0));
}
void Hud::drawCrosshair() {
- driver->draw2DLine(displaycenter - v2s32(10, 0),
- displaycenter + v2s32(10, 0), crosshair_argb);
- driver->draw2DLine(displaycenter - v2s32(0, 10),
- displaycenter + v2s32(0, 10), crosshair_argb);
+ if (player->hud_flags & HUD_FLAG_CROSSHAIR_VISIBLE) {
+ driver->draw2DLine(displaycenter - v2s32(10, 0),
+ displaycenter + v2s32(10, 0), crosshair_argb);
+ driver->draw2DLine(displaycenter - v2s32(0, 10),
+ displaycenter + v2s32(0, 10), crosshair_argb);
+ }
}
diff --git a/src/hud.h b/src/hud.h
index e0d7ccd6f..405e91176 100644
--- a/src/hud.h
+++ b/src/hud.h
@@ -31,10 +31,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define HUD_CORNER_LOWER 1
#define HUD_CORNER_CENTER 2
-#define HUD_DRAW_HOTBAR (1 << 0)
-#define HUD_DRAW_HEALTHBAR (1 << 1)
-#define HUD_DRAW_CROSSHAIR (1 << 2)
-#define HUD_DRAW_WIELDITEM (1 << 3)
+#define HUD_FLAG_HOTBAR_VISIBLE (1 << 0)
+#define HUD_FLAG_HEALTHBAR_VISIBLE (1 << 1)
+#define HUD_FLAG_CROSSHAIR_VISIBLE (1 << 2)
+#define HUD_FLAG_WIELDITEM_VISIBLE (1 << 3)
class Player;
@@ -71,14 +71,6 @@ struct HudElement {
};
-enum HudBuiltinElement {
- HUD_BUILTIN_HOTBAR = 0,
- HUD_BUILTIN_HEALTHBAR,
- HUD_BUILTIN_CROSSHAIR,
- HUD_BUILTIN_WIELDITEM
-};
-
-
inline u32 hud_get_free_id(Player *player) {
size_t size = player->hud.size();
for (size_t i = 0; i != size; i++) {
@@ -123,9 +115,10 @@ public:
void drawItem(v2s32 upperleftpos, s32 imgsize, s32 itemcount,
InventoryList *mainlist, u16 selectitem, u16 direction);
void drawLuaElements();
- void drawStatbar(v2s32 pos, u16 corner, u16 drawdir, std::string texture, s32 count, v2s32 offset);
+ void drawStatbar(v2s32 pos, u16 corner, u16 drawdir,
+ std::string texture, s32 count, v2s32 offset);
- void drawHotbar(v2s32 centerlowerpos, s32 halfheartcount, u16 playeritem, u32 flags);
+ void drawHotbar(v2s32 centerlowerpos, s32 halfheartcount, u16 playeritem);
void resizeHotbar();
void drawCrosshair();
diff --git a/src/player.cpp b/src/player.cpp
index d3e16810f..34f0fda08 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -54,35 +54,33 @@ Player::Player(IGameDef *gamedef):
inventory.addList("craftresult", 1);
// Can be redefined via Lua
- inventory_formspec = "size[8,7.5]"
+ inventory_formspec = "size[8,7.5]"
//"image[1,0.6;1,2;player.png]"
"list[current_player;main;0,3.5;8,4;]"
"list[current_player;craft;3,0;3,3;]"
"list[current_player;craftpreview;7,1;1,1;]";
// Initialize movement settings at default values, so movement can work if the server fails to send them
- movement_acceleration_default = 3 * BS;
- movement_acceleration_air = 2 * BS;
- movement_acceleration_fast = 10 * BS;
- movement_speed_walk = 4 * BS;
- movement_speed_crouch = 1.35 * BS;
- movement_speed_fast = 20 * BS;
- movement_speed_climb = 2 * BS;
- movement_speed_jump = 6.5 * BS;
- movement_liquid_fluidity = 1 * BS;
- movement_liquid_fluidity_smooth = 0.5 * BS;
- movement_liquid_sink = 10 * BS;
- movement_gravity = 9.81 * BS;
+ movement_acceleration_default = 3 * BS;
+ movement_acceleration_air = 2 * BS;
+ movement_acceleration_fast = 10 * BS;
+ movement_speed_walk = 4 * BS;
+ movement_speed_crouch = 1.35 * BS;
+ movement_speed_fast = 20 * BS;
+ movement_speed_climb = 2 * BS;
+ movement_speed_jump = 6.5 * BS;
+ movement_liquid_fluidity = 1 * BS;
+ movement_liquid_fluidity_smooth = 0.5 * BS;
+ movement_liquid_sink = 10 * BS;
+ movement_gravity = 9.81 * BS;
// Movement overrides are multipliers and must be 1 by default
- physics_override_speed = 1;
- physics_override_jump = 1;
+ physics_override_speed = 1;
+ physics_override_jump = 1;
physics_override_gravity = 1;
- hud_flags = HUD_DRAW_HOTBAR
- | HUD_DRAW_HEALTHBAR
- | HUD_DRAW_CROSSHAIR
- | HUD_DRAW_WIELDITEM;
+ hud_flags = HUD_FLAG_HOTBAR_VISIBLE | HUD_FLAG_HEALTHBAR_VISIBLE |
+ HUD_FLAG_CROSSHAIR_VISIBLE | HUD_FLAG_WIELDITEM_VISIBLE;
}
Player::~Player()
diff --git a/src/scriptapi_object.cpp b/src/scriptapi_object.cpp
index e2eec5104..4dfdeb8c8 100644
--- a/src/scriptapi_object.cpp
+++ b/src/scriptapi_object.cpp
@@ -54,10 +54,10 @@ struct EnumString es_HudElementStat[] =
struct EnumString es_HudBuiltinElement[] =
{
- {HUD_BUILTIN_HOTBAR, "hotbar"},
- {HUD_BUILTIN_HEALTHBAR, "healthbar"},
- {HUD_BUILTIN_CROSSHAIR, "crosshair"},
- {HUD_BUILTIN_WIELDITEM, "wielditem"},
+ {HUD_FLAG_HOTBAR_VISIBLE, "hotbar"},
+ {HUD_FLAG_HEALTHBAR_VISIBLE, "healthbar"},
+ {HUD_FLAG_CROSSHAIR_VISIBLE, "crosshair"},
+ {HUD_FLAG_WIELDITEM_VISIBLE, "wielditem"},
{0, NULL},
};
@@ -911,30 +911,29 @@ int ObjectRef::l_hud_get(lua_State *L)
return 1;
}
-// hud_builtin_enable(self, id, flag)
-int ObjectRef::l_hud_builtin_enable(lua_State *L)
+// hud_set_flags(self, flags)
+int ObjectRef::l_hud_set_flags(lua_State *L)
{
ObjectRef *ref = checkobject(L, 1);
Player *player = getplayer(ref);
if (player == NULL)
return 0;
- HudBuiltinElement id;
- int id_i;
+ u32 flags = 0;
+ u32 mask = 0;
+ bool flag;
- std::string s(lua_tostring(L, 2));
-
- // Return nil if component is not in enum
- if (!string_to_enum(es_HudBuiltinElement, id_i, s))
+ const EnumString *esp = es_HudBuiltinElement;
+ for (int i = 0; esp[i].str; i++) {
+ if (getboolfield(L, 2, esp[i].str, flag)) {
+ flags |= esp[i].num * flag;
+ mask |= esp[i].num;
+ }
+ }
+ if (!get_server(L)->hudSetFlags(player, flags, mask))
return 0;
-
- id = (HudBuiltinElement)id_i;
- bool flag = (bool)lua_toboolean(L, 3);
-
- bool ok = get_server(L)->hudBuiltinEnable(player, id, flag);
-
- lua_pushboolean(L, (int)ok);
+ lua_pushboolean(L, true);
return 1;
}
@@ -1048,9 +1047,7 @@ const luaL_reg ObjectRef::methods[] = {
luamethod(ObjectRef, hud_remove),
luamethod(ObjectRef, hud_change),
luamethod(ObjectRef, hud_get),
- luamethod(ObjectRef, hud_builtin_enable),
- //luamethod(ObjectRef, hud_lock_next_bar),
- //luamethod(ObjectRef, hud_unlock_bar),
+ luamethod(ObjectRef, hud_set_flags),
{0,0}
};
diff --git a/src/scriptapi_object.h b/src/scriptapi_object.h
index 81e8cda33..82535ee94 100644
--- a/src/scriptapi_object.h
+++ b/src/scriptapi_object.h
@@ -202,8 +202,8 @@ private:
// hud_get(self, id)
static int l_hud_get(lua_State *L);
- // hud_builtin_enable(self, id, flag)
- static int l_hud_builtin_enable(lua_State *L);
+ // hud_set_flags(self, flags)
+ static int l_hud_set_flags(lua_State *L);
public:
ObjectRef(ServerActiveObject *object);
diff --git a/src/server.cpp b/src/server.cpp
index a93d887e2..d5e505190 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -3675,18 +3675,18 @@ void Server::SendHUDChange(u16 peer_id, u32 id, HudElementStat stat, void *value
m_con.Send(peer_id, 0, data, true);
}
-void Server::SendHUDBuiltinEnable(u16 peer_id, u32 id, bool flag)
+void Server::SendHUDSetFlags(u16 peer_id, u32 flags, u32 mask)
{
std::ostringstream os(std::ios_base::binary);
// Write command
- writeU16(os, TOCLIENT_HUD_BUILTIN_ENABLE);
- writeU8(os, id);
- writeU8(os, (flag ? 1 : 0));
+ writeU16(os, TOCLIENT_HUD_SET_FLAGS);
+ writeU32(os, flags);
+ writeU32(os, mask);
// Make data buffer
std::string s = os.str();
- SharedBuffer<u8> data((u8*)s.c_str(), s.size());
+ SharedBuffer<u8> data((u8 *)s.c_str(), s.size());
// Send as reliable
m_con.Send(peer_id, 0, data, true);
}
@@ -4680,11 +4680,11 @@ bool Server::hudChange(Player *player, u32 id, HudElementStat stat, void *data)
return true;
}
-bool Server::hudBuiltinEnable(Player *player, u32 id, bool flag) {
+bool Server::hudSetFlags(Player *player, u32 flags, u32 mask) {
if (!player)
return false;
- SendHUDBuiltinEnable(player->peer_id, id, flag);
+ SendHUDSetFlags(player->peer_id, flags, mask);
return true;
}
diff --git a/src/server.h b/src/server.h
index b951ae53f..dcd007d23 100644
--- a/src/server.h
+++ b/src/server.h
@@ -540,7 +540,7 @@ public:
u32 hudAdd(Player *player, HudElement *element);
bool hudRemove(Player *player, u32 id);
bool hudChange(Player *player, u32 id, HudElementStat stat, void *value);
- bool hudBuiltinEnable(Player *player, u32 id, bool flag);
+ bool hudSetFlags(Player *player, u32 flags, u32 mask);
private:
@@ -584,7 +584,8 @@ private:
void SendHUDAdd(u16 peer_id, u32 id, HudElement *form);
void SendHUDRemove(u16 peer_id, u32 id);
void SendHUDChange(u16 peer_id, u32 id, HudElementStat stat, void *value);
- void SendHUDBuiltinEnable(u16 peer_id, u32 id, bool flag);
+ void SendHUDSetFlags(u16 peer_id, u32 flags, u32 mask);
+
/*
Send a node removal/addition event to all clients except ignore_id.
Additionally, if far_players!=NULL, players further away than
="hl opt">) return end -- set zs3 signal to show speed according to main_aspect setzs3(pos, main_aspect.zs3, rot) -- select appropriate lamps based on mainaspect and dst if main_aspect.shunt then advtrains.ndb.swap_node(pos, {name="advtrains_signals_ks:hs_shunt_"..rot, param2 = node.param2}) setzs3v(pos, nil, rot) else if not dst_aspect_info or not dst_aspect_info.main or dst_aspect_info.main == -1 then advtrains.ndb.swap_node(pos, {name="advtrains_signals_ks:hs_free_"..rot, param2 = node.param2}) setzs3v(pos, nil, rot) elseif dst_aspect_info.main == 0 then advtrains.ndb.swap_node(pos, {name="advtrains_signals_ks:hs_slow_"..rot, param2 = node.param2}) setzs3v(pos, nil, rot) else advtrains.ndb.swap_node(pos, {name="advtrains_signals_ks:hs_nextslow_"..rot, param2 = node.param2}) setzs3v(pos, dst_aspect_info.main, rot) end end end end -- Main aspects main signal -- These aspects tell only the speed signalization at this signal. -- Actual signal aspect is chosen based on this and the Dst signal. local mainaspects_main = { { name = "proceed", description = "Proceed", zs3 = "off" }, { name = "shunt", description = "Shunt", zs3 = "off", shunt = true, }, { name = "proceed_16", description = "Proceed (speed 16)", zs3 = "16", }, { name = "proceed_12", description = "Proceed (speed 12)", zs3 = "12", }, { name = "proceed_8", description = "Proceed (speed 8)", zs3 = "8", }, { name = "proceed_6", description = "Proceed (speed 6)", zs3 = "6", }, { name = "proceed_4", description = "Proceed (speed 4)", zs3 = "4", }, } local applyaspectf_distant = function(rot) return function(pos, node, main_aspect, dst_aspect, dst_aspect_info) if main_aspect.halt then -- halt aspect, set red and don't do anything further advtrains.ndb.swap_node(pos, {name="advtrains_signals_ks:vs_slow_"..rot, param2 = node.param2}) setzs3v(pos, nil, rot) return end -- select appropriate lamps based on mainaspect and dst if not dst_aspect_info or not dst_aspect_info.main or dst_aspect_info.main == -1 then advtrains.ndb.swap_node(pos, {name="advtrains_signals_ks:vs_free_"..rot, param2 = node.param2}) setzs3v(pos, nil, rot) elseif dst_aspect_info.main == 0 then advtrains.ndb.swap_node(pos, {name="advtrains_signals_ks:vs_slow_"..rot, param2 = node.param2}) setzs3v(pos, nil, rot) else advtrains.ndb.swap_node(pos, {name="advtrains_signals_ks:vs_nextslow_"..rot, param2 = node.param2}) setzs3v(pos, dst_aspect_info.main, rot) end end end -- Main aspects distant signal -- Only one aspect for "expect free". Whether green or yellow lamp is shown and which speed indicator is determined by remote signal local mainaspects_dst = { { name = "expectclear", description = "Expect Clear", }, } --Rangiersignal local applyaspectf_ra = function(rot) -- we get here the full main_aspect table return function(pos, node, main_aspect, dst_aspect, dst_aspect_info) if not main_aspect.halt then -- any non-halt main aspect is fine, there's only one anyway advtrains.ndb.swap_node(pos, {name="advtrains_signals_ks:ra_shuntd_"..rot, param2 = node.param2}) else advtrains.ndb.swap_node(pos, {name="advtrains_signals_ks:ra_danger_"..rot, param2 = node.param2}) end end end -- Main aspects shunt signal -- Shunt signals have only two states, distant doesn't matter local mainaspects_ra = { { name = "shunt", description = "Shunt", shunt = true, }, } for _, rtab in ipairs({ {rot = "0", sbox = {-1/8, -1/2, -1/2, 1/8, 1/2, -1/4}, ici=true, nextrot = "30"}, {rot = "30", sbox = {-3/8, -1/2, -1/2, -1/8, 1/2, -1/4}, nextrot = "45"}, {rot = "45", sbox = {-1/2, -1/2, -1/2, -1/4, 1/2, -1/4}, nextrot = "60"}, {rot = "60", sbox = {-1/2, -1/2, -3/8, -1/4, 1/2, -1/8}, nextrot = "0"}, }) do local rot = rtab.rot -- Hauptsignal for typ, prts in pairs({ danger = {asp = advtrains.interlocking.signal.ASPI_HALT, n = "slow", ici=true}, slow = { asp = function(pos) return { main = getzs3(pos) or -1, proceed_as_main = true, dst = 0 } end, n = "nextslow" }, nextslow = { asp = function(pos) return { main = getzs3(pos) or -1, proceed_as_main = true, dst = getzs3v(pos) or 6 } end, n = "free" }, free = { asp = function(pos) return { main = getzs3(pos) or -1, proceed_as_main = true, dst = -1 } end, n = "shunt" }, shunt = {asp = { main = 0, shunt = true} , n = "danger"}, }) do local tile = "advtrains_signals_ks_ltm_"..typ..".png" local afunc = prts.asp if type(afunc) == "table" then afunc = function() return prts.asp end end if typ == "nextslow" then tile = { name = tile, animation = { type = "vertical_frames", aspect_w = 32, aspect_h = 32, length = 1, } } end minetest.register_node("advtrains_signals_ks:hs_"..typ.."_"..rot, { description = "Ks Main Signal", drawtype = "mesh", mesh = "advtrains_signals_ks_main_smr"..rot..".obj", tiles = {"advtrains_signals_ks_mast.png", "advtrains_signals_ks_head.png", "advtrains_signals_ks_head.png", tile}, paramtype="light", sunlight_propagates=true, light_source = 4, paramtype2 = "facedir", selection_box = { type = "fixed", fixed = {rtab.sbox, {-1/4, -1/2, -1/4, 1/4, -7/16, 1/4}} }, groups = { cracky = 2, advtrains_signal = 2, not_blocking_trains = 1, save_in_at_nodedb = 1, not_in_creative_inventory = (rtab.ici and prts.ici) and 0 or 1, }, drop = "advtrains_signals_ks:hs_danger_0", inventory_image = "advtrains_signals_ks_hs_inv.png", advtrains = { main_aspects = mainaspects_main, apply_aspect = applyaspectf_main(rot), get_aspect_info = afunc, route_role = "main_distant", trackworker_next_rot = "advtrains_signals_ks:hs_"..typ.."_"..rtab.nextrot, trackworker_rot_incr_param2 = (rot=="60") }, on_rightclick = advtrains.interlocking.signal.on_rightclick, can_dig = advtrains.interlocking.signal.can_dig, after_dig_node = advtrains.interlocking.signal.after_dig, }) -- rotatable by trackworker end -- Vorsignal (NEU!) for typ, prts in pairs({ -- note: the names are taken from the main signal equivalent so that the same names for the lamp images can be used slow = {asp = function(pos) return { dst = 0, shunt = true } end, n = "nextslow", ici=true}, nextslow = { asp = function(pos) return { dst = getzs3v(pos) or 6, shunt = true } end, n = "free" }, free = { asp = function(pos) return { dst = -1, shunt = true } end, n = "slow" }, }) do local tile = "advtrains_signals_ks_ltm_"..typ..".png" local afunc = prts.asp if type(afunc) == "table" then afunc = function() return prts.asp end end if typ == "nextslow" then tile = { name = tile, animation = { type = "vertical_frames", aspect_w = 32, aspect_h = 32, length = 1, } } end minetest.register_node("advtrains_signals_ks:vs_"..typ.."_"..rot, { description = "Ks Distant Signal", drawtype = "mesh", mesh = "advtrains_signals_ks_distant_smr"..rot..".obj", tiles = {"advtrains_signals_ks_mast.png", "advtrains_signals_ks_head.png", "advtrains_signals_ks_head.png", tile}, paramtype="light", sunlight_propagates=true, light_source = 4, paramtype2 = "facedir", selection_box = { type = "fixed", fixed = {rtab.sbox, {-1/4, -1/2, -1/4, 1/4, -7/16, 1/4}} }, groups = { cracky = 2, advtrains_signal = 2, not_blocking_trains = 1, save_in_at_nodedb = 1, not_in_creative_inventory = (rtab.ici and prts.ici) and 0 or 1, }, drop = "advtrains_signals_ks:vs_slow_0", inventory_image = "advtrains_signals_ks_vs_inv.png", advtrains = { main_aspects = mainaspects_dst, apply_aspect = applyaspectf_distant(rot), get_aspect_info = afunc, route_role = "distant", pure_distant = true, trackworker_next_rot = "advtrains_signals_ks:vs_"..typ.."_"..rtab.nextrot, trackworker_rot_incr_param2 = (rot=="60") }, on_rightclick = advtrains.interlocking.signal.on_rightclick, can_dig = advtrains.interlocking.signal.can_dig, after_dig_node = advtrains.interlocking.signal.after_dig, }) -- rotatable by trackworker end --Rangiersignale: for typ, prts in pairs({ danger = {asp = { main = false, shunt = false }, n = "shuntd", ici=true}, shuntd = {asp = { main = false, shunt = true } , n = "danger"}, }) do local sbox = table.copy(rtab.sbox) sbox[5] = 0 local afunc = prts.asp if type(afunc) == "table" then afunc = function() return prts.asp end end minetest.register_node("advtrains_signals_ks:ra_"..typ.."_"..rot, { description = "Ks Shunting Signal", drawtype = "mesh", mesh = "advtrains_signals_ks_sht_smr"..rot..".obj", tiles = {"advtrains_signals_ks_mast.png", "advtrains_signals_ks_head.png", "advtrains_signals_ks_head.png", "advtrains_signals_ks_ltm_"..typ..".png"}, paramtype="light", sunlight_propagates=true, light_source = 4, paramtype2 = "facedir", selection_box = { type = "fixed", fixed = {sbox, rotation_sbox} }, collision_box = { type = "fixed", fixed = sbox, }, groups = { cracky = 2, advtrains_signal = 2, not_blocking_trains = 1, save_in_at_nodedb = 1, not_in_creative_inventory = (rtab.ici and prts.ici) and 0 or 1, }, drop = "advtrains_signals_ks:ra_danger_0", inventory_image = "advtrains_signals_ks_ra_inv.png", advtrains = { main_aspects = mainaspects_ra, apply_aspect = applyaspectf_ra(rot), get_aspect_info = afunc, route_role = "shunt", trackworker_next_rot = "advtrains_signals_ks:ra_"..typ.."_"..rtab.nextrot, trackworker_rot_incr_param2 = (rot=="60") }, on_rightclick = advtrains.interlocking.signal.on_rightclick, can_dig = advtrains.interlocking.signal.can_dig, after_dig_node = advtrains.interlocking.signal.after_dig, }) -- rotatable by trackworker end -- Schilder: local function register_sign(prefix, typ, nxt, description, mesh, tile2, dtyp, inv, asp) minetest.register_node("advtrains_signals_ks:"..prefix.."_"..typ.."_"..rot, { description = description, drawtype = "mesh", mesh = "advtrains_signals_ks_"..mesh.."_smr"..rot..".obj", tiles = {"advtrains_signals_ks_signpost.png", tile2}, paramtype="light", sunlight_propagates=true, light_source = 4, paramtype2 = "facedir", selection_box = { type = "fixed", fixed = {rtab.sbox, {-1/4, -1/2, -1/4, 1/4, -7/16, 1/4}} }, groups = { cracky = 2, advtrains_signal = 2, not_blocking_trains = 1, save_in_at_nodedb = 1, not_in_creative_inventory = (rtab.ici and typ == dtyp) and 0 or 1, }, drop = "advtrains_signals_ks:"..prefix.."_"..dtyp.."_0", inventory_image = inv, advtrains = { get_aspect_info = asp, trackworker_next_rot = "advtrains_signals_ks:"..prefix.."_"..typ.."_"..rtab.nextrot, trackworker_rot_incr_param2 = (rot=="60"), trackworker_next_var = "advtrains_signals_ks:"..prefix.."_"..nxt.."_"..rot, }, on_rightclick = advtrains.interlocking.signal.on_rightclick, can_dig = advtrains.interlocking.signal.can_dig, after_dig_node = advtrains.interlocking.signal.after_dig, }) -- rotatable by trackworker --TODO add rotation using trackworker end for typ, prts in pairs { ["hfs"] = {asp = {main = false, shunt = false}, n = "pam", mesh = "_hfs", owntile = true}, ["pam"] = {asp = {main = -1, shunt = false, proceed_as_main = true}, n = "ne4"}, ["ne4"] = {asp = {}, n = "ne3x1", mesh="_ne4", owntile = true}, ["ne3x1"] = {asp = {}, n = "ne3x2", mesh="_ne3", owntile = true}, ["ne3x2"] = {asp = {}, n = "ne3x3", mesh="_ne3", owntile = true}, ["ne3x3"] = {asp = {}, n = "ne3x4", mesh="_ne3", owntile = true}, ["ne3x4"] = {asp = {}, n = "ne3x5", mesh="_ne3", owntile = true}, ["ne3x5"] = {asp = {}, n = "hfs", mesh="_ne3", owntile = true}, } do local mesh = prts.mesh or "" local tile2 = "advtrains_signals_ks_sign_lf7.png^(advtrains_signals_ks_sign_"..typ..".png^[makealpha:255,255,255)" if prts.owntile then tile2 = "advtrains_signals_ks_sign_"..typ..".png" end register_sign("sign", typ, prts.n, "Signal Sign", "sign"..mesh, tile2, "hfs", "advtrains_signals_ks_sign_lf7.png", prts.asp) end for typ, prts in pairs { -- Speed restrictions: ["4"] = {asp = { main = 4, shunt = true }, n = "6"}, ["6"] = {asp = { main = 6, shunt = true }, n = "8"}, ["8"] = {asp = { main = 8, shunt = true }, n = "12"}, ["12"] = {asp = { main = 12, shunt = true }, n = "16"}, ["16"] = {asp = { main = 16, shunt = true }, n = "e"}, -- Speed restriction lifted ["e"] = {asp = { main = -1, shunt = true }, n = "4", mesh = "_zs10"}, } do local mesh = tonumber(typ) and "_zs3" or prts.mesh or "" local tile2 = "[combine:40x40:0,0=\\(advtrains_signals_ks_sign_off.png\\^[resize\\:40x40\\):3,-2=advtrains_signals_ks_sign_"..typ..".png^[invert:rgb" if typ == "e" then tile2 = "advtrains_signals_ks_sign_zs10.png" end register_sign("sign", typ, prts.n, "Permanent local speed restriction sign", "sign"..mesh, tile2, "8", "advtrains_signals_ks_sign_8.png^[invert:rgb", prts.asp) end for typ, prts in pairs { ["4"] = {main = 4, n = "6"},