Jump to content

Scripting


Renarion

Recommended Posts

Would you mind copying the scripts into codeboxes here so we can see them?

 

If the code on the switch worked by opening it up without the code, it makes me think that the code on the portcullis is activating the same no matter if you click on it or use the switch to remotely activate it.

 

You need to figure out how to make the code on the portcullis only activate if the player physically touches it...rather than when the switch is thrown.

 

LHammonds

Link to comment
Share on other sites

Alright, here is the script I attached to the portcullis itself.

 

ScriptName XDGTEaredOgurimPortcullisDoorSCRIPT

; activated by linked child
; activates optionally linked parent after 1 sec delay

short init
short open
short next
short busy
float timer
ref mySelf
ref myParent

begin onActivate

if isActionRef player == 1
	if open == 0
		message " This gate is opened elsewhere."
	endif
elseif isActionRef mySelf == 0 && busy == 0
	if open == 0
		playgroup forward 0
		set open to 1
		enableLinkedPathPoints
	else
		playgroup backward 0
		set open to 0
		disableLinkedPathPoints
	endif
	set next to 1
	set timer to 1
	set busy to 1
endif

end

begin gameMode

if init == 0
	; set up ref vars
	set mySelf to getSelf
	set myParent to getParentRef
	; prepare linked pathsgrid points
	disableLinkedPathPoints
	set init to 1
endif

; daisy-chain activation
if next == 1 && timer <=0
	set next to 0
	myParent.activate mySelf 1
endif

if timer > 0
	set timer to timer - getSecondsPassed
endif

if isAnimPlaying == 0 && busy == 1
	set busy to 0
endif

end

begin onReset

reset3DState
set open to 0
set busy to 0
set next to 0
disableLinkedPathPoints

end


 

And following is the script attached to the lever.

 

ScriptName XDGTEaredOgurimSwitch01SCRIPT

; activates parent after a 2 sec delay

short open
short next
short busy
float timer
ref mySelf
ref myParent

begin onActivate

if busy == 0
	if open == 0
		playgroup forward 1
		set open to 1
		set next to 1
		set timer to 2
	else
		playgroup backward 1
		set open to 0
		set next to 1
		set timer to 0.5
	endif
	set busy to 1
endif

end

begin gameMode

if next == 1 && timer <= 0
	set mySelf to getSelf
	set myParent to getParentRef
	myParent.activate mySelf 1
	set next to 0
endif

if isAnimPlaying == 0 && busy == 1
	set busy to 0
endif

if timer > 0
	set timer to timer - getSecondsPassed
endif

end

begin onReset

reset3DState
set next to 0
set open to 0
set busy to 0

end

 

 

 

Please, if anyone knows what went wrong help me. Try copy/pasting these into your CS and see if it works for you. Thx.

Link to comment
Share on other sites

I doubt it's a parenting problem because I have tried both possible scenarios, just to be sure. I have set the lever as parent of the portcullis and then the portcullis as the parent of the lever. The system failed in both tests. The lever animation plays, but the door does not open.

 

At this point I am open to alternative solutions. Perhaps I could somehow script to make the door open when the lever is activated, instead of when it plays its animation?

Link to comment
Share on other sites

  • Recently Browsing   0 members

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