Jump to content

Scripting is the bane of my existence


Recommended Posts

ScriptName aaTortureCageSwitchScript

ref myParent
ref mySelf

short initialized
short Busy
short Open
short AlreadyOpened
float timer

Begin OnActivate
If Busy == 0 && Open == 0
	set mySelf to getSelf
	set myParent to getParentRef
	set Busy to 1
	set Open to 1
	set timer to 2
	message "The prisoner has been condemned."
ElseIf Busy == 1
	message "You may not use this switch at this time."
ElseIf Busy == 0 && Open == 1
	message "SOMETHING IS WRONG"
	set Busy to 1
EndIf
End

Begin GameMode
If timer > 0
	set timer to timer - getSecondsPassed
EndIf

If timer <= 0 && Open == 1 && AlreadyOpened == 0
	myparent.activate mySelf 1
	set AlreadyOpened to 1
EndIf

If IsAnimPlaying == 0
	set Busy to 0
	set Open to 0
	Reset3dState
EndIf
End

 

The above code is me trying to make a reusable script that will open a cage and drop it's occupant to a fiery death.

 

I use this to reset things:

 

ScriptName aaTortureResetScript

Begin OnActivate
	message "The prisoner has been resurrected."
	wTortureHangingCageRef.Reset3dState
	wLabsPrisonerRef.Resurrect
	wLabsPrisonerRef.MoveTo TortureVictemRecall
	wLabsPrisonerRef.Evp
End

 

Please, please, please someone tell me where I'm going wrong here. I've been going at it for 2 days now =/

Link to comment
Share on other sites

I'm just a beginner myself, but I think that if you have an OnActivate block, then the object doesn't activate normally unless you have it in your script. So you need something like:

 

Begin OnActivate
If Busy == 0 && Open == 0
	set mySelf to getSelf
	set myParent to getParentRef
	set Busy to 1
	set Open to 1
	set timer to 2
	message "The prisoner has been condemned."
	Activate
ElseIf Busy == 1
	message "You may not use this switch at this time."
ElseIf Busy == 0 && Open == 1
	message "SOMETHING IS WRONG"
	set Busy to 1
EndIf
End

Edited by fg109
Link to comment
Share on other sites

Exactly what happens when you try and use your script? You should put in more debug messages so you know which step it's stopping at. Try this:

 

ScriptName aaTortureCageSwitchScript

ref mySelf
ref myParent

short Open
float timer

Begin OnActivate
If Open == 0
	set mySelf to getSelf
	set myParent to getParentRef
	set Open to 1
	set timer to 2
	message "The prisoner has been condemned."
	Activate
ElseIf Open == 1
	message "You may not use this switch at this time."
EndIf
End

Begin GameMode
If timer > 0 && Open == 1
	set timer to timer - getSecondsPassed
	message "Countdown: %.1f seconds" timer
	Return
ElseIf timer <= 0 && Open == 1
	myparent.activate myself 1
	set Open to 2
	message "Dropping prisoner"
EndIf

If Open == 2
	If IsAnimPlaying == 0
		set Open to 0
		Reset3dState
		message "resetting switch"
	Endif
EndIf
End

 

ScriptName aaTortureResetScript

float timer
short initialize

Begin OnActivate
set timer to 5
       set initialize to 1
Activate
End

Begin GameMode
if initialize == 1 && timer >= 0
	set timer to timer - GetSecondsPassed
	Return
elseif timer < 0
	set timer to 0
               set initialize to 0
	message "The prisoner has been resurrected."
	wTortureHangingCageRef.Reset3dState
	wLabsPrisonerRef.MoveTo TortureVictemRecall
	wLabsPrisonerRef.Resurrect
	wLabsPrisonerRef.Evp
endif
End

Edited by fg109
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...