Advanced Trains [advtrains] API documentation -------- To use the API, mods must depend on 'advtrains'. All boolean values in definition tables default to 'false' and can be omitted. ### Wagons Wagons are registered using the function advtrains.register_wagon(name, prototype, description, inventory_image) - 'name' is the internal name of the wagon. It should follow the mod naming convention, however, this is not enforced. For compatibility reasons, if a mod name is omitted, the wagon will be registered in the advtrains: namespace. Example: A wagon with name="engine_tgv" will be registered as "advtrains:engine_tgv". !IMPORTANT! You must not append a ":" at the start of the name, even if you want to bypass the mod naming convention check. This is because internally the register_wagon function appends a ":" automatically. - 'prototype' is the lua entity prototype. The regular definition keys for luaentites apply. Additional required and optional properties see below. DO NOT define 'on_step', 'on_activate', 'on_punch', 'on_rightclick' and 'get_staticdata' since these will be overridden. Use 'custom_*' instead. - 'description' is the description of the inventory item that is used to place the wagon. - 'inventory_image' is the inventory image of said item. # Wagon prototype properties { ... all regular luaentity properties (mesh, textures, collisionbox a.s.o)... drives_on = {default=true}, ^- used to define the tracktypes (see below) that wagon can drive on. The tracktype identifiers are given as keys, similar to privileges) max_speed = 10, ^- optional, default 10: defines the maximum speed this wagon can drive. The maximum speed of a train is determined by the wagon with the lowest max_speed value. seats = { ^- contains zero or more seat definitions. A seat is a place where a player can be attached when getting on a wagon. { name="Left front window", ^- display name of this seat attach_offset={x=0, y=10, z=0}, ^- this value is passed to 'set_attach' view_offset={x=0, y=6, z=0}, ^- player:set_eye_offset is called with this parameter. group="default" ^- optional. Defines the seat group. See 'seat_groups' below -!- Note: driving_ctrl_access field has moved to seat group definition, -!- but is still partwise supported here. If you don't use seat groups yet, -!- you really should change NOW! }, }, seat_groups = { ^- If defined, activates advanced seating behavior. See "seating behavior". default = { name = "Seats" ^- name of this seat group, to be shown in get-on menu. access_to = {"foo", "bar"} ^- List of seat groups you can access from this seat using the menu when sitting inside the train. require_doors_open = true ^- Only allow getting on and off if doors are open. driving_ctrl_access=false, ^- If the seat is a driver stand, and players sitting here should get access to the train's driving control. } } assign_to_seat_group = {"default"}, ^- optional, like seat_groups. When player right_clicks the wagon, player will be assigned to the first free seat group in the list. doors={ ^- optional. If defined, defines door animation frames. Opposite door has to be closed during animation period. ^- Remember, advtrains can't handle doors on both sides opened simultaneously. open={ [-1]={frames={x=0, y=20}, time=1}, -- open left doors [1]={frames={x=40, y=60}, time=1} -- open right doors sound = ^- The sound file of the doors opening. If none is specified, nothing is played. }, close={ [-1]={frames={x=20, y=40}, time=1}, -- close left doors [1]={frames={x=60, y=80}, time=1} -- close right doors sound = ^- The sound file of the doors closing. If none is specified, nothing is played. } }, door_entry={ 1.5, -1.5 } ^- optional. If defined, defines the locations of the doors on the model as distance from the object center on the path. ^- Getting on by walking in then takes effect. ^- Positive values mean front, negative ones back. Resulting position is automatically shifted to the right side. coupler_types_front = {scharfenberg=true}, coupler_types_back = {chain=true}, ^- Defines the available coupler types on this wagon on the front and back side. Wagon will only couple to wagons that have a matching coupler. (this property does not have any visual impact) ^- Default: not given (nil) - causes the wagon to couple to any other wagon regardless of coupler type. ^- Empty table ({}): This wagon does not couple to any other wagon (e.g. for Linetrack vehicles) ^- Register coupler types using ''advtrains.register_coupler_type(type, name)''. advtrains defines the default types "chain" (Buffer and Chain) and "scharfenberg" (Scharfenberg coupler). wagon_span=2, ^- How far this wagon extends from its base position. Is the half of the wagon length. ^- Used to determine in which distance the other wagons have to be positioned. Will require tweaking. wheel_positions = {1.5, -1.5}, ^- Optional: if defined, the wagon will be placed so that these 2 wheel positions are on the track ^- This parameter is recommended for long wagons (wagon_span >= 2). ^- The position is a distance relative to the center of the wagon. ^- Must have exactly 2 entries, corresponding to the front (1) and rear (2) wheel of the wagon object. 1st must be greater than 2nd. ^- If not provided, the simple 1-position positioning logic will be used (wagon is positioned with the center on the track) extent_h = 1, ^- Determines the collision box extent in x/z direction. Defaults to 1 (=3x3) ^- The actual bounding box size is (extent_h*2)+1, so 0 means 1x1, 1 means 3x3 and 2 means 5x5 extent_v = 2, ^- Determines the collision box extent in y direction. Defaults to 2 (=3). ^- The actual bounding box size is extent_v+1, so 0 means 1, 1 means 2, 2 means 3 a.s.o. horn_sound = , ^- The sound file of the horn. If none is specified, this wagon can't sound a horn. The specified sound file will be looped. drops = {"default:steelblock 3"} ^- List of itemstrings what to drop when the wagon is destroyed has_inventory = false ^- If this wagon has an inventory. The inventory is saved with the wagon. ^- the following settings are ignored if not. inventory_list_sizes = { box=8*6, }, ^- List of assignments of type list_name=size. ^- For every entry, an inventory list is created with the specified size. get_inventory_formspec = function(self, player_name, inventory_name) return "" end, ^- Function that should return the formspec to be displayed when requests to open the wagon's inventory. ^- advtrains.standard_inventory_formspec can be used for ordinary wagons with inventories to show ^- both the inventory grid and a 'Wagon properties' button. ^- Use "list["..inventory_name..";;,;,;]" to display a wagon's inventory list. custom_on_step = function(self, dtime) end ^- optional: Execute custom code on every step custom_on_activate = function(self, dt-- 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(