Page 1 of 1

Lua problem

Posted: Fri Feb 20, 2009 9:09 pm
by ryukaji
Im trying to make animated doors but I cant get the lua right:

Code: Select all

C:\BF2_ModTools\ToolsFL\Bin\luac.exe: ..\..\common\scripts\ABC\ABCg_con.lua:48: unexpected symbol near `['
ERROR[scriptmunge scripts\ABC\ABCg_con.lua]:Could not read input file.ERROR[scriptmunge scripts\ABC\ABCg_con.lua]:Could not read input file. [continuing]
   2 Errors    0 Warnings
Hidden/Spoiler:
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--

ScriptCB_DoFile("setup_teams")
ScriptCB_DoFile("ObjectiveConquest")

-- Empire Attacking (attacker is always #1)
local ALL = 2
local IMP = 1
-- These variables do not change
local ATT = 1
local DEF = 2

function ScriptPostLoad()


--This defines the CPs. These need to happen first
cp1 = CommandPost:New{name = "cp1"}
cp2 = CommandPost:New{name = "cp2"}
cp3 = CommandPost:New{name = "cp3"}
cp4 = CommandPost:New{name = "cp4"}



--This sets up the actual objective. This needs to happen after cp's are defined
conquest = ObjectiveConquest:New{teamATT = ATT, teamDEF = DEF,
textATT = "game.modes.con",
textDEF = "game.modes.con2",
multiplayerRules = true}

--This adds the CPs to the objective. This needs to happen after the objective is set up
conquest:AddCommandPost(cp1)
conquest:AddCommandPost(cp2)
conquest:AddCommandPost(cp3)
conquest:AddCommandPost(cp4)

conquest:Start()

EnableSPHeroRules()


end

ActivateRegion("trigger")
testfunction = OnEnterRegion(
function(region, player)
if [whatever callbacks you want] then
PlayAnimationFromTo("doorlow",0,1.2)
PauseAnimation("doorlow")
end
end,
"trigger"
)

ActivateRegion("trigger")
testfunction = OnLeaveRegion(
function(region, player)
if [whatever callbacks you want] then
PlayAnimationFromTo("doorlow",1.2,2.4)
RewindAnimation("doorlow")
PauseAnimation("doorlow")
end
end,
"trigger"
)





---------------------------------------------------------------------------
-- FUNCTION: ScriptInit
-- PURPOSE: This function is only run once
-- INPUT:
-- OUTPUT:
-- NOTES: The name, 'ScriptInit' is a chosen convention, and each
-- mission script must contain a version of this function, as
-- it is called from C to start the mission.
---------------------------------------------------------------------------
These are zeroeditor animations not XSI animated doors

What would I put for the [whatever callbacks you want] part of the script?

Re: Lua problem

Posted: Fri Feb 20, 2009 9:57 pm
by ThePanda
I think you can get rid of those lines completely, unless you want some sort of parameter for the door.

Re: Lua problem

Posted: Fri Feb 20, 2009 10:55 pm
by ryukaji
that didnt work unfortunately

Re: Lua problem

Posted: Sat Feb 21, 2009 9:54 am
by theultimat
You couly try making animated doors a different way, using XSI.

FragMe!'s Door Tutorial for XSI

EDIT:
Also, as far as I know, you need to replace

Code: Select all

[whatever callbacks you want]
with some actaul CallBacks. Could be wrong though...

Re: Lua problem

Posted: Sat Feb 21, 2009 12:47 pm
by ryukaji
theultimat wrote:You couly try making animated doors a different way, using XSI.

FragMe!'s Door Tutorial for XSI

EDIT:
Also, as far as I know, you need to replace

Code: Select all

[whatever callbacks you want]
with some actaul CallBacks. Could be wrong though...
Well yes I know that but i dont know what callbacks to put in or even what callbacks are

And I would use that tutorial if I had full XSI which I dont

Re: Lua problem

Posted: Sat Feb 21, 2009 12:57 pm
by ThePanda
Could try this:
Hidden/Spoiler:
ActivateRegion("trigger")
testfunction = OnEnterRegion(
function(region, player)
PlayAnimationFromTo("doorlow",0,1.2)
PauseAnimation("doorlow")
end,
"trigger"
)

ActivateRegion("trigger")
testfunction = OnLeaveRegion(
function(region, player)
PlayAnimationFromTo("doorlow",1.2,2.4)
RewindAnimation("doorlow")
PauseAnimation("doorlow")
end,
"trigger"
)
(Removed an extra end since the callback wasn't used)
I'm not really even good at LUA, just recently got into practising it over the last couple of months.

Re: Lua problem

Posted: Sat Feb 21, 2009 1:20 pm
by Maveritchell
You need to read the "scripting_system.doc" file in the documentation. It explains what callbacks are and how to use them.

Also you need to not make up lua functions (OnLeaveRegion doesn't exist).

Re: Lua problem

Posted: Sat Feb 21, 2009 2:26 pm
by ryukaji
Maveritchell wrote:You need to read the "scripting_system.doc" file in the documentation. It explains what callbacks are and how to use them.

Also you need to not make up lua functions (OnLeaveRegion doesn't exist).
Yes it does. The very doc you directed me to listed LeaveRegion and EnterRegion and it didnt really explain callbacks for EnterRegion and it didnt make sense to me I read all the docs to do with lua and procedural anims and I cant get the lua right for it still

Re: Lua problem

Posted: Sat Feb 21, 2009 2:57 pm
by Maveritchell
Whoops, you're right. Maybe I could do with rereading the doc.

Anyway, my terminology was probably unclear. Assuming you want everything that enters that region to trigger the door, you don't need the "if" statement at all, and your function could look like this:

Code: Select all

ActivateRegion("trigger")
testfunction = OnEnterRegion(
function(region, player)
PlayAnimationFromTo("doorlow",0,1.2)
PauseAnimation("doorlow")
end,
"trigger"
)
I'm not sure exactly what your ZE animations do, so changing the PlayAnimation (etc.) will be dependent on that.

Re: Lua problem

Posted: Sat Feb 21, 2009 3:30 pm
by ryukaji
Map instantly crashes and the error log says
Hidden/Spoiler:
Opened logfile BFront2.log 2009-02-21 1324
ingame stream movies\crawl.mvs
prev = none iLastPage = nil
prev = texture iLastPage = 1
prev = texture iLastPage = 2
prev = texture iLastPage = 3
prev = texture iLastPage = 4
ifs_legal.Exit

Message Severity: 2
.\Source\GameMovie.cpp(399)
Unable to find open movie segment shell_main

ifs_saveop_DoOps LoadFileList
ifs_saveop_DoOps LoadFileList
ifs_saveop_DoOps LoadProfile
ifs_saveop_DoOps LoadProfile
num, Selection = 1 table: 03E4116C
+++mission modes changed! ifs_mspc_MapList_layout.SelectedIdx = 1
EraSelection.subst = g era_g
play movie ATP 200 , 300 510 x 400

Message Severity: 2
.\Source\GameMovie.cpp(399)
Unable to find open movie segment ATP0.000000ly

EraSelection.subst = g era_g
num, Selection = 1 table: 03E4116C
+++mission modes changed! ifs_mspc_MapList_layout.SelectedIdx = 10
EraSelection.subst = g era_g
EraSelection.subst = g era_g
this.CurButton = nil
cur_button = nil
+++mission modes changed! ifs_mspc_MapList_layout.SelectedIdx = 9
EraSelection.subst = c era_c
EraSelection.subst = g era_g
play movie ATP 200 , 300 510 x 400

Message Severity: 2
.\Source\GameMovie.cpp(399)
Unable to find open movie segment ATP0.000000ly

this.CurButton = check_mode2
cur_button = nil
this.CurButton = check_era1
cur_button = nil
bEra_CloneWar = nil bEra_Galactic = 1
clonewar_visable = true galactic_visable = true
Adding map: HLMg_con idx: 1
this.CurButton = _map_add
cur_button = nil
this.CurButton = Launch
cur_button = nil
(none):0: attempt to call global `ActivateRegion' (a nil value)


