A mod for adding Trailers to factorio
The main focus of this mod was to add a way to manage and control trailers for vehicles to factorio, although there is a stock trailer provided it should be a simple matter for other modders to create trailers and simply link in this interface to control them
latest version roadtrain1.0.1
- allows vehicles to tow trailers
To use:
-Hop into a vehicle designated as a towing vehicle and a 3 button interface will appear in the top left:
-- click attach to connect a trailer within range of the rear of the vehicle or vehicle train
-- click detach to disconnect the last trailer from the vehicle or vehicle train
-- click detach all to disconnect all trailers in the train from each other and the lead vehicle
-By default this mod is set to allow the car to tow and adds a "stock" trailer
-Trying to enter a non-drivable vehicle will cause to to leave the vehicle
- Trying to enter a vehicle that is not the lead vehicle in the train will force the player into the lead vehicle
-If you install the bulldozer mod then the car is disabled as a towing vehicle and the bulldozer is added as one.
-you can Specify which vehicles are allowed to tow by adding the vehicle name to the whitelist "towbar" located in the config.lua (dont forget the commas)
example
Code: Select all
change the line
towbar={["car"]=true,["trailer"] = true}
to
towbar={["car"]=true,["trailer"] = true,["tank"]=true}
will allow the tank to tow trailers
Code: Select all
change the line
towable={["trailer"] = true}
to
towable{["trailer"] = true,["tank"]=true}
will allow the other vehicles (on the towbar list) to tow the tank
Code: Select all
change the line
trailer={["trailer"] = true}
to
trailer{["trailer"] = true,["tank"]=true}
tanks will no longer be drive-able and act as trailers only (thats just silly)
Code: Select all
usestock=true
Code: Select all
usestock=false
Multi-player untested
TO DO
- better texture pack for the trailer
- collision detection for towed vehicles
- proper articulation (or better follow script) for trailers
At the moment this is a working release, it can however use a lot of work. In particular I could use some help with the following things
- texture pack for stock trailer (cause I clearly suck at drawing), not terribly urgent as other modder's can create their own trailers while the main focus of this mod is a way to control those trailers.
- collision detection for towed vehicles. Currently the only way i could find for "towing" a vehicle was to use the .teleport(pos) method to move the towed objects with the driven object this of course bypasses all the games built in collision detection and the math involved in detecting and reacting to those collision is a little beyond me and probably not so useful until the trailer follow scripts can be updated to be more realistic
-proper articulation for trailers or at the very least a better algorithm to calculate how they should behave when following the towing vehicle. once again the math involved in this is a little beyond me at the moment so any help would be appreciated
Please post any bug reports, feature requests, balance suggestions, updates etc to my GitHub https://github.com/Cheata/roadtrain
Modders who want to add this mod to their packs or create there own trailers using this control interface heres what you need to know
- There is a remote interface for this mod it can be checked for using
Code: Select all
remote.interfaces["roadtrain"]
Code: Select all
settowbar(vehicle.name,true/false) -- method settowbar takes 2 varibles the name of the vehicle(Lua/entity) and true to indicate it can tow or false to indicate it can't. no return variable
Code: Select all
settowable(vehicle.name,true/false) -- method settowable takes 2 varibles the name of the vehicle(Lua/entity) and true to indicate it can be towed or false to indicate it can't. no return variable
Code: Select all
settrailer(vehicle.name,true/false) -- method setrailer takes 2 varibles the name of the vehicle(Lua/entity) and true to indicate it is a trailer (and cant be driven) or false to indicate it isn't (can be driven). no return variable
Code: Select all
addtocargo(vehicle,item,count) -- method addtocargo takes 3 varibles, the vehicle(Lua/entity) , the item being added to the inventory, and the number of that item. true is returned if the addition was successful, false if not
I would also recommend adding
Code: Select all
? "roadtrain" > 1.0.0
or
"roadtrain" > 1.0.0
When creating your own trailers please keep in mind the following
- At the moment all trailers must be of type="car"
- The distance the trailer sits from the vehicle is hard coded for the time being so making your trailer collision area too large will cause the towing vehicle to "get stuck"
- The above point also means that different sized textures will not necessarily look as intended (i.e. may have large gaps between vehicle and trailer or overlap) it is recommended that you build your trailer as it should look not to match how it will look in this mod, eventually the towing distance will hopefully be determined by the texture size and render correctly. So if you build your texture packs to look correct under the current version they may not look right under later versions
phew thats a lot of info
enjoy