Scripting related question

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
Astute
Rebel Colonel
Rebel Colonel
Posts: 566
Joined: Tue Apr 12, 2005 7:03 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Scripting related question

Post by Astute »

I've been trying out new functions/callbacks in lua and i've run into some problems. Callbacks such as OnFinishCaptureName do not work, but ones such as OnObjectKillName do. Were the ones that don't work just never added? or is there some kind of syntax i'm missing.

Here is a sample.
OnFinishCaptureName(airlockfill, "airlock1");


Any scripting wizards have a remedy?
xwingguy

RE: Scripting related question

Post by xwingguy »

If airlock1 ain't the name of the cp nothing will work.
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

RE: Scripting related question

Post by [RDH]Zerted »

All the callbacks work, you just have to get the syntax and data types correct.
Astute
Rebel Colonel
Rebel Colonel
Posts: 566
Joined: Tue Apr 12, 2005 7:03 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

RE: Scripting related question

Post by Astute »

Hmm, then it's just very hard to get them to work then. What happens ingame is i capture the cp named "airlock1", but for some reason airlockfill never triggers.
xwingguy

RE: Scripting related question

Post by xwingguy »

post the function airlockfill()
Astute
Rebel Colonel
Rebel Colonel
Posts: 566
Joined: Tue Apr 12, 2005 7:03 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

RE: Scripting related question

Post by Astute »

function airlockfill()
PlayAnimation("rise1");
end

Well, thats it. I know it works because i've tested it on a working callback(onobjectkillname)
Astute
Rebel Colonel
Rebel Colonel
Posts: 566
Joined: Tue Apr 12, 2005 7:03 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

RE: Scripting related question

Post by Astute »

Ok, i was able to get my function working, however now i'm having trouble with timers.

Message Severity: 3
.\Source\LuaHelper.cpp(312)
CallProc failed: (none):0: attempt to call global `OnTimerElapseName' (a nil value)
stack traceback:
(none): in function `ScriptPostLoad'


The scripting for the timer
conquest:Start()

airlock1_timer = CreateTimer("airlock1_timer");
SetTimerValue(airlock1_timer, 5.0);
StartTimer(airlock1_timer);
OnTimerElapseName(airlockfill, "airlock1_timer");

end

function airlockfill()

PlayAnimation("rise1");
SetTimerValue(airlock1_secondary, 5.0);
StartTimer(airlock1_secondary);

end
Very confusing.. but am I defining the timer right?
xwingguy

RE: Scripting related question

Post by xwingguy »

OnTimerElapseName() doesn't exist

it's just

OnTimerElapse()
Astute
Rebel Colonel
Rebel Colonel
Posts: 566
Joined: Tue Apr 12, 2005 7:03 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

RE: Scripting related question

Post by Astute »

How is the timer formated then? I don't really see any good examples in the official luas.
xwingguy

RE: Scripting related question

Post by xwingguy »

OnTimerElapseName(airlockfill, "airlock1_timer");

should be

OnTimerElapse(airlockfill, airlock1_timer);

You should read the campaign scripts, they contain a lot of useful info.
Astute
Rebel Colonel
Rebel Colonel
Posts: 566
Joined: Tue Apr 12, 2005 7:03 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

RE: Scripting related question

Post by Astute »

Yeah, i've read through quite a few of the campaign scripts, but usually they are formated like this.

OnTimerElapse(

function(timer)
StartObjectives()
ScriptCB_EnableCommandPostVO(0)
ScriptCB_SndPlaySound("MYG_obj_01")
ScriptCB_SndPlaySound("MYG_obj_02")
DestroyTimer(timer)
end,

timePop

)

I tried implementing it this way, but all it would do is crash my game. I don't think i've ever seen it formated like the one you suggested anywhere in the campaign files.
xwingguy

RE: Scripting related question

Post by xwingguy »

just do it the way I posted it.
Astute
Rebel Colonel
Rebel Colonel
Posts: 566
Joined: Tue Apr 12, 2005 7:03 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

RE: Scripting related question

Post by Astute »

lol, yeah. Btw, thx, it worked. Now I can finally get back to modding instead of grappling with annoying errors.
Post Reply