Lua problem

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
ryukaji
Major
Major
Posts: 513
Joined: Mon Sep 17, 2007 7:46 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Contact:

Lua problem

Post 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?
User avatar
ThePanda
Private Second Class
Posts: 74
Joined: Sat Dec 20, 2008 4:22 pm

Re: Lua problem

Post by ThePanda »

I think you can get rid of those lines completely, unless you want some sort of parameter for the door.
ryukaji
Major
Major
Posts: 513
Joined: Mon Sep 17, 2007 7:46 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Contact:

Re: Lua problem

Post by ryukaji »

that didnt work unfortunately
theultimat
Lieutenant General
Lieutenant General
Posts: 679
Joined: Sun Apr 13, 2008 1:39 pm
Location: UK

Re: Lua problem

Post 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...
ryukaji
Major
Major
Posts: 513
Joined: Mon Sep 17, 2007 7:46 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Contact:

Re: Lua problem

Post 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
User avatar
ThePanda
Private Second Class
Posts: 74
Joined: Sat Dec 20, 2008 4:22 pm

Re: Lua problem

Post 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.
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Lua problem

Post 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).
ryukaji
Major
Major
Posts: 513
Joined: Mon Sep 17, 2007 7:46 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Contact:

Re: Lua problem

Post 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
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Lua problem

Post 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.
ryukaji
Major
Major
Posts: 513
Joined: Mon Sep 17, 2007 7:46 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Contact:

Re: Lua problem

Post 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()
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Lua problem

Post by Maveritchell »

Could I see a screenshot of your region (highlighted) in ZE?
ryukaji
Major
Major
Posts: 513
Joined: Mon Sep 17, 2007 7:46 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Contact:

Re: Lua problem

Post by ryukaji »

Is my lua right though, it doesnt get munge errors but its still not working
Last edited by ryukaji on Sat Feb 21, 2009 6:40 pm, edited 1 time in total.
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: Lua problem

Post 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.
ryukaji
Major
Major
Posts: 513
Joined: Mon Sep 17, 2007 7:46 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Contact:

Re: Lua problem

Post by ryukaji »

Thank you it doesnt crash now, but now the animation doesnt play....
Post Reply