Avoiding Function Overflow Crash

Everything about mods can be found here.

Moderator: Morax

Avoiding Function Overflow Crash

Postby RavenCurow » 26 Aug 2016, 13:29

I appologize for all the threads asking for help guys, but I tend to mod a lot and if I can't figure something out on my own I figure its best to ask around.

This time around I'm looking at functions. I'm trying to call an OnImpact function in a projectile script, but the base faction projectiles lua already has the OnImpact script. Is there a way I can add on to that function in my script without having to do a round about hook? The effect I want to add to the projectile is not one I want every unit who uses the base projectile to have.
RavenCurow
Avatar-of-War
 
Posts: 98
Joined: 30 Oct 2014, 01:17
Has liked: 1 time
Been liked: 14 times
FAF User Name: RavenCurow

Re: Avoiding Function Overflow Crash

Postby Exotic_Retard » 26 Aug 2016, 13:35

since scripts are combined at runtime you just need to ensure that the original function runs:
for example in this mml missile script:

Code: Select all
SIFLaanseTacticalMissile01EQ = Class(SLaanseTacticalMissile) {
   
    OnCreate = function(self)
        SLaanseTacticalMissile.OnCreate(self)
        self:SetCollisionShape('Sphere', 0, 0, 0, 2)
        self.MoveThread = self:ForkThread(self.MovementThread)
    end,
}
*rest of code snipped*

we have the OnCreate and in there we have some extra stuff we want to do but first we call the original OnCreate by referring to the class of the projectile SLaanseTacticalMissile
Code: Select all
        SLaanseTacticalMissile.OnCreate(self)


is the line. you want to think about where you put that. sometimes you want the original code to run before, sometimes after.


hope that this is what you wanted to know
User avatar
Exotic_Retard
Contributor
 
Posts: 1470
Joined: 21 Mar 2013, 22:51
Has liked: 557 times
Been liked: 626 times
FAF User Name: Exotic_Retard

Re: Avoiding Function Overflow Crash

Postby RavenCurow » 26 Aug 2016, 14:13

Indeed it was. Thank you.
RavenCurow
Avatar-of-War
 
Posts: 98
Joined: 30 Oct 2014, 01:17
Has liked: 1 time
Been liked: 14 times
FAF User Name: RavenCurow

Re: Avoiding Function Overflow Crash

Postby RocketRooster » 26 Aug 2016, 14:30

I keep seeing "Slaaneshi Tactical Missile". I'm a dirty old man.
RocketRooster
Avatar-of-War
 
Posts: 294
Joined: 08 Apr 2016, 11:29
Has liked: 29 times
Been liked: 52 times
FAF User Name: RocketRooster


Return to Mods & Tools

Who is online

Users browsing this forum: No registered users and 1 guest