Community Forum

LUA Mod Scripting - question

Forum Overview >> Scripting

CategoryScripting
Created18.03.2020 20:06


Paul Oberosler (pavll) 18.03.2020 20:06
Can somebody tell me where i can find a documentation about all functions extended to "self" like "self:isActive()"?

And eventually where to find information about i think global vars like "g_currentMission"?

Bilbo Beutlin (BBeutlin) 18.03.2020 21:21
What did I tell you in other post short time ago? At first learn LUA basics. I can't imagine that you did this within 1-2 hours.

The 'self' construct is not FS specific. It is a basic term in LUA. You need to understand what it means. So read the tutorials.

For references to the FS functions see (here on GDN) Documentation -> Scripting API Reference (LUADOC)

You'll often find things like the "g_currentMission" table not documented anywhere (officially).
Most stuff you must find out yourself by examining the table contents. Nearly all variables in tables have names which explain the usage (at least halfways).

Paul Oberosler (pavll) 22.03.2020 12:04
OK, sorry. I've thought that there is somewhere docs where i can find the fs19 added gloabal variables. And with infos about self i meant for example if i code this:

SomeMod = {}
local SomeMod_mt = Class(SomeMod)

fuction SomeMod:new() {
local self = {}
setmetatable(self, SomeMod_mt)
self.spec_drivable -- where was this spec added? with Class() function? Where can i see which things Class add?
}

Bilbo Beutlin (BBeutlin) 22.03.2020 16:41
The "Class()" function simply registers the object as new class.
The so-called "metatable" is an auxiliary table where important basic variables become initialized.
The "self.spec_drivable" is nothing else than a declaration/definition of a variable in the "self" array/table. In LUA (like in most other languages) variables must be declared first before usage/access, else it will result in "nil".

Paul Oberosler (pavll) 22.03.2020 17:26
Ok, but this was not what i've meant. For example, i searched for a method how i can check the rotation of the steering wheel of the drivable vehicle which is currently in use by a player. So i searched in other plugins where i've found out that i can get this by:

local _, steeringRotationY, _ = getRotation(self.spec_drivable.steeringWheel.node)

That was just an example. So can you help me: Where can I get answers to similar questions? Any idea?.

Bilbo Beutlin (BBeutlin) 22.03.2020 17:45
It's quite trivial. The variable prefix "spec_" was introduced to make things more clear and consistent.
Now you need only look under the associated specialization LUA code for assignment and meaning of a variable.
Also debugging becomes easier if you have identifiable different subtables sorted by themes.


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