Forged Alliance Forever Forged Alliance Forever Forums 2018-02-09T00:07:56+02:00 /feed.php?f=41&t=15861 2018-02-09T00:07:56+02:00 2018-02-09T00:07:56+02:00 /viewtopic.php?t=15861&p=160665#p160665 <![CDATA[Re: Veterancy buff for LifeBarSize]]> http://supcom.wikia.com/wiki/Lua

And a basic LUA beginner guide:
https://www.lua.org/pil/1.html

And a FTP server with about 500 SupCom mods.
You will find many examples for everything here:
http://viking.gurut.org/Mods/

And another Mod FTP. Almost the same mods as above, just as backup:
http://gpgnet.obliteratingwave.co.uk/Va ... dual-Mods/

Statistics: Posted by Uveso — 09 Feb 2018, 00:07


]]>
2018-02-08T23:24:08+02:00 2018-02-08T23:24:08+02:00 /viewtopic.php?t=15861&p=160664#p160664 <![CDATA[Re: Veterancy buff for LifeBarSize]]>
Do you know of a good beginner's guide/resource for setting up overlays and if/then statements in Lua? These are the biggest sticking points for me, and I'm having to learn based on what I'm seeing in other mods but it's not giving me a proper understanding of these tools.

Statistics: Posted by dippydoop — 08 Feb 2018, 23:24


]]>
2018-02-08T05:04:08+02:00 2018-02-08T05:04:08+02:00 /viewtopic.php?t=15861&p=160645#p160645 <![CDATA[Re: Veterancy buff for LifeBarSize]]>
Make a file like DippyUtilities.lua and import the functions to unit.lua from there.

Lets say you have a function called HelloWorld() and a function GodByeWorld() inside your DippyUtilities.lua.

Then import it to the unit.lua file with this:
local DippyFunctions = import('/mods/yourmodname/DippyUtilities.lua')

Now you can call your functions with:
DippyFunctions.HelloWorld()
DippyFunctions.GodByeWorld()

you can also import functions directly with:
local HelloWorld= import('/mods/yourmodname/DippyUtilities.lua').HelloWorld

Btw, i am using a special LOG line for debugging:
LOG('* Debug: ['..string.gsub(debug.getinfo(1).source, ".*\\(.*.lua)", "%1")..', line:'..debug.getinfo(1).currentline..'] - Debugtext bla blub')

This will print the lua-filename and line-number with your debugtext to the LOG window. (game.log)

Statistics: Posted by Uveso — 08 Feb 2018, 05:04


]]>
2018-02-07T17:38:19+02:00 2018-02-07T17:38:19+02:00 /viewtopic.php?t=15861&p=160623#p160623 <![CDATA[Re: Veterancy buff for LifeBarSize]]>
Looking at the Idle Engineers mod (looking at how overlays work), it seems to have several different functions for creating, updating and removing overlays. Would I be correct in assuming I'd have to make a separate file with similar functions (instead relating to the veterancy system), then have the Unit.lua file pointed towards that, and have said functions referred to in the SetVeteranLevel function?

That sounded clearer in my mind.

Statistics: Posted by dippydoop — 07 Feb 2018, 17:38


]]>
2018-02-07T07:20:36+02:00 2018-02-07T07:20:36+02:00 /viewtopic.php?t=15861&p=160582#p160582 <![CDATA[Re: Veterancy buff for LifeBarSize]]>
"Self" is the unit that has a levelup, and "level" is the actual veterancy level.

To connect 2 strings together you can use in LUA 2 dots: "String1..String2"

So, if you write
Code:
'Veteran Level '..level
you will get the string 'Veteran Level 1'.

Just test it. I bet, when you see the result, you instantly know how it's working ;)

[Edit] Woops, i answered this before reading the next post from Franck83 ^^

Statistics: Posted by Uveso — 07 Feb 2018, 07:20


]]>
2018-02-07T00:29:41+02:00 2018-02-07T00:29:41+02:00 /viewtopic.php?t=15861&p=160574#p160574 <![CDATA[Re: Veterancy buff for LifeBarSize]]>
Franck83 wrote:
It's lua text concatenate system. You get level (variable number) then add it to the text 'Veteran level '.

So if you are 3* veteran, it will show your name : 'Veteran Level 3'


Thanks, I understand now.

I've managed to successfully put Uveso's code into the mod's existing Unit.lua file, and it works. I'll have to see if I can make it work with the overlays system, next. After that, make it so that it only displays for units over a given level.

Statistics: Posted by dippydoop — 07 Feb 2018, 00:29


]]>
2018-02-06T22:57:01+02:00 2018-02-06T22:57:01+02:00 /viewtopic.php?t=15861&p=160569#p160569 <![CDATA[Re: Veterancy buff for LifeBarSize]]>
So if you are 3* veteran, it will show your name : 'Veteran Level 3'

