Page 1 of 1

I need script help please

Posted: Tue Aug 29, 2006 2:40 am
by Big_rich

Code: Select all

  EnableSPHeroRules()
    BlockPlanningGraphArcs("door1_con")
    SetProperty("gatepanel", "MaxHealth", 1000)
    SetProperty("gatepanel", "CurHealth", 1000)
    SetProperty("gate", "MaxHealth", 12000)
    SetProperty("gate", "CurHealth", 12000)
    OnObjectKillName(PlayAnimDown, "gatepanel");
    OnObjectRespawnName(PlayAnimUp, "gatepanel");
    OnObjectRespawnName(PlayAnimUp, "gate");
    OnObjectKillName(PlayAnimDown1, "gate");
 end

gate = 1

function PlayAnimDown()
    PauseAnimation("thegateup");
    RewindAnimation("thegatedown");
    PlayAnimation("thegatedown");
    --ShowMessageText("level.kas2.objectives.gateopen",1)
    --ScriptCB_SndPlaySound("KAS_obj_13")
    SetProperty("gatepanel", "MaxHealth", 1200)
    UnblockPlanningGraphArcs("door1_con");
    DisableBarriers("door1");
end

function PlayAnimDown1()
    PauseAnimation("thegateup");
    RewindAnimation("thegatedown11");
    PlayAnimation("thegatedown11");
    SetProperty("gatepanel", "MaxHealth", 5000)
    KillObject("gatepanel")
    gate = 0
    --ShowMessageText("level.kas2.objectives.gateopen",1)
    UnblockPlanningGraphArcs("door1_con");
    DisableBarriers("door1");
end

function PlayAnimUp()
    if gate == 1 then
    PauseAnimation("thegatedown");
    RewindAnimation("thegateup");
    PlayAnimation("thegateup");
    SetProperty("gatepanel", "MaxHealth", 1000)
    SetProperty("gatepanel", "CurHealth", 1000)
    SetProperty("gate", "MaxHealth", 12000)
    BlockPlanningGraphArcs("door1_con");
    EnableBarriers("door1");
    else
    RespawnObject("gate")
    PauseAnimation("thegatedown");
    RewindAnimation("thegateup");
    PlayAnimation("thegateup");
    SetProperty("gatepanel", "MaxHealth", 1000)
    SetProperty("gatepanel", "CurHealth", 1000)
    SetProperty("gate", "MaxHealth", 12000)
    BlockPlanningGraphArcs("door1_con");
    EnableBarriers("door1");
end
I'm basically trying to set up the kas gate, with a twist. I want the auctual gate to be able to be destroyed, and when it dies I want the gate panel to go with it. Once the gatepanel get reapaired the gate itself will come back. I keep getting lua errors with the set up above. It's the if and else part that has got me confused. I know it's not set up right. Could someone look and give me a suggestion on how to do it?

Here is the lua. log

Code: Select all

D:\BF2_ModTools\ToolsFL\Bin\luac.exe: ..\..\common\scripts\FI1\FI1g_con.lua:278: `end' expected (to close `function' at line 77) near `<eof>'
ERROR[scriptmunge scripts\FI1\FI1g_con.lua]:Could not read input file.ERROR[scriptmunge scripts\FI1\FI1g_con.lua]:Could not read input file. [continuing]
   2 Errors    0 Warnings

ERROR[levelpack mission\FI1g_con.req]:Expecting bracket, but none was found.
File : munged\pc\fi1g_con.script.req(1)...

ucft <--
ERROR[levelpack mission\FI1g_con.req]:Expecting bracket, but none was found.
File : munged\pc\fi1g_con.script.req(1)...

ucft <--

   2 Errors    0 Warnings


RE: I need script help please

Posted: Tue Aug 29, 2006 3:10 am
by archer01
I see an 'end' for the function, but not for the 'if' statement. Every function and every 'if' statement must have a concluding 'end' statement at the end of the code block (it tells the program that this is the end of the function/if).

Example:

Code: Select all

function()
   if blah then
       stuff
   elseif blah2 then
       more stuff
   elseif blah3 then
       other stuff
   else
       what do you think? stuff!
   end
end
There might be more issues, but I'm a little too tired to go into it any further right now (it's late where I am at the moment). Sorry. Hope that helps a bit though.

RE: I need script help please

Posted: Tue Aug 29, 2006 7:42 am
by Big_rich
cool that was it. thanks