lua errors...

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 errors...

Post by ryukaji »

Here is my scriptpostload:
I got an error about playing a custom sound upon entering region, and theres problems with my elevator like after you get in and the elevator goes down the doors teleport rapidly up to where they started and where they ended after they went down so you cant walk past but you can kinda see through. Can anyone spot the elevator problem or tell me how to get a custom sound effect to play when you enter a region?

Hidden/Spoiler:
function ScriptPostLoad()
DisableSmallMapMiniMap()

EnableSPHeroRules()
-- This is the actual objective setup
TDM = ObjectiveTDM:New{teamATT = 1, teamDEF = 2,
multiplayerScoreLimit = 100,
textATT = "game.modes.tdm",
textDEF = "game.modes.tdm2", multiplayerRules = true, isCelebrityDeathmatch = true}
TDM:Start()

SetProperty("cp2", "IsVisible", 0)


AddAIGoal(1, "Deathmatch", 100)
AddAIGoal(2, "Deathmatch", 100)

AddDeathRegion("deathregion")

ForceHumansOntoTeam1()


firstspawned = 0

onfirstspawn = OnCharacterSpawn(
function(character)
if IsCharacterHuman(character) and firstspawned == 0 then
ShowObjectiveTextPopup("level.DOM.message.1", ATT)
ReleaseCharacterSpawn(onfirstspawn)
end
end
)

timer1 = CreateTimer("timer1")
SetTimerValue(timer1, 1.5)

timer2 = CreateTimer("timer2")
SetTimerValue(timer2, 2.0)

//this part works:
animateobja = OnObjectKill(
function(object, killer)
if GetEntityName(object) == "elevatorconsole" then
PlayAnimation("elevator_open")
StartTimer ("timer1")
testfunction = OnTimerElapse(
function(timer, timer1)
PauseAnimation("elevator_open")
end,
"timer1"
)
end
end
)


//The problem must be somewhere down here
ActivateRegion("doortrigger2")
testfunction2 = OnEnterRegion (
function (enter_region, player)
if IsCharacterHuman(player) then
PlayAnimation ("elevator_close")
StartTimer ("timer1")
end
end,
"doortrigger2"
)
testfunction3 = OnTimerElapse (
function (timer, timer1)
PauseAnimation ("elevator_close")
RewindAnimation ("elevator_open")
PlayAnimation ("elevator_down")
StartTimer("timer2")
end,
"timer1"
)
testfunction4 = OnTimerElapse (
function (timer, timer2)
PauseAnimation ("elevator_down")
RewindAnimation ("elevator_open")
PlayAnimation ("elevator_open")
StartTimer("timer1")
end,
"timer2"
)
testfunction5 = OnTimerElapse (
function (timer, timer1)
PauseAnimation ("elevator_open")
end,
"timer1"
)

//this doesnt work and gives me an error.
soundplayed=0
ActivateRegion("deadtrigger")
testfunction6 = OnEnterRegion (
function (enter_region, player)
if IsCharacterHuman(player) and soundplayed ==0 then
PlaySound("helpme")
soundplayed=1
end
end,
"deadtrigger"
)





end
User avatar
Fiodis
Master of the Force
Master of the Force
Posts: 4145
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

Re: lua errors...

Post by Fiodis »

Hidden/Spoiler:
[code]//The problem must be somewhere down here
ActivateRegion("doortrigger2")
testfunction2 = OnEnterRegion (
function (enter_region, player)
if IsCharacterHuman(player) then
PlayAnimation ("elevator_close")
StartTimer ("timer1")
end
end,
"doortrigger2"
)[/code]
Oughtn't it be:
Hidden/Spoiler:
[quote]//The problem must be somewhere down here
ActivateRegion("doortrigger2")
testfunction2 = OnEnterRegion (
function (enter_region, player)
if IsCharacterHuman(player) then
PauseAnimation ("elavator_close")
RewindAnimation ("elavator_close")

PlayAnimation ("elevator_close")
StartTimer ("timer1")
end
end,
"doortrigger2"
)[/quote]
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 errors...

Post by ryukaji »

Well that didnt really fix anything because I dont think you have to rewind an animation that hasnt played yet. Werent you successful in making an elevator? If you still have to script could you show me so I can use it to fix mine?
User avatar
Fiodis
Master of the Force
Master of the Force
Posts: 4145
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

Re: lua errors...

Post by Fiodis »

I always like to rewind them anyway, helps to solve problems. I think. And also I use a single animation, and OnObjectDamage rather than OnObjectKill:

Code: Select all

	testfunction2 = OnObjectDamage (
		function (object, damager)
		if GetEntityName (object) == "button_g" then
		PauseAnimation ("elavator")
		RewindAnimation ("elavator")
		PlayAnimationFromTo ("elavator", 0.0, 8.5)
		end
		end
		)
		
	testfunction3 = OnObjectDamage (
		function (object, damager) 
		if GetEntityName (object) == "button_1" then 
		PauseAnimation ("elavator")
		RewindAnimation ("elavator")
		PlayAnimationFromTo ("elavator", 10.0, 23.0) 
		end 
		end
		)
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 errors...

Post by ryukaji »

How do you get it to work with only 1 animation? I think i have to have different ones because I have doors on my elevator.
Post Reply