aboutsummaryrefslogtreecommitdiff
path: root/advtrains_luaautomation/atc_rail.lua
local ac = {nodes={}}function ac.load(data)if data then ac.nodes=data.nodes endendfunction ac.save()return{nodes = ac.nodes}endfunction 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
Commit message (Expand)AuthorAge
* LuaATC: Fix position of error label, use consistent name "LuaATC" instead of ...orwell962021-11-02
* Hopefully fix #177orwell962021-04-25
* LuaATC: add sending atc command to train by ID, and getters for in/out text (...orwell962021-03-02
* Restore LuaATC autocouple interface accidentally lost in 74a2199orwell962021-02-15
* luaatc: Train event: also remember arrow connection in enter callback, remove...orwell962021-02-10
* luaatc: don't fail train event when train has already passed the rail at even...orwell962021-02-10
* Fix lots of things around new LZBorwell962021-02-10
* Disable ARS train flag and surrounding usesorwell962021-02-10
* Add approach callback mechanism to LuaATCorwell962021-02-10
* add maximum length parameter to split_at_fc and split_off_locomotiveGabriel Pérez-Cerezo2020-08-21
* Add command to split off locomotiveGabriel Pérez-Cerezo2020-07-28
* add train_length command to luaatcGabriel Pérez-Cerezo2020-07-27
* Add function to step through freight codesGabriel Pérez-Cerezo2020-07-26
* add split_train_at_fc luaatc commandGabriel Pérez-Cerezo2020-07-26
* Make using the default tracks optional, even in submodsBlockhead2020-07-10
* fix typo in luaautomationGabriel Pérez-Cerezo2020-07-02
* Add autocouple modeGabriel Pérez-Cerezo2020-06-29
* document shunting mode, add unset_shunt to luaatcGabriel Pérez-Cerezo2020-06-08
* Shunting mode now couples trains on collision.Gabriel Pérez-Cerezo2019-08-11
* Add decoupling to luaatcGabriel Pérez-Cerezo2019-08-11
* Fix occurences of old lzb_invalidateorwell962019-04-23
* Force LZB Halt settingorwell962019-02-05
* Add getter/setter for routingcode in LuaATCorwell962019-01-15
* Remove zip release files, move mod to root, exclude assets from Makefile (#92)rubenwardy2017-09-20
class="hl kwd">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