This shows you the differences between two versions of the page.
— |
usage:atlatc:examples:tis:environment [2022-06-28 12:09] (current) 56independent created |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Environment-Based Train Information System ====== | ||
+ | ===== Introduction ===== | ||
+ | After the [[digilines]] system was used, a server admin thought it would be nicer to not have ugly blue wires all over the place, so decided to wirelessly transmit signals instead. | ||
+ | |||
+ | The environment system uses the '' | ||
+ | |||
+ | It calculates distance based on Co-ordinates. | ||
+ | |||
+ | ===== Explanations ===== | ||
+ | Here, the code uses two seperate scripts. This makes the code a lot more bother to setup, but at least it is less bother then using Digilines. | ||
+ | |||
+ | ==== Collectors ==== | ||
+ | The LuaATC tracks wait for a train to run over them, and check if the distance of the train is less then the previous train (this prevents later trains being registered earlier) | ||
+ | |||
+ | The track extracts information, | ||
+ | |||
+ | ==== Display ==== | ||
+ | The display refreshes every 2 seconds, putting the information with values from the table onto the board. If the information changes, then within 2 seconds the board changes. | ||
+ | |||
+ | The skippingrc is set to the standard on 56i-mtserver, | ||
+ | |||
+ | ===== Code ===== | ||
+ | ==== LuaATC tracks ==== | ||
+ | <code lua> | ||
+ | placeTrack = POS(0,0,0) -- Co-ordinates for the track you are working on | ||
+ | placeStation = POS(0,0,0) -- Co-ordinates for a track of your choice in the station | ||
+ | |||
+ | distance = math.sqrt((placeTrack.x-placeStation.x)^2+(placeTrack.y-placeStation.y)^2+(placeTrack.z-placeStation.z)^2) -- Comment this out if using a different distance calculation and have a raw number | ||
+ | -- distance = xx -- Uncomment this and fill in your number in place of xx if you have a raw number | ||
+ | |||
+ | if event.type == " | ||
+ | if distance < F.tbl.distance then -- Show information for closer trains before further trains | ||
+ | F.tbl = { | ||
+ | distance = distance, | ||
+ | length = train_length(), | ||
+ | line = get_line(), | ||
+ | rc = get_rc(), | ||
+ | } | ||
+ | end | ||
+ | end | ||
+ | </ | ||
+ | |||
+ | ==== Displayers ==== | ||
+ | <code lua > | ||
+ | channel = " | ||
+ | platform = "" | ||
+ | services = "" | ||
+ | skippingrc = " | ||
+ | |||
+ | interrupt(2) -- Set in environment code. | ||
+ | |||
+ | --[[ | ||
+ | |||
+ | {distance = distance, length = length, line = line, rc = rc, skipping = skipping} | ||
+ | |||
+ | Table format for info | ||
+ | |||
+ | Platform 3 - EW services | ||
+ | 30 m Away, 6 cars | ||
+ | EW line, RC By | ||
+ | Stopping here | ||
+ | |||
+ | Information shown | ||
+ | |||
+ | ]]-- | ||
+ | | ||
+ | if F.tbl.rc == skippingrc then | ||
+ | stopping = " | ||
+ | else | ||
+ | stopping = " | ||
+ | end | ||
+ | |||
+ | |||
+ | info = " | ||
+ | |||
+ | digiline_send(channel, | ||
+ | </ | ||