-- 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.
(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:
-- 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)
---------------------------------------------------------------------------
-- 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....