diff options
author | Singularis <singularis@volny.cz> | 2022-07-05 06:48:19 +0200 |
---|---|---|
committer | orwell <orwell@bleipb.de> | 2025-05-27 20:22:01 +0200 |
commit | ec223d6f3d5d1a7e1257c468d169a0353ec0963e (patch) | |
tree | 683c7a10e32e077b37ece37004442e8c66ebb7f8 | |
parent | 744aee2cdd319bc19e83cc9efb52a07ae6adbb06 (diff) | |
download | advtrains-ec223d6f3d5d1a7e1257c468d169a0353ec0963e.tar.gz advtrains-ec223d6f3d5d1a7e1257c468d169a0353ec0963e.tar.bz2 advtrains-ec223d6f3d5d1a7e1257c468d169a0353ec0963e.zip |
[advtrains]
- odebrán mód advtrains_luaautomation
- lokalizace
- zastaralá funkce getpos() nahrazena za get_pos()
44 files changed, 369 insertions, 2141 deletions
diff --git a/advtrains/couple.lua b/advtrains/couple.lua index 3e6c432..49c8a5d 100644 --- a/advtrains/couple.lua +++ b/advtrains/couple.lua @@ -475,7 +475,7 @@ minetest.register_entity("advtrains:couple", { self.object:remove() end, on_step=function(self, dtime) - if advtrains.wagon_outside_range(self.object:getpos()) then + if advtrains.wagon_outside_range(self.object:get_pos()) then --atdebug("Couple Removing outside range") self.object:remove() return @@ -514,7 +514,7 @@ minetest.register_entity("advtrains:couple", { tp2=advtrains.path_get_interpolated(train2, train2.end_index) end local pos_median=advtrains.pos_median(tp1, tp2) - if not vector.equals(pos_median, self.object:getpos()) then + if not vector.equals(pos_median, self.object:get_pos()) then self.object:set_pos(pos_median) end self.position_set=true diff --git a/advtrains/debugringbuffer.lua b/advtrains/debugringbuffer.lua index bdb4a3a..e753da0 100644 --- a/advtrains/debugringbuffer.lua +++ b/advtrains/debugringbuffer.lua @@ -38,7 +38,7 @@ end minetest.register_chatcommand("atdebug_show", { params = "train sid", -- Short parameter description - description = "Dump debug log", -- Full description + description = "Zapíše ladicí log", -- Full description privs = {train_operator=true}, -- Require the "privs" privilege to run func = function(name, param) advtrains.drb_dump(param) diff --git a/advtrains/init.lua b/advtrains/init.lua index a7e5764..00755d6 100644 --- a/advtrains/init.lua +++ b/advtrains/init.lua @@ -1,4 +1,4 @@ - +print("[MOD BEGIN] " .. minetest.get_current_modname() .. "(" .. os.clock() .. ")") --[[ Advanced Trains - Minetest Mod @@ -422,7 +422,7 @@ function advtrains.load_version_4() end --== load luaatc == - if atlatc then + if minetest.get_modpath("advtrains_luaautomation") and atlatc then local la_save = serialize_lib.load_atomic(advtrains.fpath.."_atlatc.ls") if la_save then atlatc.load(la_save) @@ -526,7 +526,7 @@ advtrains.avt_save = function(remove_players_from_wagons) -- save of luaatc local la_save - if atlatc then + if minetest.get_modpath("advtrains_luaautomation") and atlatc then la_save = atlatc.save() end @@ -614,7 +614,7 @@ minetest.register_globalstep(function(dtime_mt) if advtrains_itm_mainloop then advtrains_itm_mainloop(dtime) end - if atlatc then + if minetest.get_modpath("advtrains_luaautomation") and atlatc then --atlatc.mainloop_stepcode(dtime) atlatc.interrupt.mainloop(dtime) end @@ -643,7 +643,7 @@ end) -- first time called in main loop (after the init phase) because luaautomation has to initialize first. function advtrains.load() advtrains.avt_load() --loading advtrains. includes ndb at advtrains.ndb.load_data() - --if atlatc then + --if minetest.get_modpath("advtrains_luaautomation") and atlatc then -- atlatc.load() --includes interrupts --end == No longer loading here. Now part of avt_save() legacy loading. if advtrains_itm_init then @@ -677,7 +677,7 @@ function advtrains.save(remove_players_from_wagons) local t1 = os.clock() advtrains.avt_save(remove_players_from_wagons) --saving advtrains. includes ndb at advtrains.ndb.save_data() - if atlatc then + if minetest.get_modpath("advtrains_luaautomation") and atlatc then atlatc.save() end atlog("Saved advtrains save files, took",math.floor((os.clock()-t1) * 1000),"ms") @@ -700,7 +700,7 @@ end) minetest.register_chatcommand("at_empty_seats", { params = "", -- Short parameter description - description = "Detach all players, especially the offline ones, from all trains. Use only when no one serious is on a train.", -- Full description + description = attrans("Detach all players, especially the offline ones, from all trains. Use only when no one serious is on a train."), -- Full description privs = {train_operator=true, server=true}, -- Require the "privs" privilege to run func = function(name, param) atwarn("Data is being saved. While saving, advtrains will remove the players from trains. Save files will be reloaded afterwards!") @@ -712,7 +712,7 @@ minetest.register_chatcommand("at_empty_seats", minetest.register_chatcommand("at_reroute", { params = "", - description = "Delete all train routes, force them to recalculate", + description = attrans("Delete all train routes, force them to recalculate"), privs = {train_operator=true}, -- Only train operator is required, since this is relatively safe. func = function(name, param) advtrains.invalidate_all_paths() @@ -722,8 +722,8 @@ minetest.register_chatcommand("at_reroute", minetest.register_chatcommand("at_whereis", { - params = "<train id>", - description = "Returns the position of the train with the given id", + params = attrans("<train id>"), + description = attrans("Returns the position of the train with the given id"), privs = {train_operator = true}, func = function(name,param) local train = advtrains.trains[param] @@ -737,7 +737,7 @@ minetest.register_chatcommand("at_whereis", minetest.register_chatcommand("at_disable_step", { params = "<yes/no>", - description = "Disable the advtrains globalstep temporarily", + description = attrans("Disable the advtrains globalstep temporarily"), privs = {server=true}, func = function(name, param) if minetest.is_yes(param) then @@ -761,5 +761,5 @@ end local tot=(os.clock()-lot)*1000 +print("[MOD END] " .. minetest.get_current_modname() .. "(" .. os.clock() .. ")") minetest.log("action", "[advtrains] Loaded in "..tot.."ms") - diff --git a/advtrains/locale/advtrains.cs.tr b/advtrains/locale/advtrains.cs.tr new file mode 100644 index 0000000..606eee7 --- /dev/null +++ b/advtrains/locale/advtrains.cs.tr @@ -0,0 +1,220 @@ +# textdomain: advtrains +This wagon is owned by @1, you can't destroy it.=Vlastníkem/cí toho vagonu je @1, nemáte právo ho rozebrat. +Warning: If you destroy this wagon, you only get some steel back! If you are sure, hold Sneak and left-click the wagon.=Varování: Rozeberete-li tento vagon, zůstane vám jen několik železných bloků! Jste-li si jisti, stiskněte Shift a klikněte na vagon levým tlačítkem. +Show Inventory=Zobrazit inventář +Select seat:=Vybrat místo k sezení: +ATC controller, unconfigured.=Řídicí obvod ATC, nenastavený. +ATC controller=Řídicí obvod ATC +ATC controller, mode @1@nChannel: @2=Řídicí obvod ATC v režimu "@1"@nKanál: @2 +ATC controller, mode @1@nCommand: @2=Řídicí obvod ATC v režimu "@1"@nPříkaz: @2 +Command=Příkaz +Command (on)=Příkaz (zapnutý) +Digiline channel=Kanál digilinky +Save=Uložit +ATC Reverse command warning: didn't reverse train, train moving!=Obrácení vlaku - Varování: Příkaz 'R' obrací směr jízdy, ne celý vlak! +ATC command syntax error: I statement not closed: @1=Chyba syntaxe: Příkaz není uzavřen: @1 +ATC command parse error: Unknown command: @1=Chyba v programu: Neznámý příkaz: @1 +This position is protected!=Tato pozice je chráněna! +This rail is protected!=Tento traťový úsek je chráněný! +You need to own at least one neighboring wagon to destroy this couple.=K rozebrání těchto vagonů musíte vlastnit alespoň jeden sousedící vagon. +@1 Platform (low)=Nízké nástupiště z: @1 +@1 Platform (high)=Vysoké nástupiště z: @1 +@1 Platform (45 degree)=Vysoké úhlopříčné nástupiště z: @1 +@1 Platform (low, 45 degree)=Nízké úhlopříčné nástupiště z: @1 +off=signál stůj +on=signál volno +Lampless Signal (@1)=Mechanický signál (@1) +Signal (@1)=Světelný signál (@1) +Track Worker Tool@n@nLeft-click: change rail type (straight/curve/switch)@nRight-click: rotate rail/bumper/signal/etc.=Klíč na konstrukci výhybek@n@nLevé tlačítko přepíná typ trati (rovná/zatáčka/výhybka),@nPravé tlačítko otáčí kolejový úsek. +This node can't be rotated using the trackworker!=Tento úsek nelze klíčem otočit! +This node can't be changed using the trackworker!=Tento úsek nelze klíčem změnit! +Can't place: not pointing at node=Kolej nelze umístit: chybí podloží +Can't place: space occupied!=Kolej nelze umístit: prostor je již zabrán! +Can't place: protected position!=Kolej nelze umístit: prostor je chráněn! +Can't place: Not enough slope items left (@1 required)=Kolej nelze umístit: V inventáři nemáte dostatek dílů na celý svah (jsou požadovány @1) +Can't place: There's no slope of length @1=Kolej nelze umístit: Není tu svah o délce @1 +Can't place: no supporting node at upper end.=Kolej nelze umístit: chybí podpora na horním konci svahu. +Deprecated Track=Zastaralý typ koleje +Track=Kolej +Bumper=Zarážka +Detector Rail=Detekující kolej +Speed:=Rychlost: +Target:=Cíl: +@1 Slope=@1: svah +Can't get on: wagon full or doors closed!=Nelze nastoupit, protože všechny dveře jsou zavřené! +Can't get on: @1=Nelze nastoupit: @1 +Use Sneak+rightclick to bypass closed doors!=Pro obejití dveří stiskněte Shift+klikněte pravým tlačítkem na vagon. +Lock couples=Spřažení uzamčeno +Save wagon properties=Uložit vlastnosti vlaku +Doors are closed! Use Sneak+rightclick to ignore the closed doors and get off!=Dveře jsou zavřeny! Pro obejití dveří držte při výstupu Shift. +Wagon properties=Vlastnosti vagonu +Get off=Vystoupit +Get off (forced)=Vystoupit (vynutit) +(Doors closed)=(Dveře zavřeny) +Access to @1=Přístup k: @1 +Default Seat=Výchoí sedadlo +Default Seat (driver stand)=Výchozí sedadlo (sedadlo řidiče/ky) +Driver Stand=Sedadlo řidiče/ky +Driver stand=Sedadlo řidiče/ky +Driver Stand (left)=Sedadlo řidiče/ky (vlevo) +Driver Stand (right)=Sedadlo řidiče/ky (vpravo) +Big Industrial Train Engine=Velká průmyslová lokomotiva +Industrial Train Engine=Průmyslová lokomotiva +Industrial tank wagon=Cisternový nákladní vagon +Industrial wood wagon=Klánicový vůz +Japanese Train Engine=Japonská motorová jednotka +Japanese Train Wagon=Japonský vagon +Steam Engine=Parní lokomotiva +Detailed Steam Engine=Detailní parní lokomotiva +Passenger Wagon=Osobní vagon +Passenger area=Prostor pro cestující +Passenger Area=Prostor pro cestující +Box Wagon=Dřevěný nákladní vagon +Subway Passenger Wagon=Žlutý vůz metra +The wagon's inventory is not empty!=Inventář tohoto vagonu je prázný! +This track can not be changed!=Tento úsek nemůže být změněn! +This track can not be rotated!=Tento úsek nemůže být otočen! +This track can not be removed!=Tento úsek nemůže být odstraněn! +Position is occupied by a train.=Pozice je zabrána vlakem. +There's a Track Circuit Break here.=Zde je hranice traťových oddílů (TCB). +There's a Signal Influence Point here.=Zde je bod účinku signalizace. +Buffer and Chain Coupler=Spřáhlo typu BCC +Scharfenberg Coupler=Spřáhlo typu SC +Japanese Train Inter-Wagon Connection=Japonské spojení mezi vagony(?) +Can not couple: The couplers of the trains do not match (@1 and @2).=Vagony nelze spojit, protože mají různé typy spřáhel: @1 a @2 +<none>=<žádný/á> + +Andrew's Cross=Výstražný kříž +Boiler=Kotel (pro parní lokomotivu) +Chimney=Komín (pro parní lokomotivu) +Train copy/paste tool@n@nLeft-click: copy train@nRight-click: paste train=Duplikátor vlakových souprav@n@nKlik levým: zkopírovat soupravu do schránky@nKlik pravým: umístit duplikát na trať +driver's cab=Kabina strojvedoucí/ho +Loading Track=Kolej nakládání/vykládání +3-way turnout=Třísměrová výhybka +Y-turnout=Výhybka do Y +Unloading Track=Kolej vykládání +90+Angle Diamond Crossing Track=Křížení kolejí s tupým úhlem +Perpendicular Diamond Crossing Track=Pravoúhlé křížení kolejí +Diagonal Diamond Crossing Track=Příčné křížení kolejí +Wallmounted Signal (l)=Semafor pro umístění na zeď (vlevo od trati) +Wallmounted Signal (r)=Semafor pro umístění na zeď (vpravo od trati) +Wallmounted Signal (t)=Semafor pro umístění na zeď (nad tratí) +Wheel=Železniční kolo +Demo signal at Danger=Ukázkový signál: Stůj +Demo signal at Free=Ukázkový signál: Volno +Demo signal at Slow=Ukázkový signál: Pomalu +Point speed restriction=Omezení rychlosti +Point Speed Restriction Rail=Kolej s omezením rychlosti +Station/Stop Rail=Kolej na zastavení ve stanici +Set point speed restriction:=Nastavit omezení rychlosti: +Track Circuit Break=Hranice traťových úseků (TCB) +Interlocking tool@nright-click turnouts to inspect route locks=Železniční inspekční nástroj@nKlikněte pravým tlačítkem na výhybku pro prozkoumání vlakových cest +Interlocking privilege required!=Na přehazování výhybek je potřeba právo! +Ks Main Signal=Hlavní semafor KS +Ks Main Signal Screen=Obrazovka hlavního semaforu KS +Ks Mast=Sloupek KS +Ks Speed Restriction Signal (top)=Omezení rychlosti KS (horní díl) +Ks Speed Restriction Signal (bottom)=Omezení rychlosti KS (spodní díl) +Ks Shunting Signal=Posunový semafor KS +Permanent local speed restriction sign=Trvalé omezení traťové rychlosti +Signal Sign=Železniční značka +Line speed restriction sign=Linkové omezení traťové rychlosti +Temporary local speed restriction sign=Dočasné omezení traťové rychlosti +Ks speed limit indicator=Indikátor traťové rychlosti KS +Ks distant speed limit indicator=Předzvěst traťové rychlosti KS +!!! Train off track !!!=!!!Vlak stojí mimo koleje !!! +Allow these players to access your wagon:=Dovolit těmto hráčským postavám řídit váš vlak: +Wagon road number:=Číslo vagonu: +Freight Code:=Nákladní kód: +Save wagon properties=Uložit vlastnosti vagonu +Text displayed outside on train=Text zobrazený venku +Text displayed inside train=Text zobrazený uvnitř +Line=Linka +Routingcode=Směrovací kód +Train overview/coupling control:=Ovládání spřáhel: +Train overview / coupling control is only shown when the train stands=Ovládání spřáhel je možné jen u strojícího vlaku +Remote Routesetting=Vzdálené nastavení vlakové cesty +Clear 'Disable ARS' flag=Zrušit příznak 'vypnout ARS' +Missing train_operator privilege=Chybí vám právo train_operator +Not allowed to do this.=Toto vám není dovoleno. +You don't have the train_operator privilege.=Chybí vám právo train_operator. +The track you are trying to place the wagon on is not long enough!=Trať není dost dlouhá na umístění tohoto vagonu! +Wagon placeholder=Místodržící vagonu +Onboard Computer=Palubní počítač +Station code '@1' does already exist and is owned by @2=Kód stanice '@1' již existuje a patří: @2 +Not allowed to edit station name, owned by @1=Nemůžete měnit název stanice, protože ta patří: @1 +Next Stop:=Příští zastávka/stanice: +Unknown Station=Neznámá zastávka +Error=Chyba +Stn. @1 T. @2=Stan. @1 kol. @2 +Insufficient privileges to use this!=Nemáte právo použít tento nástroj! +Route lock inspector=Železniční inspekční nástroj +Route locks currently put:=Aktuálně uzamčené vlakové cesty: +Clear=Uvolnit/smazat +No route locks set=Žádné vlakové cesty +Emplace manual lock=Ručně uzamknout +Cannot use this here.=Zde tento nástroj nelze použít. +Manual lock (@1)=Ručně nastavená vlaková cesta (@1) +Set aspect manually=Nastavit stav signalizace ručně +Signal at @1=Značka na pozici @1 +Influence point is set at @1/@2=Bod účinku je nastaven na: @1/@2 +Move=Přesunout +Influence point is not set.=Bod účinku není nastaven. +It is recommended to set an influence point.=Je doporučeno nastavit bod účinku. +This is the point where trains will obey the signal.=To je bod na trati, kde se vlaky budou řídit dle tohoto signálu. +Set=Nastavit +Configuring Signal: Please look in train's driving direction and punch rail to set influence point.=Nastavuji semafor: Dívejte se po směru jízdy vlaku a klikněte levým tlačítkem na trať, abyste nastavil/a bod účinku. +Configuring Signal: Successfully set influence point=Nastavuji semafor: Bod účinku úspěšně nastaven +Configuring Signal: Influence point of another signal is already present!=Nastavuji semafor: Na tomto místě je již nastaven bod účinku jiného semaforu! +Configuring Signal: This is not a normal two-connection rail! Aborted.=Nastavuji semafor: Chyba - toto není normální dvousměrná trať! +Configuring Signal: Node is too far away. Aborted.=Nastavuji semafor: Trať je příliš daleko! +Select Signal Aspect:=Stav signalizce: +@=@= Main Signal @=@==@=@= Hlavní signál @=@= +Halt=Stůj +Continue at maximum speed=Volno +Continue, speed limit unchanged (no info)=Volno, omezení rychlosti beze změny +Continue at speed of @1=Volno, omezení rychlosti: @1 +@=@= Shunting @=@==@=@= Posun @=@= +allowed=povolen +@=@= Distant Signal @=@==@=@= Následující signál @=@= +Expect to stop at the next signal=Bude: Stůj +Expect to pass the next signal at maximum speed=Bude: Volno +No info=Bez informace +Expect to pass the next signal at speed of @1=Bude: Volno s omezením rychlosti na @1 +Save signal aspect=Nastavit +Station Code=Kód zastávky/st. +Station Name=Název zastávky/st. +Door Delay=Zpoždění dveří +Dep. Speed=Rychl. na odj. +Stop Time=Doba stání +Door Side=Otevřít dveře +Left=vlevo +Right=vpravo +Closed=neotevírat +Reverse train=Obrátit směr jízdy +Kick out passengers=Vyhodit cestující +Trains stopping here (ARS rules)=Vlaky zastavující zde (ARS) +Wagon is full.=Vůz je plně obsazen. +Doors are closed! (try holding sneak key!)=Dveře jsou zavřené! (zkuste při nástupu držet Shift) +Tram=Tramvaj +Construction train=Podbíječka + +Blue Subway Passenger Wagon=Modrý vůz metra +Red Subway Passenger Wagon=Červený vůz metra +Green Subway Passenger Wagon=Zelený vůz metra +Black Subway Passenger Wagon=Černý vůz metra +White Subway Passenger Wagon=Bílý vůz metra +Gray Subway Passenger Wagon=Šedý vůz metra + +prev FC=předch. NK +Current FC:=Akt. NK: +next FC=další NK + +Detach all players, especially the offline ones, from all trains. Use only when no one serious is on a train.=Vyhodí všechny postavy (zejména ty nejsoucí ve hře) ze všech vlaků. +Delete all train routes, force them to recalculate=Smaže všechny vlakové cesty, čímž vynutí jejich nové vypočítání. +Returns the position of the train with the given id=Vypíše pozici vlaku podle jeho id +Disable the advtrains globalstep temporarily=Dočasně vypne globální krok advtrains +Display advtrains train map of given area.@nFirst form:[x1 z1 x2 z2] - specify area directly.@nSecond form:[mdef] - Use a predefined map background(see init.lua)@nThird form: No parameters - use WorldEdit position markers.=Zobrazí mapu dané oblasti podle advtrains.@nPrvní forma: [x1 z1 x2 z2] - určit oblast přímo.@nDruhá forma:[mdef] - Použít předdefinované pozadí mapy (viz init.lua)@nTřetí forma: Bez parametrů - použít pozice nastavené v Editoru světa. +Cache advtrains node database again. Run when tracks changed.=Vytvoří novou keš uzlů pro advtrains. Použijte, pokud se změnilo vedení tratí. +<train id>=<id vlaku> +Write node db back to map and find ghost nodes=Zapíše databázi bloků zpět do mapy a najde zdánlivé bloky diff --git a/advtrains/nodedb.lua b/advtrains/nodedb.lua index 41ac089..af21756 100644 --- a/advtrains/nodedb.lua +++ b/advtrains/nodedb.lua @@ -379,7 +379,7 @@ local ptime=0 minetest.register_chatcommand("at_sync_ndb", { params = "", -- Short parameter description - description = "Write node db back to map and find ghost nodes", -- Full description + description = attrans("Write node db back to map and find ghost nodes"), -- Full description privs = {train_operator=true}, func = function(name, param) if os.time() < ptime+30 and not minetest.get_player_privs(name, "server") then diff --git a/advtrains/signals.lua b/advtrains/signals.lua index b26c950..bd1bd49 100644 --- a/advtrains/signals.lua +++ b/advtrains/signals.lua @@ -58,6 +58,7 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red", }, mesh = "advtrains_retrosignal_"..r..rotation..".b3d", tiles = {"advtrains_retrosignal.png"}, + use_texture_alpha = "opaque", inventory_image="advtrains_retrosignal_inv.png", drop="advtrains:retrosignal_off", description=attrans("Lampless Signal (@1)", attrans(r..rotation)), diff --git a/advtrains/tracks.lua b/advtrains/tracks.lua index 261818e..2e8a5ce 100644 --- a/advtrains/tracks.lua +++ b/advtrains/tracks.lua @@ -476,7 +476,8 @@ function advtrains.register_tracks(tracktype, def, preset) mesh = def.shared_model or (def.models_prefix.."_"..img_suffix..def.models_suffix), tiles = {def.shared_texture or (def.texture_prefix.."_"..img_suffix..".png"), def.second_texture}, - + use_texture_alpha = "clip", + groups = { attached_node = advtrains.IGNORE_WORLD and 0 or 1, advtrains_track=1, diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua index 35c3726..41ded71 100644 --- a/advtrains/trainlogic.lua +++ b/advtrains/trainlogic.lua @@ -628,7 +628,7 @@ function advtrains.train_step_b(id, train, dtime) local ocn = otrn.path_cn[ob_idx] local ocp = otrn.path_cp[ob_idx] - local target_is_inside, ref_index, facing + local target_is_inside, ref_index, facing, same_dir if base_cn == ocn then -- same direction diff --git a/advtrains/wagons.lua b/advtrains/wagons.lua index fe1a0f8..9cc7a7d 100644 --- a/advtrains/wagons.lua +++ b/advtrains/wagons.lua @@ -361,7 +361,7 @@ function wagon:on_step(dtime) --show off-track information in outside text instead of notifying the whole server about this if train.off_track then - outside = outside .."\n!!! Train off track !!!" + outside = outside .."\n" .. attrans("!!! Train off track !!!") end if self.infotext_cache~=outside then @@ -700,16 +700,16 @@ function wagon:on_rightclick(clicker) self:get_on(clicker, seatid) return else - rsn="Wagon is full." + rsn=attrans("Wagon is full.") end else - rsn="Doors are closed! (try holding sneak key!)" + rsn=attrans("Doors are closed! (try holding sneak key!)") end end end end end - minetest.chat_send_player(pname, attrans("Can't get on: "..rsn)) + minetest.chat_send_player(pname, attrans("Can't get on: @1", rsn)) else self:show_get_on_form(pname) end @@ -805,8 +805,8 @@ function wagon:get_off(seatno) end --if not door_entry, or paths missing, fall back to old method --atdebug("using fallback") - local objpos=advtrains.round_vector_floor_y(self.object:getpos()) - local yaw=self.object:getyaw() + local objpos=advtrains.round_vector_floor_y(self.object:get_pos()) + local yaw=self.object:get_yaw() local isx=(yaw < math.pi/4) or (yaw > 3*math.pi/4 and yaw < 5*math.pi/4) or (yaw > 7*math.pi/4) local offp --abuse helper function @@ -859,23 +859,23 @@ function wagon:show_wagon_properties(pname) ]] local data = advtrains.wagons[self.id] local form="size[5,5]" - form = form .. "field[0.5,1;4.5,1;whitelist;Allow these players to access your wagon:;"..minetest.formspec_escape(data.whitelist or "").."]" - form = form .. "field[0.5,2;4.5,1;roadnumber;Wagon road number:;"..minetest.formspec_escape(data.roadnumber or "").."]" + form = form .. "field[0.5,1;4.5,1;whitelist;" .. attrans("Allow these players to access your wagon:") .. ";"..minetest.formspec_escape(data.whitelist or "").."]" + form = form .. "field[0.5,2;4.5,1;roadnumber;" .. attrans("Wagon road number:") .. ";"..minetest.formspec_escape(data.roadnumber or "").."]" local fc = "" if data.fc then fc = table.concat(data.fc, "!") end - form = form .. "field[0.5,3;4.5,1;fc;Freight Code:;"..fc.."]" + form = form .. "field[0.5,3;4.5,1;fc;" .. attrans("Freight Code:") ..";"..fc.."]" if data.fc then if not data.fcind then data.fcind = 1 end if data.fcind > 1 then - form=form.."button[0.5,3.5;1,1;fcp;prev FC]" + form=form.."button[0.5,3.5;1,1;fcp;" .. S("prev FC") .."]" end - form=form.."label[1.5,3.5;Current FC:]" + form=form.."label[1.5,3.5;" .. S("Current FC:").."]" local cur = data.fc[data.fcind] or "" form=form.."label[1.5,3.75;"..minetest.formspec_escape(cur).."]" - form=form.."button[3.5,3.5;1,1;fcn;next FC]" + form=form.."button[3.5,3.5;1,1;fcn;" .. S("next FC") .. "]" end form=form.."button_exit[0.5,4.5;4,1;save;"..attrans("Save wagon properties").."]" minetest.show_formspec(pname, "advtrains_prop_"..self.id, form) @@ -968,7 +968,7 @@ function wagon:show_bordcom(pname) form=form.."field[7.5,3.25;3,1;routingcode;"..attrans("Routingcode")..";"..(minetest.formspec_escape(train.routingcode or "")).."]" --row 5 : train overview and autocoupling if train.velocity==0 then - form=form.."label[0.5,4;Train overview /coupling control:]" + form=form.."label[0.5,4;"..attrans("Train overview/coupling control:").."]" linhei=5 local pre_own, pre_wl, owns_any = nil, nil, minetest.check_player_privs(pname, "train_admin") for i, tpid in ipairs(train.trainparts) do @@ -1008,9 +1008,9 @@ function wagon:show_bordcom(pname) end else - form=form.."label[0.5,4.5;Train overview / coupling control is only shown when the train stands.]" + form=form.."label[0.5,4.5;" .. attrans("Train overview / coupling control is only shown when the train stands.") .. "]" end - form = form .. "button[0.5,8;3,1;save;Save]" + form = form .. "button[0.5,8;3,1;save;" .. attrans("Save") .. "]" -- Interlocking functionality: If the interlocking module is loaded, you can set the signal aspect -- from inside the train @@ -1020,14 +1020,14 @@ function wagon:show_bordcom(pname) local oci = train.lzb.checkpoints[i] if oci.udata and oci.udata.signal_pos then if advtrains.interlocking.db.get_sigd_for_signal(oci.udata.signal_pos) then - form = form .. "button[4.5,8;5,1;ilrs;Remote Routesetting]" + form = form .. "button[4.5,8;5,1;ilrs;" .. attrans("Remote Routesetting") .. "]" break end end i=i+1 end if train.ars_disable then - form = form .. "button[4.5,7;5,1;ilarsenable;Clear 'Disable ARS' flag]" + form = form .. "button[4.5,7;5,1;ilarsenable;" .. attrans("Clear 'Disable ARS' flag") .. "]" end end @@ -1250,7 +1250,7 @@ function wagon:check_seat_group_access(pname, sgr) return false, "Not allowed to access a driver stand!" end if self.seat_groups[sgr].driving_ctrl_access then - advtrains.log("Drive", pname, self.object:getpos(), self:train().text_outside) + advtrains.log("Drive", pname, self.object:get_pos(), self:train().text_outside) end return true end @@ -1267,7 +1267,7 @@ end function advtrains.safe_decouple_wagon(w_id, pname, try_run) if not minetest.check_player_privs(pname, "train_operator") then - minetest.chat_send_player(pname, "Missing train_operator privilege") + minetest.chat_send_player(pname, attrans("Missing train_operator privilege")) return false end local data = advtrains.wagons[w_id] @@ -1285,7 +1285,7 @@ function advtrains.safe_decouple_wagon(w_id, pname, try_run) end if not checklock(pname, data.owner, owdata.owner, data.whitelist, owdata.whitelist) then - minetest.chat_send_player(pname, "Not allowed to do this.") + minetest.chat_send_player(pname, attrans("Not allowed to do this.")) return false end @@ -1372,7 +1372,7 @@ function advtrains.register_wagon(sysname_p, prototype, desc, inv_img, nincreati return itemstack end if not minetest.check_player_privs(placer, {train_operator = true }) then - minetest.chat_send_player(pname, "You don't have the train_operator privilege.") + minetest.chat_send_player(pname, attrans("You don't have the train_operator privilege.")) return itemstack end if not minetest.check_player_privs(placer, {train_admin = true }) and minetest.is_protected(pointed_thing.under, placer:get_player_name()) then @@ -1384,7 +1384,7 @@ function advtrains.register_wagon(sysname_p, prototype, desc, inv_img, nincreati local prevpos = advtrains.get_adjacent_rail(pointed_thing.under, tconns, plconnid, prototype.drives_on) if not prevpos then - minetest.chat_send_player(pname, "The track you are trying to place the wagon on is not long enough!") + minetest.chat_send_player(pname, attrans("The track you are trying to place the wagon on is not long enough!")) return end @@ -1416,5 +1416,5 @@ advtrains.register_wagon("advtrains:wagon_placeholder", { assign_to_seat_group = {}, wagon_span=1, drops={}, -}, "Wagon placeholder", "advtrains_wagon_placeholder.png", true) +}, attrans("Wagon placeholder"), "advtrains_wagon_placeholder.png", true) diff --git a/advtrains_interlocking/demosignals.lua b/advtrains_interlocking/demosignals.lua index 1c1b8b2..e19205a 100644 --- a/advtrains_interlocking/demosignals.lua +++ b/advtrains_interlocking/demosignals.lua @@ -34,7 +34,7 @@ local suppasp = { } minetest.register_node("advtrains_interlocking:ds_danger", { - description = "Demo signal at Danger", + description = attrans("Demo signal at Danger"), tiles = {"at_il_signal_asp_danger.png"}, groups = { cracky = 3, @@ -53,7 +53,7 @@ minetest.register_node("advtrains_interlocking:ds_danger", { after_dig_node = advtrains.interlocking.signal_after_dig, }) minetest.register_node("advtrains_interlocking:ds_free", { - description = "Demo signal at Free", + description = attrans("Demo signal at Free"), tiles = {"at_il_signal_asp_free.png"}, groups = { cracky = 3, @@ -74,7 +74,7 @@ minetest.register_node("advtrains_interlocking:ds_free", { after_dig_node = advtrains.interlocking.signal_after_dig, }) minetest.register_node("advtrains_interlocking:ds_slow", { - description = "Demo signal at Slow", + description = attrans("Demo signal at Slow"), tiles = {"at_il_signal_asp_slow.png"}, groups = { cracky = 3, diff --git a/advtrains_interlocking/init.lua b/advtrains_interlocking/init.lua index a2f5882..83956a2 100644 --- a/advtrains_interlocking/init.lua +++ b/advtrains_interlocking/init.lua @@ -1,6 +1,8 @@ -- Advtrains interlocking system -- See database.lua for a detailed explanation +print("[MOD BEGIN] " .. minetest.get_current_modname() .. "(" .. os.clock() .. ")") + advtrains.interlocking = {} advtrains.SHUNT_SPEED_MAX = 6 @@ -28,3 +30,4 @@ dofile(modpath.."tsr_rail.lua") minetest.register_privilege("interlocking", {description = "Can set up track sections, routes and signals.", give_to_singleplayer = true}) +print("[MOD END] " .. minetest.get_current_modname() .. "(" .. os.clock() .. ")") diff --git a/advtrains_interlocking/signal_api.lua b/advtrains_interlocking/signal_api.lua index 83fae4a..15f26ca 100644 --- a/advtrains_interlocking/signal_api.lua +++ b/advtrains_interlocking/signal_api.lua @@ -257,7 +257,7 @@ function advtrains.interlocking.signal_rc_handler(pos, node, player, itemstack, advtrains.interlocking.show_signal_aspect_selector( pname, ndef.advtrains.supported_aspects, - "Set aspect manually", callback, + attrans("Set aspect manually"), callback, isasp) else --static signal - only IP @@ -325,21 +325,21 @@ function advtrains.interlocking.show_ip_form(pos, pname, only_notset) if not minetest.check_player_privs(pname, "interlocking") then return end - local form = "size[7,5]label[0.5,0.5;Signal at "..minetest.pos_to_string(pos).."]" + local form = "size[7,5]label[0.5,0.5;" .. attrans("Signal at @1", minetest.pos_to_string(pos)).."]" advtrains.interlocking.db.check_for_duplicate_ip(pos) local pts, connid = advtrains.interlocking.db.get_ip_by_signalpos(pos) if pts then - form = form.."label[0.5,1.5;Influence point is set at "..pts.."/"..connid.."]" - form = form.."button_exit[0.5,2.5; 5,1;set;Move]" - form = form.."button_exit[0.5,3.5; 5,1;clear;Clear]" + form = form.."label[0.5,1.5;" .. attrans("Influence point is set at @1/@2", pts, connid).."]" + form = form.."button_exit[0.5,2.5; 5,1;set;"..attrans("Move") .. "]" + form = form.."button_exit[0.5,3.5; 5,1;clear;" .. attrans("Clear") .. "]" local ipos = minetest.string_to_pos(pts) ipmarker(ipos, connid) else - form = form.."label[0.5,1.5;Influence point is not set.]" - form = form.."label[0.5,2.0;It is recommended to set an influence point.]" - form = form.."label[0.5,2.5;This is the point where trains will obey the signal.]" + form = form.."label[0.5,1.5;" .. attrans("Influence point is not set.") .. "]" + form = form.."label[0.5,2.0;" .. attrans("It is recommended to set an influence point.") .. "]" + form = form.."label[0.5,2.5;" .. attrans("This is the point where trains will obey the signal.") .. "]" - form = form.."button_exit[0.5,3.5; 5,1;set;Set]" + form = form.."button_exit[0.5,3.5; 5,1;set;" .. attrans("Set") .. "]" end if not only_notset or not pts then minetest.show_formspec(pname, "at_il_ipassign_"..minetest.pos_to_string(pos), form) @@ -368,12 +368,12 @@ end) -- inits the signal IP assignment process function advtrains.interlocking.signal_init_ip_assign(pos, pname) if not minetest.check_player_privs(pname, "interlocking") then - minetest.chat_send_player(pname, "Insufficient privileges to use this!") + minetest.chat_send_player(pname, attrans("Insufficient privileges to use this!")) return end --remove old IP --advtrains.interlocking.db.clear_ip_by_signalpos(pos) - minetest.chat_send_player(pname, "Configuring Signal: Please look in train's driving direction and punch rail to set influence point.") + minetest.chat_send_player(pname, attrans("Configuring Signal: Please look in train's driving direction and punch rail to set influence point.")) players_assign_ip[pname] = pos end @@ -398,15 +398,15 @@ minetest.register_on_punchnode(function(pos, node, player, pointed_thing) if not advtrains.interlocking.db.get_ip_signal_asp(pts, plconnid) then advtrains.interlocking.db.set_ip_signal(pts, plconnid, signalpos) ipmarker(pos, plconnid) - minetest.chat_send_player(pname, "Configuring Signal: Successfully set influence point") + minetest.chat_send_player(pname, attrans("Configuring Signal: Successfully set influence point")) else - minetest.chat_send_player(pname, "Configuring Signal: Influence point of another signal is already present!") + minetest.chat_send_player(pname, attrans("Configuring Signal: Influence point of another signal is already present!")) end else - minetest.chat_send_player(pname, "Configuring Signal: This is not a normal two-connection rail! Aborted.") + minetest.chat_send_player(pname, attrans("Configuring Signal: This is not a normal two-connection rail! Aborted.")) end else - minetest.chat_send_player(pname, "Configuring Signal: Node is too far away. Aborted.") + minetest.chat_send_player(pname, attrans("Configuring Signal: Node is too far away. Aborted.")) end players_assign_ip[pname] = nil end @@ -429,22 +429,22 @@ function advtrains.interlocking.show_signal_aspect_selector(pname, p_suppasp, p_ } local purpose = p_purpose or "" - local form = "size[7,7]label[0.5,0.5;Select Signal Aspect:]" + local form = "size[7,7]label[0.5,0.5;" .. attrans("Select Signal Aspect:") .. "]" form = form.."label[0.5,1;"..purpose.."]" - form = form.."label[0.5,1.5;== Main Signal ==]" + form = form.."label[0.5,1.5;" .. attrans("== Main Signal ==") .. "]" local selid = 1 local entries = {} for idx, spv in ipairs(suppasp.main) do local entry if spv == 0 then - entry = "Halt" + entry = attrans("Halt") elseif spv == -1 then - entry = "Continue at maximum speed" + entry = attrans("Continue at maximum speed") elseif not spv then - entry = "Continue\\, speed limit unchanged (no info)" + entry = attrans("Continue\\, speed limit unchanged (no info)") else - entry = "Continue at speed of "..spv + entry = attrans("Continue at speed of @1", spv) end -- hack: the crappy formspec system returns the label, not the index. save the index in it. entries[idx] = idx.."| "..entry @@ -455,26 +455,26 @@ function advtrains.interlocking.show_signal_aspect_selector(pname, p_suppasp, p_ form = form.."dropdown[0.5,2;6;main;"..table.concat(entries, ",")..";"..selid.."]" - form = form.."label[0.5,3;== Shunting ==]" + form = form.."label[0.5,3;" .. attrans("== Shunting ==") .. "]" if suppasp.shunt == nil then local st = 1 if isasp and isasp.shunt then st=2 end - form = form.."dropdown[0.5,3.5;6;shunt_free;---,allowed;"..st.."]" + form = form.."dropdown[0.5,3.5;6;shunt_free;---," .. attrans("allowed") .. ";"..st.."]" end - form = form.."label[0.5,4.5;== Distant Signal ==]" + form = form.."label[0.5,4.5;" .. attrans("== Distant Signal ==").."]" local selid = 1 local entries = {} for idx, spv in ipairs(suppasp.dst) do local entry if spv == 0 then - entry = "Expect to stop at the next signal" + entry = attrans("Expect to stop at the next signal") elseif spv == -1 then - entry = "Expect to pass the next signal at maximum speed" + entry = attrans("Expect to pass the next signal at maximum speed") elseif not spv then - entry = "No info" + entry = attrans("No info") else - entry = string.format("Expect to pass the next signal at speed of %d", spv) + entry = attrans("Expect to pass the next signal at speed of @1", string.format("%d", spv)) end entries[idx] = idx.."| "..entry if isasp and spv == (isasp.dst or false) then @@ -483,7 +483,7 @@ function advtrains.interlocking.show_signal_aspect_selector(pname, p_suppasp, p_ end form = form.."dropdown[0.5,5;6;dst;"..table.concat(entries, ",")..";"..selid.."]" - form = form.."button_exit[0.5,6;5,1;save;Save signal aspect]" + form = form.."button_exit[0.5,6;5,1;save;" .. attrans("Save signal aspect") .. "]" local token = advtrains.random_id() @@ -526,7 +526,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) local asp = { main = psl.suppasp.main[maini], dst = psl.suppasp.dst[dsti], - shunt = usebool(psl.suppasp.shunt, fields.shunt_free, "allowed"), + shunt = usebool(psl.suppasp.shunt, fields.shunt_free, attrans("allowed")), info = {} } psl.callback(pname, asp) diff --git a/advtrains_interlocking/tcb_ts_ui.lua b/advtrains_interlocking/tcb_ts_ui.lua index 0cc10da..330ce43 100755 --- a/advtrains_interlocking/tcb_ts_ui.lua +++ b/advtrains_interlocking/tcb_ts_ui.lua @@ -26,7 +26,7 @@ minetest.register_node("advtrains_interlocking:tcb_node", { }, mesh = "at_il_tcb_node.obj", tiles = {"at_il_tcb_node.png"}, - description="Track Circuit Break", + description=attrans("Track Circuit Break"), sunlight_propagates=true, groups = { cracky=3, diff --git a/advtrains_interlocking/tool.lua b/advtrains_interlocking/tool.lua index 5d38b3a..1208b9f 100644 --- a/advtrains_interlocking/tool.lua +++ b/advtrains_interlocking/tool.lua @@ -4,7 +4,7 @@ local ilrs = advtrains.interlocking.route minetest.register_craftitem("advtrains_interlocking:tool",{ - description = "Interlocking tool\nright-click turnouts to inspect route locks", + description = attrans("Interlocking tool\nright-click turnouts to inspect route locks"), groups = {cracky=1}, -- key=name, value=rating; rating=1..3. inventory_image = "at_il_tool.png", wield_image = "at_il_tool.png", @@ -15,28 +15,28 @@ minetest.register_craftitem("advtrains_interlocking:tool",{ return end if not minetest.check_player_privs(pname, {interlocking=true}) then - minetest.chat_send_player(pname, "Insufficient privileges to use this!") + minetest.chat_send_player(pname, attrans("Insufficient privileges to use this!")) return end if pointed_thing.type=="node" then local pos=pointed_thing.under if advtrains.is_passive(pos) then - local form = "size[7,5]label[0.5,0.5;Route lock inspector]" + local form = "size[7,5]label[0.5,0.5;" .. attrans("Route lock inspector") .. "]" local pts = minetest.pos_to_string(pos) local rtl = ilrs.has_route_lock(pts) if rtl then - form = form.."label[0.5,1;Route locks currently put:\n"..rtl.."]" - form = form.."button_exit[0.5,3.5; 5,1;clear;Clear]" + form = form.."label[0.5,1;" .. attrans("Route locks currently put:") .. "\n"..rtl.."]" + form = form.."button_exit[0.5,3.5; 5,1;clear;" .. attrans("Clear") .. "]" else - form = form.."label[0.5,1;No route locks set]" - form = form.."button_exit[0.5,3.5; 5,1;emplace;Emplace manual lock]" + form = form.."label[0.5,1;" .. attrans("No route locks set") .. "]" + form = form.."button_exit[0.5,3.5; 5,1;emplace;" .. attrans("Emplace manual lock") .. "]" end minetest.show_formspec(pname, "at_il_rtool_"..pts, form) else - minetest.chat_send_player(pname, "Cannot use this here.") + minetest.chat_send_player(pname, attrans("Cannot use this here.")) return end end @@ -59,7 +59,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) ilrs.remove_route_locks(pts) end if fields.emplace then - ilrs.add_manual_route_lock(pts, "Manual lock ("..pname..")") + ilrs.add_manual_route_lock(pts, attrans("Manual lock (@1)", pname)) end end end diff --git a/advtrains_interlocking/tsr_rail.lua b/advtrains_interlocking/tsr_rail.lua index f302540..ee8fe37 100644 --- a/advtrains_interlocking/tsr_rail.lua +++ b/advtrains_interlocking/tsr_rail.lua @@ -8,8 +8,8 @@ local function updateform(pos) local pe = advtrains.encode_pos(pos) local npr = advtrains.interlocking.npr_rails[pe] or 2 - meta:set_string("infotext", "Point speed restriction: "..npr) - meta:set_string("formspec", "field[npr;Set point speed restriction:;"..npr.."]") + meta:set_string("infotext", advtrans("Point speed restriction") .. ": "..npr) + meta:set_string("formspec", "field[npr;"..attrans("Set point speed restriction:")..";"..npr.."]") end @@ -25,11 +25,11 @@ local adefunc = function(def, preset, suffix, rotation) on_receive_fields = function(pos, formname, fields, player) local pname = player:get_player_name() if not minetest.check_player_privs(pname, {interlocking=true}) then - minetest.chat_send_player(pname, "Interlocking privilege required!") + minetest.chat_send_player(pname, attrans("Interlocking privilege required!")) return end if minetest.is_protected(pos, pname) then - minetest.chat_send_player(pname, "This rail is protected!") + minetest.chat_send_player(pname, attrans("This rail is protected!")) minetest.record_protection_violation(pos, pname) return end @@ -59,7 +59,7 @@ if minetest.get_modpath("advtrains_train_track") ~= nil then models_prefix="advtrains_dtrack", models_suffix=".b3d", shared_texture="advtrains_dtrack_shared_npr.png", - description="Point Speed Restriction Rail", + description=attrans("Point Speed Restriction Rail"), formats={}, get_additional_definiton = adefunc, }, advtrains.trackpresets.t_30deg_straightonly) diff --git a/advtrains_itrainmap/init.lua b/advtrains_itrainmap/init.lua index 0443609..20c0dfe 100644 --- a/advtrains_itrainmap/init.lua +++ b/advtrains_itrainmap/init.lua @@ -1,4 +1,4 @@ - +print("[MOD BEGIN] " .. minetest.get_current_modname()) local map_def={ example = { @@ -85,8 +85,8 @@ local function cache_ndb() end minetest.register_chatcommand("itm", { - params="[x1 z1 x2 z2] or [mdef]", - description="Display advtrains train map of given area.\nFirst form:[x1 z1 x2 z2] - specify area directly.\nSecond form:[mdef] - Use a predefined map background(see init.lua)\nThird form: No parameters - use WorldEdit position markers.", + params="[x1 z1 x2 z2] nebo [mdef]", + description=attrans("Display advtrains train map of given area.\nFirst form:[x1 z1 x2 z2] - specify area directly.\nSecond form:[mdef] - Use a predefined map background(see init.lua)\nThird form: No parameters - use WorldEdit position markers."), privs={itm=true}, func = function(name, param) local mdef=string.match(param, "^(%S+)$") @@ -119,7 +119,7 @@ minetest.register_chatcommand("itm", { }) minetest.register_chatcommand("itm_cache_ndb", { params="", - description="Cache advtrains node database again. Run when tracks changed.", + description=attrans("Cache advtrains node database again. Run when tracks changed."), privs={itm=true}, func = function(name, param) cache_ndb() @@ -147,3 +147,4 @@ function advtrains_itm_init() --automatically run itm_cache_ndb minetest.after(2, cache_ndb) end +print("[MOD END] " .. minetest.get_current_modname()) diff --git a/advtrains_line_automation/init.lua b/advtrains_line_automation/init.lua index 7b758bc..9223fcd 100644 --- a/advtrains_line_automation/init.lua +++ b/advtrains_line_automation/init.lua @@ -1,5 +1,5 @@ -- Advtrains line automation system - +print("[MOD BEGIN] " .. minetest.get_current_modname() .. "(" .. os.clock() .. ")") advtrains.lines = { -- [station code] = {name=..., owner=...} stations = {}, @@ -45,3 +45,4 @@ function advtrains.lines.step(dtime) advtrains.lines.rwt.step(dtime) advtrains.lines.sched.run() end +print("[MOD END] " .. minetest.get_current_modname() .. "(" .. os.clock() .. ")") diff --git a/advtrains_line_automation/stoprail.lua b/advtrains_line_automation/stoprail.lua index 55a4785..a654630 100644 --- a/advtrains_line_automation/stoprail.lua +++ b/advtrains_line_automation/stoprail.lua @@ -15,20 +15,20 @@ local function updatemeta(pos) local pe = advtrains.encode_pos(pos) local stdata = advtrains.lines.stops[pe] if not stdata then - meta:set_string("infotext", "Error") + meta:set_string("infotext", attrans("Error")) end - meta:set_string("infotext", "Stn. "..stdata.stn.." T. "..stdata.track) + meta:set_string("infotext", attrans("Stn. @1 T. @2"..stdata.track, stdata.stn, stdata.track)) end local door_dropdown = {L=1, R=2, C=3} -local door_dropdown_rev = {Right="R", Left="L", Closed="C"} +local door_dropdown_rev = {[attrans("Right")]="R", [attrans("Left")]="L", [attrans("Closed")]="C"} local function show_stoprailform(pos, player) local pe = advtrains.encode_pos(pos) local pname = player:get_player_name() if minetest.is_protected(pos, pname) then - minetest.chat_send_player(pname, "Position is protected!") + minetest.chat_send_player(pname, attrans("Position is protected!")) return end @@ -58,10 +58,10 @@ local function show_stoprailform(pos, player) form = form.."field[4.30,2.0;1.75,1;track;"..attrans("Track")..";"..minetest.formspec_escape(stdata.track).."]" form = form.."field[6.05,2.0;1.75,1;wait;"..attrans("Stop Time")..";"..stdata.wait.."]" form = form.."label[0.5,2.6;"..attrans("Door Side").."]" - form = form.."dropdown[0.51,3.0;2;doors;Left,Right,Closed;"..door_dropdown[stdata.doors].."]" + form = form.."dropdown[0.51,3.0;2;doors;" .. attrans("Left") .. "," .. attrans("Right") .. "," .. attrans("Closed") .. ";"..door_dropdown[stdata.doors].."]" form = form.."checkbox[3.00,2.7;reverse;"..attrans("Reverse train")..";"..(stdata.reverse and "true" or "false").."]" form = form.."checkbox[3.00,3.1;kick;"..attrans("Kick out passengers")..";"..(stdata.kick and "true" or "false").."]" - form = form.."textarea[0.8,4.2;7,2;ars;Trains stopping here (ARS rules);"..advtrains.interlocking.ars_to_text(stdata.ars).."]" + form = form.."textarea[0.8,4.2;7,2;ars;"..attrans("Trains stopping here (ARS rules)")..";"..advtrains.interlocking.ars_to_text(stdata.ars).."]" form = form.."button[0.5,6;7,1;save;"..attrans("Save").."]" minetest.show_formspec(pname, "at_lines_stop_"..pe, form) @@ -73,7 +73,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) local pos = advtrains.decode_pos(pe) if pos then if minetest.is_protected(pos, pname) then - minetest.chat_send_player(pname, "Position is protected!") + minetest.chat_send_player(pname, attrans("Position is protected!")) return end @@ -94,7 +94,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) if (stn.owner == pname or minetest.check_player_privs(pname, "train_admin")) then stdata.stn = fields.stn else - minetest.chat_send_player(pname, "Station code '"..fields.stn.."' does already exist and is owned by "..stn.owner) + minetest.chat_send_player(pname, attrans("Station code '@1' does already exist and is owned by @2", fields.stn, stn.owner)) show_stoprailform(pos,player) return end @@ -108,7 +108,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) if (stn.owner == pname or minetest.check_player_privs(pname, "train_admin")) then stn.name = fields.stnname else - minetest.chat_send_player(pname, "Not allowed to edit station name, owned by "..stn.owner) + minetest.chat_send_player(pname, attrans("Not allowed to edit station name, owned by @1", stn.owner)) end end @@ -179,8 +179,8 @@ local adefunc = function(def, preset, suffix, rotation) if stdata.ars and (stdata.ars.default or advtrains.interlocking.ars_check_rule_match(stdata.ars, train) ) then advtrains.lzb_add_checkpoint(train, index, 2, nil) local stn = advtrains.lines.stations[stdata.stn] - local stnname = stn and stn.name or "Unknown Station" - train.text_inside = "Next Stop:\n"..stnname + local stnname = stn and stn.name or attrans("Unknown Station") + train.text_inside = attrans("Next Stop:") .. "\n"..stnname advtrains.interlocking.ars_set_disable(train, true) end end @@ -196,7 +196,7 @@ local adefunc = function(def, preset, suffix, rotation) if stdata.ars and (stdata.ars.default or advtrains.interlocking.ars_check_rule_match(stdata.ars, train) ) then local stn = advtrains.lines.stations[stdata.stn] - local stnname = stn and stn.name or "Unknown Station" + local stnname = stn and stn.name or attrans("Unknown Station") -- Send ATC command and set text advtrains.atc.train_set_command(train, "B0 W O"..stdata.doors..(stdata.kick and "K" or "").." D"..stdata.wait.." OC "..(stdata.reverse and "R" or "").."D"..(stdata.ddelay or 1) .. " A1 S" ..(stdata.speed or "M"), true) @@ -218,7 +218,7 @@ if minetest.get_modpath("advtrains_train_track") ~= nil then models_prefix="advtrains_dtrack", models_suffix=".b3d", shared_texture="advtrains_dtrack_shared_stop.png", - description="Station/Stop Rail", + description=attrans("Station/Stop Rail"), formats={}, get_additional_definiton = adefunc, }, advtrains.trackpresets.t_30deg_straightonly) diff --git a/advtrains_luaautomation/README.md b/advtrains_luaautomation/README.md deleted file mode 100755 index 67a4b80..0000000 --- a/advtrains_luaautomation/README.md +++ /dev/null @@ -1,451 +0,0 @@ - -# Advtrains - Lua Automation features - -This mod offers components that run LUA code and interface with each other through a global environment. It makes complex automated railway systems possible. The mod is sometimes abbreviated as 'LuaATC' or 'atlatc'. This stands for AdvTrainsLuaATC. This short name has been chosen for user convenience, since the name of this mod ('advtrains_luaautomation') is very long. - -A probably more complete documentation of LuaATC is found on the [Advtrains Wiki](http://advtrains.de/wiki/doku.php?id=usage:atlatc:start) - -## Privileges -To perform any operations using this mod (except executing operation panels), players need the "atlatc" privilege. -This privilege should never be granted to anyone except trusted administrators. Even though the LUA environment is sandboxed, it is still possible to DoS the server by coding infinite loops or requesting expotentially growing interrupts. - -## Environments - -Each active component is assigned to an environment where all atlac data is held. Components in different environments can't inferface with each other. -This system allows multiple independent automation systems to run simultaneously without polluting each other's environment. - - - `/env_create <env_name>`: -Create environment with the given name. To be able to do anything, you first need to create an environment. Choose the name wisely, you can't change it afterwards without deleting the environment and starting again. - - - `/env_setup <env_name>`: -Invoke the form to edit the environment's initialization code. For more information, see the section on active components. You can also delete an environment from here. - - - `/env_subscribe <env_name>`, `/env_unsubscribe <env_name>`: -Subscribe or unsubscribe from log/error messages originating from this environment - - - `/env_subscriptions [env_name]`: -List your subscriptions or players subscribed to an environment. - - -## Functions and variables -### General Functions and Variables -The following standard Lua libraries are available: - - `string` - - `math` - - `table` - - `os` - -The following standard Lua functions are available: - - `assert` - - `error` - - `ipairs` - - `pairs` - - `next` - - `select` - - `tonumber` - - `tostring` - - `type` - - `unpack` - -Any attempt to overwrite the predefined values results in an error. - -### LuaAutomation Global Variables - - `S` -The variable 'S' contains a table which is shared between all components of the environment. Its contents are persistent over server restarts. May not contain functions, every other value is allowed. - - - `F` -The variable 'F' also contains a table which is shared between all components of the environment. Its contents are discarded on server shutdown or when the init code gets re-run. Every data type is allowed, even functions. -The purpose of this table is not to save data, but to provide static value and function definitions. The table should be populated by the init code. - -### LuaAutomation Global Functions -> Note: in the following functions, all parameters named `pos` designate a position. You can use the following: -> - a default Minetest position vector (eg. {x=34, y=2, z=-18}) -> - the POS(34,2,-18) shorthand below. -> - A string, the passive component name. See 'passive component naming'. - - - - - `POS(x,y,z)` -Shorthand function to create a position vector {x=?, y=?, z=?} with less characters. - - - `getstate(pos)` -Get the state of the passive component at position `pos`. - - - `setstate(pos, newstate)` -Set the state of the passive component at position `pos`. - - - `is_passive(pos)` -Checks whether there is a passive component at the position pos (and/or whether a passive component with this name exists) - - - `interrupt(time, message)` -Cause LuaAutomation to trigger an `int` event on this component after the given time in seconds with the specified `message` field. `message` can be of any Lua data type. Returns true. *Not available in init code.* - - - `interrupt_safe(time, message)` -Like `interrupt()`, but does not add an interrupt and returns false when an interrupt (of any type) is already present for this component. Returns true when interrupt was successfully added. - - - `interrupt_pos(pos, message)` -Immediately trigger an `ext_int` event on the active component at position pos. `message` is like in interrupt(). Use with care, or better **_don't use_**! Incorrect use can result in **_expotential growth of interrupts_**. - - - `clear_interrupts()` -Removes any pending interrupts of this node. - - - `digiline_send(channel, message)` -Make this active component send a digiline message on the specified channel. -Not available in init code. - - - `atc_send_to_train(<train_id>, <atc_command>)` - Sends the specified ATC command to the train specified by its train id. This happens regardless of where the train is in the world, and can be used to remote-control trains. Returns true on success. If the train ID does not exist, returns false and does nothing. See [atc_command.txt](../atc_command.txt) for the ATC command syntax. - -#### Interlocking Route Management Functions -If `advtrains_interlocking` is enabled, the following aditional functions can be used: - - - `can_set_route(pos, route_name)` -Returns whether it is possible to set the route designated by route_name from the signal at pos. - - - `set_route(pos, route_name)` -Requests the given route from the signal at pos. Has the same effect as clicking "Set Route" in the signalling dialog. - - - `cancel_route(pos)` -Cancels the route that is set from the signal at pos. Has the same effect as clicking "Cancel Route" in the signalling dialog. - - - `get_aspect(pos)` -Returns the signal aspect of the signal at pos. A signal aspect has the following format: -```lua -asp = { - main = <int speed>, - -- Main signal aspect, tells state and permitted speed of next section - -- 0 = section is blocked - -- >0 = section is free, speed limit is this value - -- -1 = section is free, maximum speed permitted - -- false = Signal doesn't provide main signal information, retain current speed limit. - shunt = <boolean>, - -- Whether train may proceed as shunt move, on sight - -- main aspect takes precedence over this - -- When main==0, train switches to shunt move and is restricted to speed 8 - proceed_as_main = <boolean>, - -- If an approaching train is a shunt move and 'shunt' is false, - -- the train may proceed as a train move under the "main" aspect - -- if the main aspect permits it (i.e. main!=0) - -- If this is not set, shunt moves are NOT allowed to switch to - -- a train move, and must stop even if "main" would permit passing. - -- This is intended to be used for "Halt for shunt moves" signs. - - dst = <int speed>, - -- Distant signal aspect, tells state and permitted speed of the section after next section - -- The character of these information is purely informational - -- At this time, this field is not actively used - -- 0 = section is blocked - -- >0 = section is free, speed limit is this value - -- -1 = section is free, maximum speed permitted - -- false = Signal doesn't provide distant signal information. - - -- the character of call_on and dead_end is purely informative - call_on = <boolean>, -- Call-on route, expect train in track ahead (not implemented yet) - dead_end = <boolean>, -- Route ends on a dead end (e.g. bumper) (not implemented yet) - - w_speed = <integer>, - -- "Warning speed restriction". Supposed for short-term speed - -- restrictions which always override any other restrictions - -- imposed by "speed" fields, until lifted by a value of -1 - -- (Example: german Langsamfahrstellen-Signale) -} -``` -As of January 2020, the 'dst', 'call_on' and 'dead_end' fields are not used. - -#### Lines - -The advtrains_line_automation component adds a few contraptions that should make creating timeable systems easier. -Part of its functionality is also available in LuaATC: - -- `rwt.*` - all Railway Time functions are included as documented in [the wiki](https://advtrains.de/wiki/doku.php?id=dev:lines:rwt) - - - `schedule(rw_time, msg)`, `schedule_in(rw_dtime, msg)` -Schedules an event of type {type="schedule", schedule=true, msg=msg} at (resp. after) the specified railway time (which can be in any format). You can only schedule one event this way. (uses the new lines-internal scheduler) - -Note: Using the lines scheduler is preferred over using `interrupt()`, as it's more performant and safer to use. - -## Events -The event table is a variable created locally by the component being triggered. It is a table with the following format: -```lua -event = { - type = "<event type>", - <event type> = true, - --additional event-specific content -} -``` -You can check the event type by using the following: -```lua -if event.type == "wanted" then - --do stuff -end -``` -or -```lua -if event.wanted then - --do stuff -end -``` -where `wanted` is the event type to check for. -See the "Active Components" section below for details on the various event types as not all of them are applicable to all components. - -## Components -Atlac components introduce automation-capable components that fall within two categories: - - Active Components are components that are able to run Lua code, triggered by specific events. - - Passive Components can't perform actions themselves. Their state can be read and set by active components or manually by the player. - -### Lua ATC Rails -Lua ATC rails are the only components that can actually interface with trains. The following event types are available to the Lua ATC rails: - - `{type="train", train=true, id="<train_id>"}` - * This event is fired when a train enters the rail. The field `id` is the unique train ID, which is 6-digit random numerical string. - * If the world contains trains from an older advtrains version, this string may be longer and contain a dot `.` - - - `{type="int", int=true, msg=<message>}` - * Fired when an interrupt set by the `interrupt` function runs out. `<message>` is the message passed to the interrupt function. - * For backwards compatiblity reasons, `<message>` is also contained in an `event.message` variable. - - - `{type="ext_int", ext_int=true, message=<message>}` - * Fired when another node called `interrupt_pos` on this position. `message` is the message passed to the interrupt_pos function. - - - `{type="digiline", digiline=true, channel=<channel>, msg=<message>}` - * Fired when the controller receives a digiline message. - -#### Basic Lua Rail Functions and Variables -In addition to the above environment functions, the following functions are available to whilst the train is in contact with the LuaATC rail: - - - `atc_send(<atc_command>)` - Sends the specified ATC command to the train (a string) and returns true. If there is no train, returns false and does nothing. See [atc_command.txt](../atc_command.txt) for the ATC command syntax. - - - `atc_reset()` - Resets the train's current ATC command. If there is no train, returns false and does nothing. - - - `atc_arrow` - Boolean, true when the train is driving in the direction of the arrows of the ATC rail. Nil if there is no train. - - - `atc_id` - Train ID of the train currently passing the controller. Nil if there's no train. - - - `atc_speed` - Speed of the train, or nil if there is no train. - - - `atc_set_text_outside(text)` - Set text shown on the outside of the train. Pass nil to show no text. `text` must be a string. - - - `atc_set_text_inside(text)` - Set text shown to train passengers. Pass nil to show no text. `text` must be a string. - - - `atc_set_text_inside(text) / atc_set_text_outside(text)` - Getters for inside/outside text, return nil when no train is there. - - - `get_line()` - Returns the "Line" property of the train (a string). - This can be used to distinguish between trains of different lines and route them appropriately. - The interlocking system also uses this property for Automatic Routesetting. - - - `set_line(line)` - Sets the "Line" property of the train (a string). - If the first digit of this string is a number (0-9), any subway wagons on the train (from advtrains_train_subway) will have this one displayed as line number - (where "0" is actually shown as Line 10 on the train) - - - `get_rc()` - Returns the "Routingcode" property of the train (a string). - The interlocking system uses this property for Automatic Routesetting. - - - `set_rc(routingcode)` - Sets the "Routingcode" property of the train (a string). - The interlocking system uses this property for Automatic Routesetting. - -#### Shunting Functions and Variables -There are several functions available especially for shunting operations. Some of these functions make use of Freight Codes (FC) set in the Wagon Properties of each wagon and/or locomotive: - - - `split_at_index(index, atc_command)` - Splits the train at the specified index, into a train with index-1 wagons and a second train starting with the index-th wagon. The `atc_command` specified is sent to the second train after decoupling. `"S0"` or `"B0"` is common to ensure any locomotives in the remaining train don't continue to move. - - `index` must be more than 1 to avoid trying to decouple the very front of a train. - - Example: train has wagons `"foo","foo","foo","bar","bar","bar"` - Command: `split_at_index(4,"S0")` - Result: first train (continues at previous speed): `"foo","foo","foo"`, second train (slows at S0): `"bar","bar","bar"` - - - `split_at_fc(atc_command, len)` - Splits the train in such a way that all cars with non-empty current FC of the first part of the train have the same FC. The - `atc_command` specified is sent to the rear part, as with split_at_index. It returns the fc of the cars of the first part. - - Example : Train has current FCs `"" "" "bar" "foo" "bar"` - Command: `split_at_fc(<atc_command>)` - Result: `train "" "" "bar"` and `train "foo" "bar"` - The function returns `"bar"` in this case. - - The optional argument `len` specifies the maximum length for the - first part of the train. - Example: Train has current FCs `"foo" "foo" "foo" "foo" "bar" "bar"` - Command: `split_at_fc(<atc_command>,3)` - Result: `"foo" "foo" "foo"` and `"foo" "bar" "bar"` - The function returns `"foo"` in this case. - - - `split_off_locomotive(command, len)` - Splits off the locomotives at the front of the train, which are - identified by an empty FC. `command` specifies the ATC command to be - executed by the rear half of the train. The optional argument `len` specifies the maximum length for the - first part of the train as above. - - - `step_fc()` - Steps the FCs of all train cars forward. FCs are composed of codes - separated by exclamation marks (`!`), for instance - `"foo!bar!baz"`. Each wagon has a current FC, indicating its next - destination. Stepping the freight code forward, selects the next - code after the !. If the end of the string is reached, then the - first code is selected, except if the string ends with a question - mark (`?`), then the order is reversed. - - - - `train_length()` - returns the number of cars the train is composed of. - - - `set_autocouple()` - Sets the train into autocouple mode. The train will couple to the next train it collides with. - - - `unset_autocouple()` - Unsets autocouple mode - -Deprecated: - - - `set_shunt()`, `unset_shunt()` - deprecated aliases for set_autocouple() and unset_autocouple(), will be removed from a later release. - - -#### Interlocking -These additional functions are available when advtrains_interlocking is enabled: - - - `atc_set_ars_disable(boolean)` - Disables (true) or enables (false) the use of ARS for this train. The train will not trigger ARS (automatic route setting) on signals then. - - Note: If you want to disable ARS from an approach callback, the call to `atc_set_ars_disable(true)` *must* happen during the approach callback, and may not be deferred to an interrupt(). Else the train might trigger an ARS before the interrupt fires. - - - `section_occupancy(section_id)` - Returns a table of train ids for the specified section, nil if no section id is provided, false if the section id is invalid, an empty table if the section id is valid but empty of trains. - -#### Approach callbacks -The LuaATC interface provides a way to hook into the approach callback system, which is for example used in the TSR rails (provided by advtrains_interlocking) or the station tracks (provided by advtrains_lines). However, for compatibility reasons, this behavior needs to be explicitly enabled. - -Enabling the receiving of approach events works by setting a variable in the local environment of the ATC rail, by inserting the following code: - -```lua -__approach_callback_mode = 1 --- to receive approach callbacks only in arrow direction --- or alternatively -__approach_callback_mode = 2 --- to receive approach callbacks in both directions -``` - -The following event will be emitted when a train approaches: -```lua -{type="approach", approach=true, id="<train_id>"} -``` - -Please note these important considerations when using approach callbacks: - - - Approach events might be generated multiple times for the same approaching train. If you are using atc_set_lzb_tsr(), you need to call this function on every run of the approach callback, even if you issued it before for the same train. - - A reference to the train is available while executing this event, so that functions such as atc_send() or atc_set_text_outside() can be called. On any consecutive interrupts, that reference will no longer be available until the train enters the track ("train" event) - - Unlike all other callbacks, approach callbacks are executed synchronous during the train step. This may cause unexpected side effects when performing certain actions (such as switching turnouts, setting signals/routes) from inside such a callback. I strongly encourage you to only run things that are absolutely necessary at this point in time, and defer anything else to an interrupt(). Be aware that certain things might trigger unexpected behavior. - -Operations that are safe to execute in approach callbacks: - - - anything related only to the global environment (setting things in S) - - digiline_send() - - atc_set_text_*() - - atc_set_lzb_tsr() (see below) - -In the context of approach callbacks, one more function is available: - - - `atc_set_lzb_tsr(speed)` -Impose a Temporary Speed Restriction at the location of this rail, making the train pass this rail at the specified speed. (Causes the same behavior as the TSR rail) - -#### Timetable Automation - -The advtrains_line_automation component adds a few contraptions that should make creating timeable systems easier. -Part of its functionality is also available in LuaATC: - -- `rwt.*` -All Railway Time functions are included as documented in https://advtrains.de/wiki/doku.php?id=dev:lines:rwt - -- `schedule(rw_time, msg)` -- `schedule_in(rw_dtime, msg)` -Schedules the following event `{type="schedule", schedule=true, msg=msg}` at (resp. after) the specified railway time (which can be in any format). You can only schedule one event this way. Uses the new lines-internal scheduler. - -### Operator panel -This simple node executes its actions when punched. It can be used to change a switch and update the corresponding signals or similar applications. It can also be connected to by the`digilines` mod. - -The event fired is `{type="punch", punch=true}` by default. In case of an interrupt or a digiline message, the events are similar to the ones of the ATC rail. - -### Init code -The initialization code is not a component as such, but rather a part of the whole environment. It can (and should) be used to make definitions that other components can refer to. -A basic example function to define behavior for trains in stations: -```lua -function F.station(station_name) - if event.train then - atc_send("B0WOL") - atc_set_text_inside(station_name) - interrupt(10,"depart") - end - if event.int and event.message="depart" then - atc_set_text_inside("") --an empty string clears the displayed text - atc_send("OCD1SM") - end -end -``` - -The corresponding Lua ATC Rail(s) would then contain the following or similar: -```lua -F.station("Main Station") -``` - -The init code is run whenever the F table needs to be refilled with data. This is the case on server startup and whenever the init code is changed and you choose to run it. -The event table of the init code is always `{type="init", init=true}` and can not be anything else. -Functions are run in the environment of the currently active node, regardless of where they were defined. - -### Passive components - -All passive components can be interfaced with the `setstate()` and `getstate()` functions (see above). -Each node below has been mapped to specific "states": - -#### Signals -The red/green light signals `advtrains:signal_on/off` are interfaceable. Others such as `advtrains:retrosignal_on/off` are not. If advtrains_interlocking is enabled, trains will obey the signal if the influence point is set. - - - "green" - Signal shows green light - - "red" - Signal shows red light - -#### Switches/Turnouts -All default rail switches are interfaceable, independent of orientation. - - - "cr" The switch is set in the direction that is not straight. - - "st" The switch is set in the direction that is straight. - -The "Y" and "3-Way" switches have custom states. Looking from the convergence point: - - - "l" The switch is set towards the left. - - "c" The switch is set towards the center (3-way only). - - "r" The switch is set towards the right. - - -#### Mesecon Switch -The Mesecon switch can be switched using LuaAutomation. Note that this is not possible on levers or protected mesecon switches, only the unprotected full-node 'Switch' block `mesecons_switch:mesecon_switch_on/off`. - - - "on" - the switch is switched on. - - "off" - the switch is switched off. - -#### Andrew's Cross - - - "on" - it blinks. - - "off" - it does not blink. - -#### Passive Component Naming -You can assign names to passive components using the Passive Component Naming tool. -Once you set a name for any component, you can reference it by that name in the `getstate()` and `setstate()` functions. -This way, you don't need to memorize positions. - -Example: signal named `"Stn_P1_out"` at `(1,2,3)` -Use `setstate("Stn_P1_out", "green")` instead of `setstate(POS(1,2,3), "green")` - -If `advtrains_interlocking` is enabled, PC-Naming can also be used to name interlocking signals for route setting via the `set_route()` functions. -**Important**: The "Signal Name" field in the signalling formspec is completely independent from PC-Naming and can't be used to look up the position. You need to explicitly use the PC-Naming tool. - diff --git a/advtrains_luaautomation/active_common.lua b/advtrains_luaautomation/active_common.lua deleted file mode 100644 index 50fb2bc..0000000 --- a/advtrains_luaautomation/active_common.lua +++ /dev/null @@ -1,202 +0,0 @@ - - -local ac = {nodes={}} - -function ac.load(data) - if data then - ac.nodes=data.nodes - end -end -function ac.save() - return {nodes = ac.nodes} -end - -function ac.after_place_node(pos, player) - local meta=minetest.get_meta(pos) - meta:set_string("formspec", ac.getform(pos, meta)) - meta:set_string("infotext", "LuaATC component, unconfigured.") - local ph=minetest.pos_to_string(pos) - --just get first available key! - for en,_ in pairs(atlatc.envs) do - ac.nodes[ph]={env=en} - return - end -end -function ac.getform(pos, meta_p) - local meta = meta_p or minetest.get_meta(pos) - local envs_asvalues={} - - local ph=minetest.pos_to_string(pos) - local nodetbl = ac.nodes[ph] - local env, code, err = nil, "", "" - if nodetbl then - code=nodetbl.code or "" - err=nodetbl.err or "" - env=nodetbl.env or "" - end - local sel = 1 - for n,_ in pairs(atlatc.envs) do - envs_asvalues[#envs_asvalues+1]=minetest.formspec_escape(n) - if n==env then - sel=#envs_asvalues - end - end - local form = "size["..atlatc.CODE_FORM_SIZE.."]" - .."style[code;font=mono]" - .."label[0,-0.1;Environment]" - .."dropdown[0,0.3;3;env;"..table.concat(envs_asvalues, ",")..";"..sel.."]" - .."button[5,0.2;2,1;save;Save]" - .."button[7,0.2;3,1;cle;Clear Local Env.]" - .."textarea[0.3,1.5;"..atlatc.CODE_FORM_SIZE..";code;Code;"..minetest.formspec_escape(code).."]" - .."label["..atlatc.CODE_FORM_ERRLABELPOS..";"..err.."]" - return form -end - -function ac.after_dig_node(pos, node, player) - advtrains.invalidate_all_paths(pos) - advtrains.ndb.clear(pos) - local ph=minetest.pos_to_string(pos) - ac.nodes[ph]=nil -end - -function ac.on_receive_fields(pos, formname, fields, player) - if not minetest.check_player_privs(player:get_player_name(), {atlatc=true}) then - minetest.chat_send_player(player:get_player_name(), "Missing privilege: atlatc - Operation cancelled!") - return - end - - local meta=minetest.get_meta(pos) - local ph=minetest.pos_to_string(pos) - local nodetbl = ac.nodes[ph] or {} - --if fields.quit then return end - if fields.env then - nodetbl.env=fields.env - end - if fields.code then - nodetbl.code=fields.code - end - if fields.save then - -- reset certain things - nodetbl.err=nil - if advtrains.lines and advtrains.lines.sched then - -- discard all schedules for this node - advtrains.lines.sched.discard_all(advtrains.encode_pos(pos)) - end - end - if fields.cle then - nodetbl.data={} - end - - ac.nodes[ph]=nodetbl - - meta:set_string("formspec", ac.getform(pos, meta)) - if nodetbl.env then - meta:set_string("infotext", "LuaATC component, assigned to environment '"..nodetbl.env.."'") - else - meta:set_string("infotext", "LuaATC component, invalid enviroment set!") - end -end - -function ac.run_in_env(pos, evtdata, customfct_p, ignore_no_code) - local ph=minetest.pos_to_string(pos) - local nodetbl = ac.nodes[ph] - if not nodetbl then - atwarn("LuaATC component at",ph,": Data not in memory! Please visit component and click 'Save'!") - return - end - - local meta - if advtrains.is_node_loaded(pos) then - meta=minetest.get_meta(pos) - end - - if not nodetbl.env or not atlatc.envs[nodetbl.env] then - atwarn("LuaATC component at",ph,": Not an existing environment: "..(nodetbl.env or "<nil>")) - return false - end - local env = atlatc.envs[nodetbl.env] - if not nodetbl.code or nodetbl.code=="" then - if not ignore_no_code then - env:log("warning", "LuaATC component at",ph,": No code to run! (insert -- to suppress warning)") - end - return false - end - - local customfct=customfct_p or {} - -- add interrupt function - customfct.interrupt=function(t, imesg) - assertt(t, "number") - assert(t >= 0) - atlatc.interrupt.add(t, pos, {type="int", int=true, message=imesg, msg=imesg}) --Compatiblity "message" field. - end - customfct.interrupt_safe=function(t, imesg) - assertt(t, "number") - assert(t >= 0) - if atlatc.interrupt.has_at_pos(pos) then - return false - end - atlatc.interrupt.add(t, pos, {type="int", int=true, message=imesg, msg=imesg}) --Compatiblity "message" field. - return true - end - customfct.clear_interrupts=function() - atlatc.interrupt.clear_ints_at_pos(pos) - end - -- add digiline_send function, if digiline is loaded - if minetest.global_exists("digiline") then - customfct.digiline_send=function(channel, msg) - assertt(channel, "string") - if advtrains.is_node_loaded(pos) then - digiline:receptor_send(pos, digiline.rules.default, channel, msg) - end - end - end - -- add lines scheduler if enabled - if advtrains.lines and advtrains.lines.sched then - customfct.schedule = function(rwtime, msg) - return advtrains.lines.sched.enqueue(rwtime, "atlatc_env", {pos=pos, msg=msg}, advtrains.encode_pos(pos), 1) - end - customfct.schedule_in = function(rwtime, msg) - return advtrains.lines.sched.enqueue_in(rwtime, "atlatc_env", {pos=pos, msg=msg}, advtrains.encode_pos(pos), 1) - end - end - - local datain=nodetbl.data or {} - local succ, dataout = env:execute_code(datain, nodetbl.code, evtdata, customfct) - if succ then - atlatc.active.nodes[ph].data=atlatc.remove_invalid_data(dataout) - else - atlatc.active.nodes[ph].err=dataout - env:log("error", "LuaATC component at",ph,": LUA Error:",dataout) - if meta then - meta:set_string("infotext", "LuaATC component, ERROR:"..dataout) - end - --TODO temporary - --if customfct.atc_id then - -- advtrains.drb_dump(customfct.atc_id) - -- error("Debug: LuaATC error hit!") - --end - end - if meta then - meta:set_string("formspec", ac.getform(pos, meta)) - end -end - -function ac.on_digiline_receive(pos, node, channel, msg) - atlatc.interrupt.add(0, pos, {type="digiline", digiline=true, channel = channel, msg = msg}) -end - -if advtrains.lines and advtrains.lines.sched then - advtrains.lines.sched.register_callback("atlatc_env", function(data) - -- This adds another interrupt to the atlatc queue... there might be a better way - atlatc.interrupt.add(0, data.pos, {type="schedule",schedule=true, msg=data.msg}) - end) -end - -ac.trackdef_advtrains_defs = { - on_train_enter = function(pos, train_id) - --do async. Event is fired in train steps - atlatc.interrupt.add(0, pos, {type="train", train=true, id=train_id}) - end, -} - -atlatc.active=ac diff --git a/advtrains_luaautomation/atc_rail.lua b/advtrains_luaautomation/atc_rail.lua deleted file mode 100644 index 5dde99c..0000000 --- a/advtrains_luaautomation/atc_rail.lua +++ /dev/null @@ -1,249 +0,0 @@ --- atc_rail.lua --- registers and handles the ATC rail. Active component. --- This is the only component that can interface with trains, so train interface goes here too. - ---Using subtable -local r={} - --- Note on appr_internal: --- The Approach callback is a special corner case: the train is not on the node, and it is executed synchronized --- (in the train step right during LZB traversal). We therefore need access to the train id and the lzbdata table -function r.fire_event(pos, evtdata, appr_internal) - - local ph=minetest.pos_to_string(pos) - local railtbl = atlatc.active.nodes[ph] - - if not railtbl then - atwarn("LuaATC interface rail at",ph,": Data not in memory! Please visit position and click 'Save'!") - return - end - - --prepare ingame API for ATC. Regenerate each time since pos needs to be known - --If no train, then return false. - - -- try to get the train from the event data - -- This workaround is required because the callback is one step delayed, and a fast train may have already left the node. - -- Also used for approach callback - local train_id = evtdata._train_id - local atc_arrow = evtdata._train_arrow - local train, tvel - - if train_id then - train=advtrains.trains[train_id] - -- speed - tvel=train.velocity - -- if still no train_id available, try to get the train at my position - else - train_id=advtrains.get_train_at_pos(pos) - if train_id then - train=advtrains.trains[train_id] - advtrains.train_ensure_init(train_id, train) - -- look up atc_arrow - local index = advtrains.path_lookup(train, pos) - atc_arrow = (train.path_cn[index] == 1) - -- speed - tvel=train.velocity - end - end - - local customfct={ - atc_send = function(cmd) - if not train_id then return false end - assertt(cmd, "string") - advtrains.atc.train_set_command(train, cmd, atc_arrow) - return true - end, - split_at_index = function(index, cmd) - if not train_id then return false end - assertt(cmd, "string") - if type(index) ~= "number" or index < 2 then - return false - end - local new_id = advtrains.split_train_at_index(train, index) - if new_id then - minetest.after(1,advtrains.atc.train_set_command,advtrains.trains[new_id], cmd, atc_arrow) - return true - end - return false - end, - split_at_fc = function(cmd, len) - assertt(cmd, "string") - if not train_id then return false end - local new_id, fc = advtrains.split_train_at_fc(train, false, len) - if new_id then - minetest.after(1,advtrains.atc.train_set_command,advtrains.trains[new_id], cmd, atc_arrow) - end - return fc or "" - end, - split_off_locomotive = function(cmd, len) - assertt(cmd, "string") - if not train_id then return false end - local new_id, fc = advtrains.split_train_at_fc(train, true, len) - if new_id then - minetest.after(1,advtrains.atc.train_set_command,advtrains.trains[new_id], cmd, atc_arrow) - end - end, - train_length = function () - if not train_id then return false end - return #train.trainparts - end, - step_fc = function() - if not train_id then return false end - advtrains.train_step_fc(train) - end, - set_shunt = function() - -- enable shunting mode - if not train_id then return false end - train.is_shunt = true - end, - unset_shunt = function() - if not train_id then return false end - train.is_shunt = nil - end, - set_autocouple = function () - if not train_id then return false end - train.autocouple = true - end, - unset_autocouple = function () - if not train_id then return false end - train.autocouple = nil - end, - set_line = function(line) - if type(line)~="string" and type(line)~="number" then - return false - end - train.line = line .. "" - minetest.after(0, advtrains.invalidate_path, train_id) - return true - end, - get_line = function() - return train.line - end, - set_rc = function(rc) - if type(rc)~="string"then - return false - end - train.routingcode = rc - minetest.after(0, advtrains.invalidate_path, train_id) - return true - end, - get_rc = function() - return train.routingcode - end, - atc_reset = function() - if not train_id then return false end - advtrains.atc.train_reset_command(train) - return true - end, - atc_arrow = atc_arrow, - atc_id = train_id, - atc_speed = tvel, - atc_set_text_outside = function(text) - if not train_id then return false end - if text then assertt(text, "string") end - advtrains.trains[train_id].text_outside=text - return true - end, - atc_set_text_inside = function(text) - if not train_id then return false end - if text then assertt(text, "string") end - advtrains.trains[train_id].text_inside=text - return true - end, - atc_get_text_outside = function() - if not train_id then return false end - return advtrains.trains[train_id].text_outside - end, - atc_get_text_inside = function(text) - if not train_id then return false end - return advtrains.trains[train_id].text_inside - end, - atc_set_lzb_tsr = function(speed) - if not appr_internal then - error("atc_set_lzb_tsr() can only be used during 'approach' events!") - end - assert(tonumber(speed), "Number expected!") - - local index = appr_internal.index - advtrains.lzb_add_checkpoint(train, index, speed, nil) - - return true - end, - } - -- interlocking specific - if advtrains.interlocking then - customfct.atc_set_ars_disable = function(value) - advtrains.interlocking.ars_set_disable(train, value) - end - end - - atlatc.active.run_in_env(pos, evtdata, customfct) - -end - -advtrains.register_tracks("default", { - nodename_prefix="advtrains_luaautomation:dtrack", - texture_prefix="advtrains_dtrack_atc", - models_prefix="advtrains_dtrack", - models_suffix=".b3d", - shared_texture="advtrains_dtrack_shared_atc.png", - description=atltrans("LuaATC Rail"), - formats={}, - get_additional_definiton = function(def, preset, suffix, rotation) - return { - after_place_node = atlatc.active.after_place_node, - after_dig_node = atlatc.active.after_dig_node, - - on_receive_fields = function(pos, ...) - atlatc.active.on_receive_fields(pos, ...) - - --set arrowconn (for ATC) - local ph=minetest.pos_to_string(pos) - local _, conns=advtrains.get_rail_info_at(pos, advtrains.all_tracktypes) - local nodeent = atlatc.active.nodes[ph] - if nodeent then - nodeent.arrowconn=conns[1].c - end - end, - - advtrains = { - on_train_enter = function(pos, train_id, train, index) - --do async. Event is fired in train steps - atlatc.interrupt.add(0, pos, {type="train", train=true, id=train_id, - _train_id = train_id, _train_arrow = (train.path_cn[index] == 1)}) - end, - on_train_approach = function(pos, train_id, train, index, has_entered, lzbdata) - -- Insert an event only if the rail indicated that it supports approach callbacks - local ph=minetest.pos_to_string(pos) - local railtbl = atlatc.active.nodes[ph] - -- uses a "magic variable" in the local environment of the node - -- This hack is necessary because code might not be prepared to get approach events... - if railtbl and railtbl.data and railtbl.data.__approach_callback_mode then - local acm = railtbl.data.__approach_callback_mode - local in_arrow = (train.path_cn[index] == 1) - if acm==2 or (acm==1 and in_arrow) then - local evtdata = {type="approach", approach=true, id=train_id, has_entered = has_entered, - _train_id = train_id, _train_arrow = in_arrow} -- reuses code from train_enter - -- This event is *required* to run synchronously, because it might set the ars_disable flag on the train and add LZB checkpoints, - -- although this is generally discouraged because this happens right in a train step - -- At this moment, I am not aware whether this may cause side effects, and I must encourage users not to do expensive calculations here. - r.fire_event(pos, evtdata, {train_id = train_id, train = train, index = index, lzbdata = lzbdata}) - end - end - end, - }, - luaautomation = { - fire_event=r.fire_event - }, - digiline = { - receptor = {}, - effector = { - action = atlatc.active.on_digiline_receive - }, - }, - } - end, -}, advtrains.trackpresets.t_30deg_straightonly) - - -atlatc.rail = r diff --git a/advtrains_luaautomation/chatcmds.lua b/advtrains_luaautomation/chatcmds.lua deleted file mode 100644 index b6ffaee..0000000 --- a/advtrains_luaautomation/chatcmds.lua +++ /dev/null @@ -1,141 +0,0 @@ ---chatcmds.lua ---Registers commands to modify the init and step code for LuaAutomation - -local function get_init_form(env, pname) - local err = env.init_err or "" - local code = env.init_code or "" - - local form = "size["..atlatc.CODE_FORM_SIZE.."]" - .."style[code;font=mono]" - .."button[0.0,0.2;2.5,1;run;Run Init Code]" - .."button[2.5,0.2;2.5,1;cls;Clear S]" - .."button[5.0,0.2;2.5,1;save;Save]" - .."button[7.5,0.2;2.5,1;del;Delete Env.]" - .."textarea[0.3,1.5;"..atlatc.CODE_FORM_SIZE..";code;Environment initialization code;"..minetest.formspec_escape(code).."]" - .."label[0.0,9.7;"..err.."]" - return form -end - -core.register_chatcommand("env_setup", { - params = "<environment name>", - description = "Set up and modify AdvTrains LuaAutomation environment", - privs = {atlatc=true}, - func = function(name, param) - local env=atlatc.envs[param] - if not env then return false,"Invalid environment name!" end - minetest.show_formspec(name, "atlatc_envsetup_"..param, get_init_form(env, name)) - return true - end, -}) - -core.register_chatcommand("env_create", { - params = "<environment name>", - description = "Create an AdvTrains LuaAutomation environment", - privs = {atlatc=true}, - func = function(name, param) - if not param or param=="" then return false, "Name required!" end - if string.find(param, "[^a-zA-Z0-9-_]") then return false, "Invalid name (only common characters)" end - if atlatc.envs[param] then return false, "Environment already exists!" end - atlatc.envs[param] = atlatc.env_new(param) - atlatc.envs[param].subscribers = {name} - return true, "Created environment '"..param.."'. Use '/env_setup "..param.."' to define global initialization code, or start building LuaATC components!" - end, -}) -core.register_chatcommand("env_subscribe", { - params = "<environment name>", - description = "Subscribe to the log of an Advtrains LuaATC environment", - privs = {atlatc=true}, - func = function(name, param) - local env=atlatc.envs[param] - if not env then return false,"Invalid environment name!" end - for _,pname in ipairs(env.subscribers) do - if pname==name then - return false, "Already subscribed!" - end - end - table.insert(env.subscribers, name) - return true, "Subscribed to environment '"..param.."'." - end, -}) -core.register_chatcommand("env_unsubscribe", { - params = "<environment name>", - description = "Unubscribe to the log of an Advtrains LuaATC environment", - privs = {atlatc=true}, - func = function(name, param) - local env=atlatc.envs[param] - if not env then return false,"Invalid environment name!" end - for index,pname in ipairs(env.subscribers) do - if pname==name then - table.remove(env.subscribers, index) - return true, "Successfully unsubscribed!" - end - end - return false, "Not subscribed to environment '"..param.."'." - end, -}) -core.register_chatcommand("env_subscriptions", { - params = "[environment name]", - description = "List Advtrains LuaATC environments you are subscribed to (no parameters) or subscribers of an environment (giving an env name).", - privs = {atlatc=true}, - func = function(name, param) - if not param or param=="" then - local none=true - for envname, env in pairs(atlatc.envs) do - for _,pname in ipairs(env.subscribers) do - if pname==name then - none=false - minetest.chat_send_player(name, envname) - end - end - end - if none then - return false, "Not subscribed to any!" - end - return true - end - local env=atlatc.envs[param] - if not env then return false,"Invalid environment name!" end - local none=true - for index,pname in ipairs(env.subscribers) do - none=false - minetest.chat_send_player(name, pname) - end - if none then - return false, "No subscribers!" - end - return true - end, -}) - -minetest.register_on_player_receive_fields(function(player, formname, fields) - - local pname=player:get_player_name() - if not minetest.check_player_privs(pname, {atlatc=true}) then return end - - local envname=string.match(formname, "^atlatc_delconfirm_(.+)$") - if envname and fields.sure=="YES" then - atlatc.envs[envname]=nil - minetest.chat_send_player(pname, "Environment deleted!") - return - end - - envname=string.match(formname, "^atlatc_envsetup_(.+)$") - if not envname then return end - - local env=atlatc.envs[envname] - if not env then return end - - if fields.del then - minetest.show_formspec(pname, "atlatc_delconfirm_"..envname, "field[sure;"..minetest.formspec_escape("SURE TO DELETE ENVIRONMENT "..envname.."? Type YES (all uppercase) to continue or just quit form to cancel.")..";]") - return - end - - env.init_err=nil - if fields.code then - env.init_code=fields.code - end - if fields.run then - env:run_initcode() - minetest.show_formspec(pname, formname, get_init_form(env, pname)) - end -end) diff --git a/advtrains_luaautomation/environment.lua b/advtrains_luaautomation/environment.lua deleted file mode 100755 index 6b1a283..0000000 --- a/advtrains_luaautomation/environment.lua +++ /dev/null @@ -1,384 +0,0 @@ -------------- --- lua sandboxed environment - --- function to cross out functions and userdata. --- modified from dump() -function atlatc.remove_invalid_data(o, nested) - if o==nil then return nil end - local valid_dt={["nil"]=true, boolean=true, number=true, string=true} - if type(o) ~= "table" then - --check valid data type - if not valid_dt[type(o)] then - return nil - end - return o - end - -- Contains table -> true/nil of currently nested tables - nested = nested or {} - if nested[o] then - return nil - end - nested[o] = true - for k, v in pairs(o) do - v = atlatc.remove_invalid_data(v, nested) - end - nested[o] = nil - return o -end - - -local env_proto={ - load = function(self, envname, data) - self.name=envname - self.sdata=data.sdata and atlatc.remove_invalid_data(data.sdata) or {} - self.fdata={} - self.init_code=data.init_code or "" - self.subscribers=data.subscribers or {} - end, - save = function(self) - -- throw any function values out of the sdata table - self.sdata = atlatc.remove_invalid_data(self.sdata) - return {sdata = self.sdata, init_code=self.init_code, subscribers=self.subscribers} - end, -} - ---Environment ---Code modified from mesecons_luacontroller (credit goes to Jeija and mesecons contributors) - -local safe_globals = { - "assert", "error", "ipairs", "next", "pairs", "select", - "tonumber", "tostring", "type", "unpack", "_VERSION" -} - -local function safe_date(f, t) - if not f then - -- fall back to old behavior - return(os.date("*t",os.time())) - else - --pass parameters - return os.date(f,t) - end -end - --- string.rep(str, n) with a high value for n can be used to DoS --- the server. Therefore, limit max. length of generated string. -local function safe_string_rep(str, n) - if #str * n > 2000 then - debug.sethook() -- Clear hook - error("string.rep: string length overflow", 2) - end - - return string.rep(str, n) -end - --- string.find with a pattern can be used to DoS the server. --- Therefore, limit string.find to patternless matching. --- Note: Disabled security since there are enough security leaks and this would be unneccessary anyway to DoS the server -local function safe_string_find(...) - --if (select(4, ...)) ~= true then - -- debug.sethook() -- Clear hook - -- error("string.find: 'plain' (fourth parameter) must always be true for security reasons.") - --end - - return string.find(...) -end - -local mp=minetest.get_modpath("advtrains_luaautomation") - -local static_env = { - --core LUA functions - string = { - byte = string.byte, - char = string.char, - format = string.format, - len = string.len, - lower = string.lower, - upper = string.upper, - rep = safe_string_rep, - reverse = string.reverse, - sub = string.sub, - find = safe_string_find, - }, - math = { - abs = math.abs, - acos = math.acos, - asin = math.asin, - atan = math.atan, - atan2 = math.atan2, - ceil = math.ceil, - cos = math.cos, - cosh = math.cosh, - deg = math.deg, - exp = math.exp, - floor = math.floor, - fmod = math.fmod, - frexp = math.frexp, - huge = math.huge, - ldexp = math.ldexp, - log = math.log, - log10 = math.log10, - max = math.max, - min = math.min, - modf = math.modf, - pi = math.pi, - pow = math.pow, - rad = math.rad, - random = math.random, - sin = math.sin, - sinh = math.sinh, - sqrt = math.sqrt, - tan = math.tan, - tanh = math.tanh, - }, - table = { - concat = table.concat, - insert = table.insert, - maxn = table.maxn, - remove = table.remove, - sort = table.sort, - }, - os = { - clock = os.clock, - difftime = os.difftime, - time = os.time, - date = safe_date, - }, - POS = function(x,y,z) return {x=x, y=y, z=z} end, - getstate = advtrains.getstate, - setstate = advtrains.setstate, - is_passive = advtrains.is_passive, - --interrupts are handled per node, position unknown. (same goes for digilines) - --however external interrupts can be set here. - interrupt_pos = function(parpos, imesg) - local pos=atlatc.pcnaming.resolve_pos(parpos, "interrupt_pos") - atlatc.interrupt.add(0, pos, {type="ext_int", ext_int=true, message=imesg}) - end, - -- sends an atc command to train regardless of where it is in the world - atc_send_to_train = function(train_id, command) - assertt(command, "string") - local train = advtrains.trains[train_id] - if train then - advtrains.atc.train_set_command(train, command, true) - return true - else - return false - end - end, -} - --- If interlocking is present, enable route setting functions -if advtrains.interlocking then - local function gen_checks(signal, route_name, noroutesearch) - assertt(route_name, "string") - local pos = atlatc.pcnaming.resolve_pos(signal) - local sigd = advtrains.interlocking.db.get_sigd_for_signal(pos) - if not sigd then - error("There's no signal at "..minetest.pos_to_string(pos)) - end - local tcbs = advtrains.interlocking.db.get_tcbs(sigd) - if not tcbs then - error("Inconsistent configuration, no tcbs for signal at "..minetest.pos_to_string(pos)) - end - - local routeid, route - if not noroutesearch then - for routeidt, routet in ipairs(tcbs.routes) do - if routet.name == route_name then - routeid = routeidt - route = routet - break - end - end - if not route then - error("No route called "..route_name.." at "..minetest.pos_to_string(pos)) - end - end - return pos, sigd, tcbs, routeid, route - end - - - static_env.can_set_route = function(signal, route_name) - local pos, sigd, tcbs, routeid, route = gen_checks(signal, route_name) - -- if route is already set on signal, return whether it's committed - if tcbs.routeset == routeid then - return tcbs.route_committed - end - -- actually try setting route (parameter 'true' designates try-run - local ok = advtrains.interlocking.route.set_route(sigd, route, true) - return ok - end - static_env.set_route = function(signal, route_name) - local pos, sigd, tcbs, routeid, route = gen_checks(signal, route_name) - return advtrains.interlocking.route.update_route(sigd, tcbs, routeid) - end - static_env.cancel_route = function(signal) - local pos, sigd, tcbs, routeid, route = gen_checks(signal, "", true) - return advtrains.interlocking.route.update_route(sigd, tcbs, nil, true) - end - static_env.get_aspect = function(signal) - local pos = atlatc.pcnaming.resolve_pos(signal) - return advtrains.interlocking.signal_get_aspect(pos) - end - static_env.set_aspect = function(signal, asp) - local pos = atlatc.pcnaming.resolve_pos(signal) - return advtrains.interlocking.signal_set_aspect(pos) - end - - --section_occupancy() - static_env.section_occupancy = function(ts_id) - if not ts_id then return nil end - ts_id = tostring(ts_id) - local response = advtrains.interlocking.db.get_ts(ts_id) - if response == nil then - return false - else - return response.trains - end - end -end - --- Lines-specific: -if advtrains.lines then - local atlrwt = advtrains.lines.rwt - static_env.rwt = { - now = atlrwt.now, - new = atlrwt.new, - copy = atlrwt.copy, - to_table = atlrwt.to_table, - to_secs = atlrwt.to_secs, - to_string = atlrwt.to_string, - add = atlrwt.add, - diff = atlrwt.diff, - sub = atlrwt.sub, - adj_diff = atlrwt.adj_diff, - adjust_cycle = atlrwt.adjust_cycle, - adjust = atlrwt.adjust, - to_string = atlrwt.to_string, - get_time_until = atlrwt.get_time_until, - next_rpt = atlrwt.next_rpt, - last_rpt = atlrwt.last_rpt, - time_from_last_rpt = atlrwt.time_from_last_rpt, - time_to_next_rpt = atlrwt.time_to_next_rpt, - } -end - -for _, name in pairs(safe_globals) do - static_env[name] = _G[name] -end - ---The environment all code calls get is a table that has set static_env as metatable. ---In general, every variable is local to a single code chunk, but kept persistent over code re-runs. Data is also saved, but functions and userdata and circular references are removed ---Init code and step code's environments are not saved --- S - Table that can contain any save data global to the environment. Will be saved statically. Can't contain functions or userdata or circular references. --- F - Table global to the environment, can contain volatile data that is deleted when server quits. --- The init code should populate this table with functions and other definitions. - -local proxy_env={} ---proxy_env gets a new metatable in every run, but is the shared environment of all functions ever defined. - --- returns: true, fenv if successful; nil, error if error -function env_proto:execute_code(localenv, code, evtdata, customfct) - -- create us a print function specific for this environment - if not self.safe_print_func then - local myenv = self - self.safe_print_func = function(...) - myenv:log("info", ...) - end - end - - local metatbl ={ - __index = function(t, i) - if i=="S" then - return self.sdata - elseif i=="F" then - return self.fdata - elseif i=="event" then - return evtdata - elseif customfct and customfct[i] then - return customfct[i] - elseif localenv and localenv[i] then - return localenv[i] - elseif i=="print" then - return self.safe_print_func - end - return static_env[i] - end, - __newindex = function(t, i, v) - if i=="S" or i=="F" or i=="event" or (customfct and customfct[i]) or static_env[i] then - debug.sethook() - error("Trying to overwrite environment contents") - end - localenv[i]=v - end, - } - setmetatable(proxy_env, metatbl) - local fun, err=loadstring(code) - if not fun then - return false, err - end - - setfenv(fun, proxy_env) - local succ, data = pcall(fun) - if succ then - data=localenv - end - return succ, data -end - -function env_proto:run_initcode() - if self.init_code and self.init_code~="" then - local old_fdata=self.fdata - self.fdata = {} - --atprint("[atlatc]Running initialization code for environment '"..self.name.."'") - local succ, err = self:execute_code({}, self.init_code, {type="init", init=true}) - if not succ then - self:log("error", "Executing InitCode for '"..self.name.."' failed:"..err) - self.init_err=err - if old_fdata then - self.fdata=old_fdata - self:log("warning", "The 'F' table has been restored to the previous state.") - end - end - end -end - --- log to environment subscribers. severity can be "error", "warning" or "info" (used by internal print) -function env_proto:log(severity, ...) - local text=advtrains.print_concat_table({"[atlatc "..self.name.." "..severity.."]", ...}) - minetest.log("action", text) - for _, pname in ipairs(self.subscribers) do - minetest.chat_send_player(pname, text) - end -end - --- env.subscribers table may be directly altered by callers. - - ---- class interface - -function atlatc.env_new(name) - local newenv={ - name=name, - init_code="", - sdata={}, - subscribers={}, - } - setmetatable(newenv, {__index=env_proto}) - return newenv -end -function atlatc.env_load(name, data) - local newenv={} - setmetatable(newenv, {__index=env_proto}) - newenv:load(name, data) - return newenv -end - -function atlatc.run_initcode() - for envname, env in pairs(atlatc.envs) do - env:run_initcode() - end -end - - - - diff --git a/advtrains_luaautomation/init.lua b/advtrains_luaautomation/init.lua deleted file mode 100644 index c51aa71..0000000 --- a/advtrains_luaautomation/init.lua +++ /dev/null @@ -1,117 +0,0 @@ --- advtrains_luaautomation/init.lua --- Lua automation features for advtrains --- Uses global table 'atlatc' (AdvTrains_LuaATC) - ---TODO: re-add localization (if merging localization, discard this hunk please) -atltrans = function(s,a,...)a={a,...}return s:gsub("@(%d+)",function(n)return a[tonumber(n)]end)end - ---Privilege ---Only trusted players should be enabled to build stuff which can break the server. - -atlatc = { envs = {}} - -minetest.register_privilege("atlatc", { description = "Player can place and modify LUA ATC components. Grant with care! Allows to execute bad LUA code.", give_to_singleplayer = false, default= false }) - ---Size of code input forms in X,Y notation. Must be at least 10x10 -atlatc.CODE_FORM_SIZE = "15,12" ---Position of Error Label in Code Form -atlatc.CODE_FORM_ERRLABELPOS = "0,12" - ---assertt helper. error if a variable is not of a type -function assertt(var, typ) - if type(var)~=typ then - error("Assertion failed, variable has to be of type "..typ) - end -end - -local mp=minetest.get_modpath("advtrains_luaautomation") -if not mp then - error("Mod name error: Mod folder is not named 'advtrains_luaautomation'!") -end -dofile(mp.."/environment.lua") -dofile(mp.."/interrupt.lua") -dofile(mp.."/active_common.lua") -dofile(mp.."/atc_rail.lua") -dofile(mp.."/operation_panel.lua") -if mesecon then - dofile(mp.."/mesecon_controller.lua") -end -dofile(mp.."/pcnaming.lua") - -dofile(mp.."/chatcmds.lua") - - -local filename=minetest.get_worldpath().."/advtrains_luaautomation" - -function atlatc.load(tbl) - if tbl.version==1 then - for envname, data in pairs(tbl.envs) do - atlatc.envs[envname]=atlatc.env_load(envname, data) - end - atlatc.active.load(tbl.active) - atlatc.interrupt.load(tbl.interrupt) - atlatc.pcnaming.load(tbl.pcnaming) - end - -- run init code of all environments - atlatc.run_initcode() -end - -function atlatc.load_pre_v4() - minetest.log("action", "[atlatc] Loading pre-v4 save file") - local file, err = io.open(filename, "r") - if not file then - minetest.log("warning", " Failed to read advtrains_luaautomation save data from file "..filename..": "..(err or "Unknown Error")) - minetest.log("warning", " (this is normal when first enabling advtrains on this world)") - else - atprint("luaautomation reading file:",filename) - local tbl = minetest.deserialize(file:read("*a")) - if type(tbl) == "table" then - if tbl.version==1 then - for envname, data in pairs(tbl.envs) do - atlatc.envs[envname]=atlatc.env_load(envname, data) - end - atlatc.active.load(tbl.active) - atlatc.interrupt.load(tbl.interrupt) - atlatc.pcnaming.load(tbl.pcnaming) - end - else - minetest.log("error", " Failed to read advtrains_luaautomation save data from file "..filename..": Not a table!") - end - file:close() - end - -- run init code of all environments - atlatc.run_initcode() -end - - -atlatc.save = function() - --versions: - -- 1 - Initial save format. - - local envdata={} - for envname, env in pairs(atlatc.envs) do - envdata[envname]=env:save() - end - local save_tbl={ - version = 1, - envs=envdata, - active = atlatc.active.save(), - interrupt = atlatc.interrupt.save(), - pcnaming = atlatc.pcnaming.save(), - } - - return save_tbl -end - ---[[ --- globalstep for step code -local timer, step_int=0, 2 - -function atlatc.mainloop_stepcode(dtime) - timer=timer+dtime - if timer>step_int then - timer=0 - atlatc.run_stepcode() - end -end -]] diff --git a/advtrains_luaautomation/interrupt.lua b/advtrains_luaautomation/interrupt.lua deleted file mode 100644 index 2e54ad8..0000000 --- a/advtrains_luaautomation/interrupt.lua +++ /dev/null @@ -1,73 +0,0 @@ --- interrupt.lua --- implements interrupt queue - ---to be saved: pos and evtdata -local iq={} -local queue={} -local timer=0 -local run=false - -function iq.load(data) - local d=data or {} - queue = d.queue or {} - timer = d.timer or 0 -end -function iq.save() - return {queue = queue, timer=timer} -end - -function iq.has_at_pos(pos) - for i=1,#queue do - local qe=queue[i] - if vector.equals(pos, qe.p) then - return true - end - end - return false -end - -function iq.clear_ints_at_pos(pos) - local i=1 - while i<=#queue do - local qe=queue[i] - if not qe then - table.remove(queue, i) - elseif vector.equals(pos, qe.p) and (qe.e.int or qe.e.ext_int) then - table.remove(queue, i) - else - i=i+1 - end - end -end - -function iq.add(t, pos, evtdata) - queue[#queue+1]={t=t+timer, p=pos, e=evtdata} - run=true -end - -function iq.mainloop(dtime) - timer=timer + math.min(dtime, 0.2) - local i=1 - while i<=#queue do - local qe=queue[i] - if not qe then - table.remove(queue, i) - elseif timer>qe.t then - table.remove(queue, i) - local pos, evtdata=qe.p, qe.e - local node=advtrains.ndb.get_node(pos) - local ndef=minetest.registered_nodes[node.name] - if ndef and ndef.luaautomation and ndef.luaautomation.fire_event then - ndef.luaautomation.fire_event(pos, evtdata) - else - atwarn("[atlatc][interrupt] Couldn't run event",evtdata.type,"on",pos,", something wrong with the node",node) - end - else - i=i+1 - end - end -end - - - -atlatc.interrupt=iq diff --git a/advtrains_luaautomation/mesecon_controller.lua b/advtrains_luaautomation/mesecon_controller.lua deleted file mode 100644 index bffff84..0000000 --- a/advtrains_luaautomation/mesecon_controller.lua +++ /dev/null @@ -1,259 +0,0 @@ --- mesecon_controller.lua --- Mesecon-interfaceable Operation Panel alternative --- Looks like a Mesecon Luacontroller - --- Luacontroller Adapted Code --- From Mesecons mod https://mesecons.net/ --- (c) Jeija and Contributors - -local BASENAME = "advtrains_luaautomation:mesecon_controller" - -local rules = { - a = {x = -1, y = 0, z = 0, name="A"}, - b = {x = 0, y = 0, z = 1, name="B"}, - c = {x = 1, y = 0, z = 0, name="C"}, - d = {x = 0, y = 0, z = -1, name="D"}, -} - -local function generate_name(ports) - local d = ports.d and 1 or 0 - local c = ports.c and 1 or 0 - local b = ports.b and 1 or 0 - local a = ports.a and 1 or 0 - return BASENAME..d..c..b..a -end - - -local function set_port(pos, rule, state) - if state then - mesecon.receptor_on(pos, {rule}) - else - mesecon.receptor_off(pos, {rule}) - end -end - -local function clean_port_states(ports) - ports.a = ports.a and true or false - ports.b = ports.b and true or false - ports.c = ports.c and true or false - ports.d = ports.d and true or false -end - --- Local table for storing which Mesecons off events should be ignored --- Indexed by hex encoded position -local ignored_off_events = {} - -local function set_port_states(pos, ports) - local node = advtrains.ndb.get_node(pos) - local name = node.name - clean_port_states(ports) - local vports = minetest.registered_nodes[name].virtual_portstates - local new_name = generate_name(ports) - - if name ~= new_name and vports then - -- Problem: - -- We need to place the new node first so that when turning - -- off some port, it won't stay on because the rules indicate - -- there is an onstate output port there. - -- When turning the output off then, it will however cause feedback - -- so that the luacontroller will receive an "off" event by turning - -- its output off. - -- Solution / Workaround: - -- Remember which output was turned off and ignore next "off" event. - local ph=minetest.pos_to_string(pos) - local railtbl = atlatc.active.nodes[ph] - if not railtbl then return end - - local ign = railtbl.ignored_off_events or {} - if ports.a and not vports.a and not mesecon.is_powered(pos, rules.a) then ign.A = true end - if ports.b and not vports.b and not mesecon.is_powered(pos, rules.b) then ign.B = true end - if ports.c and not vports.c and not mesecon.is_powered(pos, rules.c) then ign.C = true end - if ports.d and not vports.d and not mesecon.is_powered(pos, rules.d) then ign.D = true end - railtbl.ignored_off_events = ign - - advtrains.ndb.swap_node(pos, {name = new_name, param2 = node.param2}) - - -- Apply mesecon state only if node loaded - -- If node is not loaded, mesecon update will occur on next load via on_updated_from_nodedb - if advtrains.is_node_loaded(pos) then - if ports.a ~= vports.a then set_port(pos, rules.a, ports.a) end - if ports.b ~= vports.b then set_port(pos, rules.b, ports.b) end - if ports.c ~= vports.c then set_port(pos, rules.c, ports.c) end - if ports.d ~= vports.d then set_port(pos, rules.d, ports.d) end - end - end -end - -local function on_updated_from_nodedb(pos, newnode, oldnode) - -- Switch appropriate Mesecon receptors depending on the node change - local vports = minetest.registered_nodes[oldnode.name].virtual_portstates - local ports = minetest.registered_nodes[newnode.name].virtual_portstates - if ports.a ~= vports.a then set_port(pos, rules.a, ports.a) end - if ports.b ~= vports.b then set_port(pos, rules.b, ports.b) end - if ports.c ~= vports.c then set_port(pos, rules.c, ports.c) end - if ports.d ~= vports.d then set_port(pos, rules.d, ports.d) end -end - -local function ignore_offevent(pos, rule) - local ph=minetest.pos_to_string(pos) - local railtbl = atlatc.active.nodes[ph] - if not railtbl then return nil end - local ign = railtbl.ignored_off_events - if ign and ign[rule.name] then - ign[rule.name] = nil - return true - end - return false -end - -local valid_ports = {a=true, b=true, c=true, d=true} - -local function fire_event(pos, evtdata) - local customfct={ - set_mesecon_outputs = function(states) - assertt(states, "table") - set_port_states(pos, states) - end, - get_mesecon_input = function(port) - local portl = string.lower(port) - if not valid_ports[portl] then - error("get_mesecon_input: Invalid port (expected a,b,c,d)") - end - if mesecon.is_powered(pos, rules[portl]) then - return true - end - return false - end, - } - atlatc.active.run_in_env(pos, evtdata, customfct, true) - -end - -local output_rules = {} -local input_rules = {} - -local node_box = { - type = "fixed", - fixed = { - {-8/16, -8/16, -8/16, 8/16, -7/16, 8/16}, -- Bottom slab - {-5/16, -7/16, -5/16, 5/16, -6/16, 5/16}, -- Circuit board - {-3/16, -6/16, -3/16, 3/16, -5/16, 3/16}, -- IC - } -} - -local selection_box = { - type = "fixed", - fixed = { -8/16, -8/16, -8/16, 8/16, -5/16, 8/16 }, -} - -for a = 0, 1 do -- 0 = off 1 = on -for b = 0, 1 do -for c = 0, 1 do -for d = 0, 1 do - local cid = tostring(d)..tostring(c)..tostring(b)..tostring(a) - local node_name = BASENAME..cid - local top = "atlatc_luacontroller_top.png" - if a == 1 then - top = top.."^atlatc_luacontroller_LED_A.png" - end - if b == 1 then - top = top.."^atlatc_luacontroller_LED_B.png" - end - if c == 1 then - top = top.."^atlatc_luacontroller_LED_C.png" - end - if d == 1 then - top = top.."^atlatc_luacontroller_LED_D.png" - end - - local groups - if a + b + c + d ~= 0 then - groups = {dig_immediate=2, not_in_creative_inventory=1, save_in_at_nodedb=1} - else - groups = {dig_immediate=2, save_in_at_nodedb=1} - end - - output_rules[cid] = {} - input_rules[cid] = {} - if a == 1 then table.insert(output_rules[cid], rules.a) end - if b == 1 then table.insert(output_rules[cid], rules.b) end - if c == 1 then table.insert(output_rules[cid], rules.c) end - if d == 1 then table.insert(output_rules[cid], rules.d) end - - if a == 0 then table.insert( input_rules[cid], rules.a) end - if b == 0 then table.insert( input_rules[cid], rules.b) end - if c == 0 then table.insert( input_rules[cid], rules.c) end - if d == 0 then table.insert( input_rules[cid], rules.d) end - - local mesecons = { - effector = { - rules = input_rules[cid], - action_change = function (pos, _, rule_name, new_state) - if new_state == "off" then - -- check for ignored off event on this node - if ignore_offevent(pos, rule_name) then - return - end - end - --Note: rule_name is not a *name* but actually the full rule table (position + name field) - --Event format consistent with Mesecons Luacontroller event - atlatc.interrupt.add(0, pos, {type=new_state, [new_state]=true, pin=rule_name}) - end, - }, - receptor = { - state = mesecon.state.on, - rules = output_rules[cid] - }, - } - - minetest.register_node(node_name, { - description = "LuaATC Mesecon Controller", - drawtype = "nodebox", - tiles = { - top, - "atlatc_luacontroller_bottom.png", - "atlatc_luacontroller_sides.png", - "atlatc_luacontroller_sides.png", - "atlatc_luacontroller_sides.png", - "atlatc_luacontroller_sides.png" - }, - inventory_image = top, - paramtype = "light", - is_ground_content = false, - groups = groups, - drop = BASENAME.."0000", - sunlight_propagates = true, - selection_box = selection_box, - node_box = node_box, - mesecons = mesecons, - -- Virtual portstates are the ports that - -- the node shows as powered up (light up). - virtual_portstates = { - a = a == 1, - b = b == 1, - c = c == 1, - d = d == 1, - }, - after_dig_node = function (pos, node, player) - mesecon.receptor_off(pos, output_rules) - atlatc.active.after_dig_node(pos, node, player) - end, - after_place_node = atlatc.active.after_place_node, - on_receive_fields = atlatc.active.on_receive_fields, - advtrains = { - on_updated_from_nodedb = on_updated_from_nodedb - }, - luaautomation = { - fire_event=fire_event - }, - digiline = { - receptor = {}, - effector = { - action = atlatc.active.on_digiline_receive - }, - }, - }) -end -end -end -end diff --git a/advtrains_luaautomation/mod.conf b/advtrains_luaautomation/mod.conf deleted file mode 100644 index a737603..0000000 --- a/advtrains_luaautomation/mod.conf +++ /dev/null @@ -1,7 +0,0 @@ -name=advtrains_luaautomation -title=Advanced Trains LuaATC -description=Lua control interface to Advanced Trains -author=orwell96 - -depends=advtrains -optional_depends=advtrains_interlocking,advtrains_line_automation,mesecons_switch diff --git a/advtrains_luaautomation/operation_panel.lua b/advtrains_luaautomation/operation_panel.lua deleted file mode 100644 index bfbbda4..0000000 --- a/advtrains_luaautomation/operation_panel.lua +++ /dev/null @@ -1,28 +0,0 @@ - -local function on_punch(pos, player) - atlatc.interrupt.add(0, pos, {type="punch", punch=true}) -end - - -minetest.register_node("advtrains_luaautomation:oppanel", { - drawtype = "normal", - tiles={"atlatc_oppanel.png"}, - description = "LuaATC operation panel", - groups = { - cracky = 1, - save_in_at_nodedb=1, - }, - after_place_node = atlatc.active.after_place_node, - after_dig_node = atlatc.active.after_dig_node, - on_receive_fields = atlatc.active.on_receive_fields, - on_punch = on_punch, - luaautomation = { - fire_event=atlatc.active.run_in_env - }, - digiline = { - receptor = {}, - effector = { - action = atlatc.active.on_digiline_receive - }, - }, -}) diff --git a/advtrains_luaautomation/p_display.lua b/advtrains_luaautomation/p_display.lua deleted file mode 100644 index e69de29..0000000 --- a/advtrains_luaautomation/p_display.lua +++ /dev/null diff --git a/advtrains_luaautomation/passive_api.txt b/advtrains_luaautomation/passive_api.txt deleted file mode 100644 index 5ae1df4..0000000 --- a/advtrains_luaautomation/passive_api.txt +++ /dev/null @@ -1,24 +0,0 @@ -Lua Automation - Passive Component API - -Passive components are nodes that do not have code running in them. However, active components can query these and request actions from them. Examples: -Switches -Signals -Displays -Mesecon Transmitter -Those passive components can also be used inside interlocking systems. - -All passive components have a table called 'advtrains' in their node definition and have the group 'save_in_at_nodedb' set, so they work in unloaded chunks. -Example for a switch: -advtrains = { - getstate = function(pos, node) - return "st" - end, - -- OR - getstate = "st", - - setstate = function(pos, node, newstate) - if newstate=="cr" then - advtrains.ndb.swap_node(pos, <corresponding switch alt>) - end - end -}
\ No newline at end of file diff --git a/advtrains_luaautomation/pcnaming.lua b/advtrains_luaautomation/pcnaming.lua deleted file mode 100644 index 71f4d9a..0000000 --- a/advtrains_luaautomation/pcnaming.lua +++ /dev/null @@ -1,81 +0,0 @@ ---pcnaming.lua ---a.k.a Passive component naming ---Allows to assign names to passive components, so they can be called like: ---setstate("iamasignal", "green") -atlatc.pcnaming={name_map={}} -function atlatc.pcnaming.load(stuff) - if type(stuff)=="table" then - atlatc.pcnaming.name_map=stuff - end -end -function atlatc.pcnaming.save() - return atlatc.pcnaming.name_map -end - -function atlatc.pcnaming.resolve_pos(pos, func_name) - if type(pos)=="string" then - local e = atlatc.pcnaming.name_map[pos] - if e then return e end - elseif type(pos)=="table" and pos.x and pos.y and pos.z then - return pos - end - error("Invalid position supplied to " .. (func_name or "???")..": " .. dump(pos)) -end - -minetest.register_craftitem("advtrains_luaautomation:pcnaming",{ - description = attrans("Passive Component Naming Tool\n\nRight-click to name a passive component."), - groups = {cracky=1}, -- key=name, value=rating; rating=1..3. - inventory_image = "atlatc_pcnaming.png", - wield_image = "atlatc_pcnaming.png", - stack_max = 1, - on_place = function(itemstack, placer, pointed_thing) - local pname = placer:get_player_name() - if not pname then - return - end - if not minetest.check_player_privs(pname, {atlatc=true}) then - minetest.chat_send_player(pname, "Missing privilege: atlatc") - return - end - if pointed_thing.type=="node" then - local pos=pointed_thing.under - if advtrains.is_protected(pos, pname) then - minetest.record_protection_violation(pos, pname) - return - end - local node = advtrains.ndb.get_node(pos) - local ndef = minetest.registered_nodes[node.name] - if node.name and ( - minetest.get_item_group(node.name, "advtrains_signal")>0 --is IL signal - or advtrains.is_passive(pos) -- is passive component - or (ndef and ndef.luaautomation) -- is active component - ) then - --look if this one already has a name - local pn="" - for name, npos in pairs(atlatc.pcnaming.name_map) do - if vector.equals(npos, pos) then - pn=name - end - end - minetest.show_formspec(pname, "atlatc_naming_"..minetest.pos_to_string(pos), "field[pn;Set name of component (empty to clear);"..minetest.formspec_escape(pn).."]") - end - end - end, -}) -minetest.register_on_player_receive_fields(function(player, formname, fields) - local pts=string.match(formname, "^atlatc_naming_(.+)") - if pts then - local pos=minetest.string_to_pos(pts) - if fields.pn then - --first remove all occurences - for name, npos in pairs(atlatc.pcnaming.name_map) do - if vector.equals(npos, pos) then - atlatc.pcnaming.name_map[name]=nil - end - end - if fields.pn~="" then - atlatc.pcnaming.name_map[fields.pn]=pos - end - end - end -end) diff --git a/advtrains_luaautomation/textures/atlatc_luacontroller_LED_A.png b/advtrains_luaautomation/textures/atlatc_luacontroller_LED_A.png Binary files differdeleted file mode 100644 index c6182cc..0000000 --- a/advtrains_luaautomation/textures/atlatc_luacontroller_LED_A.png +++ /dev/null diff --git a/advtrains_luaautomation/textures/atlatc_luacontroller_LED_B.png b/advtrains_luaautomation/textures/atlatc_luacontroller_LED_B.png Binary files differdeleted file mode 100644 index 04c2da0..0000000 --- a/advtrains_luaautomation/textures/atlatc_luacontroller_LED_B.png +++ /dev/null diff --git a/advtrains_luaautomation/textures/atlatc_luacontroller_LED_C.png b/advtrains_luaautomation/textures/atlatc_luacontroller_LED_C.png Binary files differdeleted file mode 100644 index 01f6ae4..0000000 --- a/advtrains_luaautomation/textures/atlatc_luacontroller_LED_C.png +++ /dev/null diff --git a/advtrains_luaautomation/textures/atlatc_luacontroller_LED_D.png b/advtrains_luaautomation/textures/atlatc_luacontroller_LED_D.png Binary files differdeleted file mode 100644 index 6c8a26f..0000000 --- a/advtrains_luaautomation/textures/atlatc_luacontroller_LED_D.png +++ /dev/null diff --git a/advtrains_luaautomation/textures/atlatc_luacontroller_bottom.png b/advtrains_luaautomation/textures/atlatc_luacontroller_bottom.png Binary files differdeleted file mode 100644 index 7ae955c..0000000 --- a/advtrains_luaautomation/textures/atlatc_luacontroller_bottom.png +++ /dev/null diff --git a/advtrains_luaautomation/textures/atlatc_luacontroller_sides.png b/advtrains_luaautomation/textures/atlatc_luacontroller_sides.png Binary files differdeleted file mode 100644 index 40f4b60..0000000 --- a/advtrains_luaautomation/textures/atlatc_luacontroller_sides.png +++ /dev/null diff --git a/advtrains_luaautomation/textures/atlatc_luacontroller_top.png b/advtrains_luaautomation/textures/atlatc_luacontroller_top.png Binary files differdeleted file mode 100644 index a5059af..0000000 --- a/advtrains_luaautomation/textures/atlatc_luacontroller_top.png +++ /dev/null diff --git a/advtrains_luaautomation/textures/atlatc_oppanel.png b/advtrains_luaautomation/textures/atlatc_oppanel.png Binary files differdeleted file mode 100644 index 96eb30e..0000000 --- a/advtrains_luaautomation/textures/atlatc_oppanel.png +++ /dev/null diff --git a/advtrains_luaautomation/textures/atlatc_pcnaming.png b/advtrains_luaautomation/textures/atlatc_pcnaming.png Binary files differdeleted file mode 100644 index 3fccdfc..0000000 --- a/advtrains_luaautomation/textures/atlatc_pcnaming.png +++ /dev/null diff --git a/advtrains_signals_ks/init.lua b/advtrains_signals_ks/init.lua index e97eb77..74a0cee 100755 --- a/advtrains_signals_ks/init.lua +++ b/advtrains_signals_ks/init.lua @@ -1,3 +1,4 @@ +print("[MOD BEGIN] " .. minetest.get_current_modname() .. "(" .. os.clock() .. ")") -- Ks signals -- Can display main aspects (no Zs) + Sht @@ -168,11 +169,12 @@ for _, rtab in ipairs({ } end minetest.register_node("advtrains_signals_ks:hs_"..typ.."_"..rot, { - description = "Ks Main Signal", + description = attrans("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}, - + use_texture_alpha = "opaque", + paramtype="light", sunlight_propagates=true, light_source = 4, @@ -211,11 +213,12 @@ for _, rtab in ipairs({ shuntd = {asp = { main = false, shunt = true } , n = "danger"}, }) do minetest.register_node("advtrains_signals_ks:ra_"..typ.."_"..rot, { - description = "Ks Shunting Signal", + description = attrans("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"}, - + use_texture_alpha = "opaque", + paramtype="light", sunlight_propagates=true, light_source = 4, @@ -256,7 +259,8 @@ for _, rtab in ipairs({ drawtype = "mesh", mesh = "advtrains_signals_ks_"..mesh.."_smr"..rot..".obj", tiles = {"advtrains_signals_ks_signpost.png", tile2}, - + use_texture_alpha = "opaque", + paramtype="light", sunlight_propagates=true, light_source = 4, @@ -295,7 +299,7 @@ for _, rtab in ipairs({ if typ == "hfs" then tile2 = "advtrains_signals_ks_sign_hfs.png" end - register_sign("sign", typ, prts.n, "Signal Sign", "sign"..mesh, tile2, "hfs", "advtrains_signals_ks_sign_lf7.png", prts.asp) + register_sign("sign", typ, prts.n, attrans("Signal Sign"), "sign"..mesh, tile2, "hfs", "advtrains_signals_ks_sign_lf7.png", prts.asp) end for typ, prts in pairs { @@ -313,7 +317,7 @@ for _, rtab in ipairs({ 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) + register_sign("sign", typ, prts.n, attrans("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 { @@ -326,7 +330,7 @@ for _, rtab in ipairs({ } do local tile2 = "advtrains_signals_ks_sign_lf7.png^(advtrains_signals_ks_sign_"..typ..".png^[makealpha:255,255,255)"..(typ == "e" and "" or "^[multiply:orange") local inv = "advtrains_signals_ks_sign_lf7.png^(advtrains_signals_ks_sign_8.png^[makealpha:255,255,255)^[multiply:orange" - register_sign("sign_lf", typ, prts.n, "Temporary local speed restriction sign", "sign", tile2, "8", inv, {main = prts.main, shunt = true, type = "temp"}) + register_sign("sign_lf", typ, prts.n, attrans("Temporary local speed restriction sign"), "sign", tile2, "8", inv, {main = prts.main, shunt = true, type = "temp"}) end for typ, prts in pairs { @@ -339,7 +343,7 @@ for _, rtab in ipairs({ } do local tile2 = "advtrains_signals_ks_sign_lf7.png^(advtrains_signals_ks_sign_"..typ..".png^[makealpha:255,255,255)" local inv = "advtrains_signals_ks_sign_lf7.png^(advtrains_signals_ks_sign_8.png^[makealpha:255,255,255)" - register_sign("sign_lf7", typ, prts.n, "Line speed restriction sign", "sign", tile2, "8", inv, {main = prts.main, shunt = true, type = "line"}) + register_sign("sign_lf7", typ, prts.n, attrans("Line speed restriction sign"), "sign", tile2, "8", inv, {main = prts.main, shunt = true, type = "line"}) end -- Geschwindigkeits(vor)anzeiger für Ks-Signale @@ -354,6 +358,7 @@ for _, rtab in ipairs({ local def = { drawtype = "mesh", tiles = {"advtrains_signals_ks_mast.png","advtrains_signals_ks_head.png","advtrains_signals_ks_sign_"..typ..".png^[invert:rgb^[noalpha"}, + use_texture_alpha = "opaque", paramtype = "light", sunlight_propagates = true, light_source = 4, @@ -373,7 +378,7 @@ for _, rtab in ipairs({ -- Zs 3 local t = table.copy(def) - t.description = "Ks speed limit indicator" + t.description = attrans("Ks speed limit indicator") t.mesh = "advtrains_signals_ks_zs_top_smr"..rot..".obj" t.drop = "advtrains_signals_ks:zs3_off_0" t.selection_box.fixed[1][5] = 0 @@ -382,7 +387,7 @@ for _, rtab in ipairs({ -- Zs 3v local t = table.copy(def) - t.description = "Ks distant speed limit indicator" + t.description = attrans("Ks distant speed limit indicator") t.mesh = "advtrains_signals_ks_zs_bottom_smr"..rot..".obj" t.drop = "advtrains_signals_ks:zs3v_off_0" t.tiles[3] = t.tiles[3] .. "^[multiply:yellow" @@ -391,11 +396,12 @@ for _, rtab in ipairs({ end minetest.register_node("advtrains_signals_ks:mast_mast_"..rot, { - description = "Ks Mast", + description = attrans("Ks Mast"), drawtype = "mesh", mesh = "advtrains_signals_ks_mast_smr"..rot..".obj", tiles = {"advtrains_signals_ks_mast.png"}, - + use_texture_alpha = "opaque", + paramtype="light", sunlight_propagates=true, --light_source = 4, @@ -479,3 +485,4 @@ minetest.register_craft{ output = "advtrains_signals_ks:sign_lf7_8_0 1", recipe = {{"advtrains_signals_ks:sign_lf_8_0"}} } +print("[MOD END] " .. minetest.get_current_modname() .. "(" .. os.clock() .. ")") diff --git a/advtrains_signals_ks/init_degrotate_nodes.lua b/advtrains_signals_ks/init_degrotate_nodes.lua index bd213cb..a3e79e4 100644 --- a/advtrains_signals_ks/init_degrotate_nodes.lua +++ b/advtrains_signals_ks/init_degrotate_nodes.lua @@ -20,7 +20,8 @@ minetest.register_node("advtrains_signals_ks:mast", { }, mesh = "advtrains_signals_ks_mast.obj", tiles = {"advtrains_signals_ks_mast.png"}, - description="Ks Signal Mast", + use_texture_alpha = "opaque", + description=attrans("Ks Signal Mast"), sunlight_propagates=true, groups = { cracky=3, @@ -41,7 +42,8 @@ minetest.register_node("advtrains_signals_ks:head_main", { }, mesh = "advtrains_signals_ks_head_main.obj", tiles = {"advtrains_signals_ks_mast.png", "advtrains_signals_ks_head.png"}, - description="Ks Main Signal Screen", + use_texture_alpha = "opaque", + description=attrains("Ks Main Signal Screen"), sunlight_propagates=true, groups = { cracky=3, @@ -62,7 +64,8 @@ minetest.register_node("advtrains_signals_ks:zs_top", { }, mesh = "advtrains_signals_ks_zs_top_smr0.obj", tiles = {"advtrains_signals_ks_mast.png", "advtrains_signals_ks_head.png"}, - description="Ks Speed Restriction Signal (top)", + use_texture_alpha = "opaque", + description=attrans("Ks Speed Restriction Signal (top)"), sunlight_propagates=true, groups = { cracky=3, @@ -83,7 +86,8 @@ minetest.register_node("advtrains_signals_ks:zs_bottom", { }, mesh = "advtrains_signals_ks_zs_bottom_smr0.obj", tiles = {"advtrains_signals_ks_mast.png", "advtrains_signals_ks_head.png"}, - description="Ks Speed Restriction Signal (bottom)", + use_texture_alpha = "opaque", + description=attrans("Ks Speed Restriction Signal (bottom)"), sunlight_propagates=true, groups = { cracky=3, diff --git a/advtrains_train_track/init.lua b/advtrains_train_track/init.lua index 87720e2..8bf2d13 100755 --- a/advtrains_train_track/init.lua +++ b/advtrains_train_track/init.lua @@ -1,6 +1,8 @@ -- Default tracks for advtrains -- (c) orwell96 and contributors +print("[MOD BEGIN] " .. minetest.get_current_modname() .. "(" .. os.clock() .. ")") + --flat advtrains.register_tracks("default", { nodename_prefix="advtrains:dtrack", @@ -513,3 +515,5 @@ minetest.register_lbm({ action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:dtrack_st_45", param2=node.param2}) end, }) end + +print("[MOD END] " .. minetest.get_current_modname() .. "(" .. os.clock() .. ")") diff --git a/serialize_lib/init.lua b/serialize_lib/init.lua index afc6884..d80d596 100644 --- a/serialize_lib/init.lua +++ b/serialize_lib/init.lua @@ -13,6 +13,8 @@ GNU Affero General Public License for more details. ]]-- +print("[MOD BEGIN] " .. minetest.get_current_modname() .. "(" .. os.clock() .. ")") + serialize_lib = {} --[[ Configuration table @@ -73,4 +75,4 @@ function serialize_lib.write_table_to_file(root_table, filename) return true end - +print("[MOD END] " .. minetest.get_current_modname() .. "(" .. os.clock() .. ")") |