Trying to understand the LUA

Talk about general things concerning Forged Alliance Forever.

Moderators: FtXCommando, Ze Dogfather

Trying to understand the LUA

Postby ConditionZero » 17 Jul 2020, 01:03

Some attributes have "New" in front of them, some don't. Does this add to the existing value, or replace it?

Example:
Code: Select all
FocusConvertor = {
            BuildCostEnergy = 24000,
            BuildCostMass = 800,
            BuildTime = 3000,
            Icon = 'fc',
            Name = '<LOC enhancements_0093>Disintegrator Amplifier',
            NewDamageMod = 200,
            NewMaxRadius = 35,
            Slot = 'RCH',
            UpgradeUnitAmbientBones = {
                'URL0301',
            },
ConditionZero
Crusader
 
Posts: 19
Joined: 02 Jun 2020, 00:14
Has liked: 2 times
Been liked: 2 times
FAF User Name: ConditionZero

Re: Trying to understand the LUA

Postby Sprouto » 17 Jul 2020, 01:13

This can be very subjective - this is not LUA code - but data - and is meant to be acted upon by some actual code.

What you're looking at here is the data for an enhancement - some values are well understood, Energy, Mass and Time - and of course, the name of the Enhancement. The slot, on the unit, that must be available and open - and the bone, on the model, that the enhancement effect will be attached to while it is happening.

The others, NewDamageMod and NewMaxRadius, mean nothing on their own, but it's likely that the enhancement code is looking for these specific values. However, you cannot tell from here whether the values will add to, replace, or do anything at all - for that - you'll need to find the Enhancement code, which might be partially located in the units' script file, or the general enhancement functions located in the core code.
Sprouto
Priest
 
Posts: 366
Joined: 08 Sep 2012, 05:40
Has liked: 54 times
Been liked: 74 times
FAF User Name: Sprouto

Re: Trying to understand the LUA

Postby Turinturambar » 17 Jul 2020, 10:05

Most of these things are specified by the game already and you can find a list of what those things mean here https://supcom.fandom.com/wiki/Blueprint .
The other ones you often will find specified in the script file of the unit (you have the _unit file which is the blueprint and the scriptfile. in the scripfile things like what a new upgrade does etc. are specified. there e.g. sth like NewDamageMod is used and from the way its used there you can see what it does (e.g. the new dmg mod could be added on old dmg or replace old dmg). if you dont find a scrip file in the unit folder that doesnt mean its not there, it means you have to go to the folder where fa is installed for you (steam I guess) and get the script file from there.
Turinturambar
Avatar-of-War
 
Posts: 288
Joined: 01 Jul 2015, 20:38
Has liked: 1 time
Been liked: 91 times
FAF User Name: 竜宮レナ

Re: Trying to understand the LUA

Postby Uveso » 17 Jul 2020, 17:40

ConditionZero wrote:Some attributes have "New" in front of them, some don't. Does this add to the existing value, or replace it?


They replace the original value.

NewDamageMod:

NewDamageMod is used in UAL0301_script.lua for the StabilitySuppressan:
https://github.com/FAForever/fa/blob/develop/units/UAL0301/UAL0301_script.lua#L136
https://github.com/FAForever/fa/blob/develop/units/UAL0301/UAL0301_script.lua#L141

and its used inside URL0301_script.lua for the FocusConvertor:
https://github.com/FAForever/fa/blob/develop/units/URL0301/URL0301_script.lua#L186
https://github.com/FAForever/fa/blob/develop/units/URL0301/URL0301_script.lua#L190


NewMaxRadius:

NewMaxRadius is used inside Blueprints.lua
https://github.com/FAForever/fa/blob/develop/lua/system/Blueprints.lua#L553

and in several other unit scripts:

UAL0001_script.lua
UAL0301_script.lua
UEL0001_script.lua
UEL0301_script.lua
URL0001_script.lua
URL0301_script.lua
XSL0001_script.lua
XSL0301_script.lua
Here is the unitfolder if you want to look at the unitcode:
https://github.com/FAForever/fa/tree/develop/units
User avatar
Uveso
Supreme Commander
 
Posts: 1788
Joined: 11 Dec 2015, 20:56
Location: Germany
Has liked: 70 times
Been liked: 291 times
FAF User Name: Uveso

Re: Trying to understand the LUA

Postby ConditionZero » 17 Jul 2020, 20:03

Thank you everyone. I'll have to delve a bit deeper i suppose.
ConditionZero
Crusader
 
Posts: 19
Joined: 02 Jun 2020, 00:14
Has liked: 2 times
Been liked: 2 times
FAF User Name: ConditionZero

Re: Trying to understand the LUA

Postby ConditionZero » 17 Jul 2020, 20:10

I see now. The damage is fixed with a modifier added. Where as the Range has no modifier and is directly changed.

Thank you again for directing me.
ConditionZero
Crusader
 
Posts: 19
Joined: 02 Jun 2020, 00:14
Has liked: 2 times
Been liked: 2 times
FAF User Name: ConditionZero


Return to General Discussions

Who is online

Users browsing this forum: Google [Bot] and 1 guest