First part of my lua:
Hidden/Spoiler:
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--

ScriptCB_DoFile("setup_teams")
ScriptCB_DoFile("ObjectiveConquest")

-- Empire Attacking (attacker is always #1)
local ALL = 2
local IMP = 1
-- These variables do not change
local ATT = 1
local DEF = 2

function ScriptPostLoad()


--This defines the CPs. These need to happen first
cp1 = CommandPost:New{name = "cp1"}
cp2 = CommandPost:New{name = "cp2"}
cp3 = CommandPost:New{name = "cp3"}
cp4 = CommandPost:New{name = "cp4"}



--This sets up the actual objective. This needs to happen after cp's are defined
conquest = ObjectiveConquest:New{teamATT = ATT, teamDEF = DEF,
textATT = "game.modes.con",
textDEF = "game.modes.con2",
multiplayerRules = true}

--This adds the CPs to the objective. This needs to happen after the objective is set up
conquest:AddCommandPost(cp1)
conquest:AddCommandPost(cp2)
conquest:AddCommandPost(cp3)
conquest:AddCommandPost(cp4)

conquest:Start()

EnableSPHeroRules()


end

ActivateRegion("trigger")
testfunction = OnEnterRegion(
function(region, player)
PlayAnimationFromTo("doorlow",0,1.2)
PauseAnimation("doorlow")
end,
"trigger"
)

ActivateRegion("trigger")
testfunction = OnLeaveRegion(
function(region, player)
PlayAnimationFromTo("doorlow",1.2,2.4)
PauseAnimation("doorlow")
ReqindAnimation("doorlow")
end,
"trigger"
)





---------------------------------------------------------------------------
-- FUNCTION: ScriptInit
-- PURPOSE: This function is only run once
-- INPUT:
-- OUTPUT:
-- NOTES: The name, 'ScriptInit' is a chosen convention, and each
-- mission script must contain a version of this function, as
-- it is called from C to start the mission.
---------------------------------------------------------------------------

function ScriptInit()

Re: Lua problem

Posted: Sat Feb 21, 2009 4:07 pm
by Maveritchell
Could I see a screenshot of your region (highlighted) in ZE?

Re: Lua problem

Posted: Sat Feb 21, 2009 6:25 pm
by ryukaji
Is my lua right though, it doesnt get munge errors but its still not working

Re: Lua problem

Posted: Sat Feb 21, 2009 6:34 pm
by [RDH]Zerted
Your blue code needs to be inside the ScriptPostLoad() function. Meaning, move it above the end. At its current location, it is being run when the game loads your lua file. All the files used by a map are loaded before the map starts. The map script is loaded before the ActivateRegion function is loaded, so that is why you are getting the error. It cannot find that function. You want your map code to run after the map starts.

Re: Lua problem

Posted: Sat Feb 21, 2009 6:46 pm
by ryukaji
Thank you it doesnt crash now, but now the animation doesnt play....