Page 1 of 1

lua errors...

Posted: Fri Apr 10, 2009 7:12 pm
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

Re: lua errors...

Posted: Sat Apr 11, 2009 7:36 pm
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]

Re: lua errors...

Posted: Sun Apr 12, 2009 1:55 pm
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?

Re: lua errors...

Posted: Sun Apr 12, 2009 3:59 pm
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
		)

Re: lua errors...

Posted: Mon Apr 13, 2009 2:18 pm
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.