Community Forum

Load a mod

Forum Overview >> Farming Simulator 2009

CategoryFarming Simulator 2009
Created08.01.2010 21:52

Andrew Asche (unknown) 08.01.2010 21:53
Is it possible to load a full mod into the game via script? I see how to add basic i3d files, however that is not what I want.

Basically for debugging purposes, I want to be able to create (and destroy, if that's also possible) full mods without having to use the store.


Stefan Geiger - GIANTS Software 01.02.2010 12:03
You can use the function mission.loadVehicle

local vehicle = g_currentMission:loadVehicle(xmlFilename, xPos, yOffsetToTerrain, zPos, yRot, isSavedToSavegame);

xmlFilename needs to be either a absolute path or a realtive path to the game.exe.
To create the absolute path to a mod you can use

isSavedToSavegame is a boolean denoting of the vehicle is saved to the savegame. Normally this will be true, however for example for the ai traffic cars, this is false.

The returned value directly points to the class instance of the mod. E.g. if you load a trailer with this function, you can call vehicle:setFillLevel(15000, FruitUtil.FRUITTYPE_WHEAT);
to fill the trailer with 15000 liters of wheat.

Milan Lekše (unknown) 12.09.2012 21:06
OK I understand this load vehicle but having trouble to determinate angle - yRot

How to get yRot dependent to the vehicle so the new 'vehicle' will be pararel to one in game no mather to the angle of terrain?
Tried so may things but yust cen't figure it out, new 'vehicle' loads near one in game but never the same direction??

Stefan please help

Thanks and have a nice day :)

Milan Lekše (unknown) 13.09.2012 15:02
after 4 days and lot's of test found solution :))

local ax,ay,az = localDirectionToWorld(self.components[1].node, 0, 0, 1);
local length = Utils.vector2Length(ax,az);
local yRot= math.deg(math.atan2(az/length,ax/length)) * -1
while (yRot> 359.999999) do
yRot= yRot- 360.0;
while (yRot< 0.0) do
yRot= yRot+ 360.0;
yRot= math.rad(yRot)

this script get the rotation of your vehicle, and when you load new vehicle, new wan has the same direction like your's

Note: Log in to post. Create a new account here.