Page 1 of 1

Scripting related question

Posted: Tue Jul 25, 2006 10:00 pm
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?

RE: Scripting related question

Posted: Tue Jul 25, 2006 10:16 pm
by xwingguy
If airlock1 ain't the name of the cp nothing will work.

RE: Scripting related question

Posted: Tue Jul 25, 2006 11:12 pm
by [RDH]Zerted
All the callbacks work, you just have to get the syntax and data types correct.

RE: Scripting related question

Posted: Tue Jul 25, 2006 11:27 pm
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.

RE: Scripting related question

Posted: Tue Jul 25, 2006 11:57 pm
by xwingguy
post the function airlockfill()

RE: Scripting related question

Posted: Wed Jul 26, 2006 1:28 am
by Astute
function airlockfill()
PlayAnimation("rise1");
end

Well, thats it. I know it works because i've tested it on a working callback(onobjectkillname)

RE: Scripting related question

Posted: Wed Jul 26, 2006 11:29 pm
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?

RE: Scripting related question

Posted: Wed Jul 26, 2006 11:40 pm
by xwingguy
OnTimerElapseName() doesn't exist

it's just

OnTimerElapse()

RE: Scripting related question

Posted: Wed Jul 26, 2006 11:45 pm
by Astute
How is the timer formated then? I don't really see any good examples in the official luas.

RE: Scripting related question

Posted: Wed Jul 26, 2006 11:48 pm
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.

RE: Scripting related question

Posted: Wed Jul 26, 2006 11:58 pm
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.

RE: Scripting related question

Posted: Thu Jul 27, 2006 12:00 am
by xwingguy
just do it the way I posted it.

RE: Scripting related question

Posted: Thu Jul 27, 2006 12:22 am
by Astute
lol, yeah. Btw, thx, it worked. Now I can finally get back to modding instead of grappling with annoying errors.