Community Forum

How to find out Variable names?

Forum Overview >> Farming Simulator 2011

CategoryFarming Simulator 2011
Created02.11.2010 06:44

Philipp Weber (unknown) 02.11.2010 06:53

i`m new to the LUA scripting.

So my project is, to build some custom gamehardware.

Like a display, that shows up some information, buttons with status leds and axis.

So my first step is the, in my eyes hardest. I have to find out the variables that carry the information.

Is there a list with them?

I have looked at the documentation, but just quick and didn`t found that.

Some variables of interest are:

- Speed
- Status of:
- Light
- Rundumleuchte ( yellow light on the roof, sry i don`t know it in english)
- Is a device mounted or not

And something this way.

My thought were, to write a lua script, that read the variables and write it in a file, that the external program can read it and work with the data.

I hope its understable^^

Best regards

PS.: LS11 is a wonderful game. The only thing that would make it a little bit better would be a dedicated server ;-)

Stefan Geiger - GIANTS Software 02.11.2010 12:18
The current vehicle the player is in, is stored in the variable g_currentMission.controlleVehicle if g_currentMission.controlPlayer == false. Otherwise the player is walking and not driving a vehicle.

From there on you can read the variables of the vehicle (vehicle = g_currentMission.controlleVehicle):
Speed: vehicle.lastSpeed (meter/ms)
RPM: vehicle.motor.lastMotorRpm (you need to check for vehicle.motor ~= nil)
Light: vehicle.lightsActive
Beacon Light (Rundumleuchte): vehicle.beaconLightsActive
Something attached: table.getn(vehicle.attachedImplements) > 0

Philipp Weber (unknown) 02.11.2010 22:23
So I tried it, on the basic on a tutorial for a Display that shows the capacity of a silo. But this were for LS09. I think my problem is the commands have changed. But here it is.

I named it "datentransfer.lua" + "modDesc.xml"
The Mod inits ok, but then stops at row 5 with Nil.
I tested to comment it out but the i push the failure only a few rows further till the next "geschwindigkeit". Did i created the variable "geschwindigkeit" wrong?

print("Datentransfer TEST-Anzeige geladen");

geschindigkeit = {0.0};

function geschwindigkeit:loadMap(name) self.loadedMap = name;

print("map " .. self.loadedMap .. " was loaded");

function geschwindigkeit:deleteMap() print("map " .. self.loadedMap .. " was deleted");

function geschwindigkeit:mouseEvent(posX, posY, isDown, isUp, button)

function geschwindigkeit:keyEvent(unicode, sym, modifier, isDown)

function geschwindigkeit:update(dt)
local geschwindigkeit = Utils.getNoNil(g_currentMission.controlleVehicle[vehicle.lastSpeed],0)
renderText(0.65, 0.97, 0.02,""..string.format("Geschwindigkeit:", geschwindigkeit).."")

function geschwindigkeit:draw()


Andreas GroƟschedl (unknown) 03.11.2010 07:22
1st the var is called g_currentMission.controlledVehicle!

geschwindigkeit = {}; / you forget the w
in the update function you need to declare a new var.
local speed = Utils.getNoNil(g_currentMission.controlledVehicle.lastSpeed,0);
renderText(0.65,0.97,0.02, "Geschwindigkeit: " .. tostring(speed));

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