Statistics: Posted by Franck83 — 06 Feb 2018, 22:57


]]>
2018-02-06T22:30:40+02:00 2018-02-06T22:30:40+02:00 /viewtopic.php?t=15861&p=160567#p160567 <![CDATA[Re: Veterancy buff for LifeBarSize]]>
Could you explain this line a bit more, please?
Uveso wrote:
Code:
        self:SetCustomName('Veteran Level '..level)



I get that we're setting a new name for the unit as 'Veteran Level', but what does the "..level" part do? Is it an argument of some kind?

Statistics: Posted by dippydoop — 06 Feb 2018, 22:30


]]>
2018-02-06T19:45:12+02:00 2018-02-06T19:45:12+02:00 /viewtopic.php?t=15861&p=160549#p160549 <![CDATA[Re: Veterancy buff for LifeBarSize]]>
create a blank file inside your mod:
Code:
\YourMod\lua\sim\Unit.lua

and paste this into the file:

Code:
-- Save the original Unit class
local oldUnit = Unit

-- Crate a new unitclass with all functions from the old Unitclass
Unit = Class(oldUnit) {

    -- Noe we are overwriting the original SetVeteranLevel  function.
    SetVeteranLevel = function(self, level)

        -- first lets call the old original SetVeteranLevel function.
        oldUnit.SetVeteranLevel(self, level)

        -- now we can add our own stuff
        -- Maybe add a Name to the unit with Vetaran Level:
        self:SetCustomName('Veteran Level '..level)
    end,

}


This way you have an non destructive hook, and it will work also after FAF updates.

Statistics: Posted by Uveso — 06 Feb 2018, 19:45


]]>
2018-02-06T19:26:54+02:00 2018-02-06T19:26:54+02:00 /viewtopic.php?t=15861&p=160545#p160545 <![CDATA[Re: Veterancy buff for LifeBarSize]]>
dippydoop wrote:
I'd need some kind of function to pull the veteran level from all units


Please no :)

In older days we used a programmroutine/thread to scann every unit for a single variable.

But now we are using events ^^.

Take a look into the file:
Code:
\lua\sim\Unit.lua


and search for:

SetVeteranLevel = function(self, level)


There you can add your function to do something at a higher veteran level.

Maybe for testing, giving the unit a unitname with self:SetCustomName('I am a veteran!')

Statistics: Posted by Uveso — 06 Feb 2018, 19:26


]]>
2018-02-06T15:58:03+02:00 2018-02-06T15:58:03+02:00 /viewtopic.php?t=15861&p=160526#p160526 <![CDATA[Re: Veterancy buff for LifeBarSize]]> I'd need some kind of function to pull the veteran level from all units, then apply a particular bitmap at certain milestones (perhaps the stock veterancy icons could be used for that).
Perhaps a less performance-intensive way would be to run the check upon levelup, but I'm not sure if that would come with its own problems, like in the removal of overlays upon unit death.

Statistics: Posted by dippydoop — 06 Feb 2018, 15:58


]]>
2018-02-06T12:29:01+02:00 2018-02-06T12:29:01+02:00 /viewtopic.php?t=15861&p=160522#p160522 <![CDATA[Re: Veterancy buff for LifeBarSize]]>
If you want to mod, i recommend you to install Notepad++ or a software of this kind. There are search functions that are very useful.

So you can type 'Overlays' to access to all FAF files about it.

Image

Statistics: Posted by Franck83 — 06 Feb 2018, 12:29


]]>
2018-02-05T20:48:59+02:00 2018-02-05T20:48:59+02:00 /viewtopic.php?t=15861&p=160501#p160501 <![CDATA[Re: Veterancy buff for LifeBarSize]]>
I don't suppose you know a good resource to prime me on overlays, do you?

Statistics: Posted by dippydoop — 05 Feb 2018, 20:48


]]>
2018-02-05T19:15:29+02:00 2018-02-05T19:15:29+02:00 /viewtopic.php?t=15861&p=160486#p160486 <![CDATA[Re: Veterancy buff for LifeBarSize]]>
is unit:SetLifeBarSize(val) an effective command ? Don't know, maybe but never seen before.

What you want to do is a UI thing not a sim one.

Overlays will grants you much more control and option with what you want to do. Maybe some dev can give you more info on overlays use.

Statistics: Posted by Franck83 — 05 Feb 2018, 19:15


]]>
2018-02-05T19:09:01+02:00 2018-02-05T19:09:01+02:00 /viewtopic.php?t=15861&p=160485#p160485 <![CDATA[Re: Veterancy buff for LifeBarSize]]> I was getting the impression that I was missing something; is there no way of adding a new affect? It seems all it would have to do is pull an existing value from a blueprint file, modify it, then set the modified value as the new value for that unit.

Thanks for the idea, I've downloaded the mod you suggested. It seems like there's potential there, but it will take me a while to poke through it and understand what's going on.

Statistics: Posted by dippydoop — 05 Feb 2018, 19:09


]]>