Basic Mod Questions

Everything about mods can be found here.

Moderator: Morax

Re: Basic Mod Questions

Postby Franck83 » 12 Oct 2018, 00:59

Once you are playing a game, Ctrl + F10 restart it. The tip is that you can mod your lua file, save it, then click Ctrl F10 to test changes.
Last edited by Franck83 on 12 Oct 2018, 12:44, edited 1 time in total.
Alliance of Heroes Mod is out ! Try it ! It's in the Mod Vault !
User avatar
Franck83
Evaluator
 
Posts: 538
Joined: 30 Dec 2016, 11:59
Location: France
Has liked: 114 times
Been liked: 122 times
FAF User Name: Franck83

Re: Basic Mod Questions

Postby Crazy Cossack » 12 Oct 2018, 04:18

That is all good information thanks people. :)
Crazy Cossack
Avatar-of-War
 
Posts: 53
Joined: 13 Mar 2013, 12:44
Has liked: 0 time
Been liked: 9 times
FAF User Name: Crazy_Cossack

Re: Basic Mod Questions

Postby Uveso » 12 Oct 2018, 13:42

copy from:
viewtopic.php?f=41&t=12970&start=10

You can also force the debugwindow to show up while gamestart:

Please Make a desktop-shortcut from the file:
C:\ProgramData\FAForever\bin\ForgedAlliance.exe
(Rightclick the file and select "Send to" -> Desktop Shortcut")

Open the shortcut and change the Command line (target):
from:
C:\ProgramData\FAForever\bin\ForgedAlliance.exe
to:
C:\ProgramData\FAForever\bin\ForgedAlliance.exe /init init_faf.lua /EnableDiskWatch /log C:\game.log /showlog

commandline explanation:
"/init init_faf.lua" this will start the normal FAF version of the game. Change this to "/init init_fafbeta.lua" and you will start the beta version of FAF
"/EnableDiskWatch" with this you can change unit or game files and the game will immediately load and execute the new changes. You dont need to restart the game.
"/log C:\game.log" will force to write the game.log at c:\ root dir.
"/showlog" displays the Debug Window (Shows the same what you can find inside the game.log)

[Edit] you should read the full topic from viewtopic.php?f=41&t=12970
There are many hints for start modding.
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: Basic Mod Questions

Postby Crazy Cossack » 13 Oct 2018, 02:47

Okay I know how to do this sort of thing in my blueprints.lua.

Spoiler: show
-- Mexes T1

if bp.BlueprintId == 'ueb1103'
or bp.BlueprintId == 'uab1103'
or bp.BlueprintId == 'urb1103'
or bp.BlueprintId == 'xsb1103' then
if bp.Defense.Health then
bp.Defense.Health = 1000
end
if bp.Defense.MaxHealth then
bp.Defense.MaxHealth = 1000
end
if bp.Economy.MaintenanceConsumptionPerSecondEnergy then
bp.Economy.MaintenanceConsumptionPerSecondEnergy = 4
end
end -- end Mexes T1


That means that I know how to change parameter values in blueprint files and nothing else. I am learning from a very low base of knowledge. (Ignore the precise changes to the T1 mexes, it's just a test mod.)

The next thing I feel I need to learn is how to control what an engineer or ACU or factory can make i.e their build capabilities. What is the simplest and most elegant way to do that (to add or subtract to the list of what they can make)?

Because my knowledge base is low, I first have to learn by "monkey see - monkey do" techniques. As I put more items together, I will start to understand the overall language (LUA) and the folder and file structures of FAF. I hope. :)

To put my poor programming knowledge in context, I taught myself Basic and Turbo Pascal many years ago. I wrote a chess program with basic AI in Turbo Pascal. It had 2 move look-ahead (4 ply search) with a minimax algorithm. I modded Cossacks 3 for the last few years (mainly a parameters mod but it had some other aspects). Cossacks 3 uses object Pascal in its very large and messy scripts and full destructive hooking at the whole of file level, handled by their simple mod manager. So, change one parameter in a huge file (thousands of lines) and you had to overwrite that whole file on load. Then when the developers changed/inserted a hundred lines in that file (all over the place) for a patch it usually broke my mod and I had to do a file compare and merge on that file. This could happen to multiple files at patch time. Due to this and other issues with Cossacks 3 I gave up modding and playing it. It has a very poor game engine anyway.

I understand arrays but not classes and objects so that is a problem area with my knowledge. And of course, I have no idea where stuff is in all the different FAF files. LUA syntax is a bit different too. Some stuff seems case sensitive. There are no markers at end lines like (;) and the "if-then" statement needs an "end" statement (probably because there is no end line character like (;)). Also, "==" seems to mean "equal to" and "=" apparently means "becomes equal to" which other languages express as ":=".

A link to a syntax guide would be great. I'll start searching on the net too.
Crazy Cossack
Avatar-of-War
 
Posts: 53
Joined: 13 Mar 2013, 12:44
Has liked: 0 time
Been liked: 9 times
FAF User Name: Crazy_Cossack

Re: Basic Mod Questions

Postby speed2 » 13 Oct 2018, 08:17

User avatar
speed2
Contributor
 
Posts: 3189
Joined: 05 Jan 2013, 15:11
Has liked: 636 times
Been liked: 1119 times
FAF User Name: speed2

Re: Basic Mod Questions

Postby Franck83 » 13 Oct 2018, 18:08

Crazy Cossack wrote:That means that I know how to change parameter values in blueprint files and nothing else.


Modding Blueprints.lua acts as : individual unit lua -----> blueprints.lua (you current hook) ----> Mod execution.


But, you can change values directly in individual unit bp too.

First so you need to copy and modify unit from the .nx2. rename the nx2 as a zip file and unpack it.
Image


Then Copy and hook the files needed (here in my Alliance of Heroes mod, UAL001 Aeon ACU) :
Image



Now you can have access to a huge amount of individual data you can change :

In the bp :
Image

This is a link to understand values and data : http://supcom.wikia.com/wiki/Blueprint


And in the individual script dealing with building restriction (as you requested) (Here AEON ACU enhancements T2-T3)
Image


About lua programming, don't be afraid, it's easy to understand and to learn if you proceed step by step. Just keep a look on existing code, and try to understand.

You can always ask on this forum for help.
Alliance of Heroes Mod is out ! Try it ! It's in the Mod Vault !
User avatar
Franck83
Evaluator
 
Posts: 538
Joined: 30 Dec 2016, 11:59
Location: France
Has liked: 114 times
Been liked: 122 times
FAF User Name: Franck83

Re: Basic Mod Questions

Postby Crazy Cossack » 13 Oct 2018, 22:19

Franck83,

I don't know how to hook a whole file yet. I am probably overlooking something obvious.

With the current method I know how to change basic parameters (numeric values attached to variables). My next step is to learn how to delete or insert entries into tables. However, I can't get table.insert to work yet. I have tried to use this code to make the T1 radar, in its blueprint file, build-able by the T1 ACU Commander but the code does not seem to work. There may be something else I need to do?

Spoiler: show
-- Radar T1

if bp.BlueprintId == 'ueb3101'
or bp.BlueprintId == 'uab3101'
or bp.BlueprintId == 'urb3101'
or bp.BlueprintId == 'xsb3101' then
if bp.Defense.Health then
bp.Defense.Health = 100
end
if bp.Defense.MaxHealth then
bp.Defense.MaxHealth = 100
end
if bp.Categories then
table.insert(bp.Categories, 'BUILTBYCOMMANDER')
end;
-- table.remove(bp.Categories, 5)
end -- end Radar T1



If I remove the 3 lines to make it buildable and test that table.remove command then that works. I can for example take away the ability of a T2 ACU to make a T1 radar. These are just experiments to learn LUA. I have no real idea what will happen in my mod yet.

But I figure my first two steps are;

(a) learn how to change numeric parameters; (DONE)
(b) learn how to add and subtract unit capabilities by inserting and removing capabilities in list tables. (Still working on it.)

When I want to complexly modify whole files or create new files, I will have to learn how to hook whole files, for sure.
Crazy Cossack
Avatar-of-War
 
Posts: 53
Joined: 13 Mar 2013, 12:44
Has liked: 0 time
Been liked: 9 times
FAF User Name: Crazy_Cossack

Re: Basic Mod Questions

Postby Uveso » 14 Oct 2018, 03:06

Removing a value from a table can be a pain :)

Let's say you want to remove the category 'BUILTBYTIER2ENGINEER' from the blueprint categories array:
Code: Select all
BP.Categories = RemoveItemFromArray('BUILTBYTIER2ENGINEER',BP.Categories)


To make this work, you need to include this function to your script file:
Code: Select all
function RemoveItemFromArray(REMOVEME,ARRAY)
    zold = 1
    while ARRAY[zold] do
        if ARRAY[zold] == REMOVEME then
            table.remove(ARRAY, zold)
        else
            zold = zold + 1
        end
    end
    return ARRAY
end
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: Basic Mod Questions

Postby Crazy Cossack » 14 Oct 2018, 03:42

Actually, this worked (quite simple but one has to know the item one wants removed is in slot 5);

table.remove(bp.Categories, 5)

But the reverse did not work;

table.insert(bp.Categories, 'BUILTBYCOMMANDER')

This didn't work. I was trying to add the radar to the T1 commander's build menu.

Your code for removal will perform better if developers change the relevant category at all. But it's actually adding an item to the build menu that I really want to know how to do. I will keep experimenting but all answers welcomed. :)
Crazy Cossack
Avatar-of-War
 
Posts: 53
Joined: 13 Mar 2013, 12:44
Has liked: 0 time
Been liked: 9 times
FAF User Name: Crazy_Cossack

Re: Basic Mod Questions

Postby Uveso » 14 Oct 2018, 14:16

Crazy Cossack wrote:table.insert(bp.Categories, 'BUILTBYCOMMANDER')

This will enable an unupgraded ACU to build the unit.

If you want to add this to the "T1" commander build tree use this:
Code: Select all
table.insert(bp.Categories, 'BUILTBYTIER1COMMANDER')


These are all 4 commander categories:
Code: Select all
table.insert(bp.Categories, 'BUILTBYCOMMANDER')
table.insert(bp.Categories, 'BUILTBYTIER1COMMANDER')
table.insert(bp.Categories, 'BUILTBYTIER2COMMANDER')
table.insert(bp.Categories, 'BUILTBYTIER3COMMANDER')


If you only use BUILTBYCOMMANDER and you upgrade your ACU, then you can't build the unit any longer.
You need to add also the higher tier commander categories.
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

PreviousNext

Return to Mods & Tools

Who is online

Users browsing this forum: No registered users and 1 guest