Help With Disable Player Controls Script?

Post » Thu Jun 21, 2012 3:54 pm

I'm wanting to add a small script that is attached to a trigger box that will disable the players control. They will only be able to look around.

But the syntax has me a bit flummoxed.

Here's what I have so far:

Spoiler

Scriptname LBGDisablePlayerControls extends Actor

Bool Property DisableControls = TRUE Auto
{Should we lock the player in-place? Default = TRUE}

Bool Property doOnce = TRUE auto
{Shall we do this only once? Default = TRUE}

auto STATE waitingForPlayer
EVENT onTriggerEnter(objectReference triggerRef)

if doOnce
gotoState("hasBeenTriggered")
endif

if DisableControls == TRUE
Game.DisablePlayerControls(true, true, true, false, true, false, true)
endif

endEvent

endSTATE

STATE hasBeenTriggered
; this is an empty state.
endSTATE

Thanks for any help in debugging this :smile:
User avatar
Chelsea Head
 
Posts: 3433
Joined: Thu Mar 08, 2007 6:38 am

Post » Thu Jun 21, 2012 12:29 pm

As it stands, those properties are useless. Repeatedly disabling the controls adds nothing. So the event could just do

gotoState("hasBeenTriggered")
Game.DisablePlayerControls(true, true, true, false, true, false, true)
User avatar
Dan Endacott
 
Posts: 3419
Joined: Fri Jul 06, 2007 9:12 am

Post » Fri Jun 22, 2012 12:48 am

As it stands, those properties are useless. Repeatedly disabling the controls adds nothing. So the event could just do

gotoState("hasBeenTriggered")
Game.DisablePlayerControls(true, true, true, false, true, false, true)

I was wanting to use properties so the script can be expandable and re-usable.

But I don't understand when you say they are repeatedly disabling :smile:

Where is the script making the controls disabled more than once?
User avatar
Avril Churchill
 
Posts: 3455
Joined: Wed Aug 09, 2006 10:00 am

Post » Thu Jun 21, 2012 7:28 pm

I was wanting to use properties so the script can be expandable and re-usable.

But I don't understand when you say they are repeatedly disabling :smile:

Where is the script making the controls disabled more than once?

The flip side of your question is, where is the script changing the DoOnce flag?

As I'm reading your script (is this psuedo-code or does it actually compile?), I wouldn't bother with the states. In my opinion, and I'm sure there are many who will offer a different take, I would use them if I have race conditions I'm worried about or for more complex code. This is too simpe of a function and made more complicated with states. I'd write it like:

if !Done  if DisableControls	Game.DisablePlayerControls(true, true, true, false, true, false, true)  endif  Done = Trueendif
Note: I changed the name from DoOnce to Done as it made more since to me...

Edit: Also, not sure why you'd want to make the default do nothing, as you have it.
User avatar
Jonathan Braz
 
Posts: 3459
Joined: Wed Aug 22, 2007 10:29 pm

Post » Thu Jun 21, 2012 3:39 pm

Just noticed that your script extends an Actor, which won't work. It's triggers that have OnTriggerEnter events.

You can certainly have a DoOnce property, which would mean that every time the player goes to that spot they are disabled, but I don't see the point of the DisableControls property in a Script called LBGDisableControls - if you don't want controls disabled you shouldn't be running such a script, I'd have thought.

Edit: I should use states, so that a once entered trigger does not have to check a variable.
User avatar
Jessica Stokes
 
Posts: 3315
Joined: Fri Jul 28, 2006 11:01 am

Post » Thu Jun 21, 2012 12:23 pm

Just noticed that your script extends an Actor, which won't work. It's triggers that have OnTriggerEnter events.

I understand what you're saying here as I always have a hard time figuring out that line.

Can you tell me what it should be?
User avatar
Jaki Birch
 
Posts: 3379
Joined: Fri Jan 26, 2007 3:16 am

Post » Fri Jun 22, 2012 2:44 am

Scriptname LBGDisablePlayerControls extends ObjectReference
User avatar
Zach Hunter
 
Posts: 3444
Joined: Wed Aug 08, 2007 3:26 pm

Post » Thu Jun 21, 2012 10:21 pm

That did it!

Thanks Ingenue!
User avatar
Dan Wright
 
Posts: 3308
Joined: Mon Jul 16, 2007 8:40 am

Post » Thu Jun 21, 2012 8:16 pm

The flip side of your question is, where is the script changing the DoOnce flag?

As I'm reading your script (is this psuedo-code or does it actually compile?), I wouldn't bother with the states. In my opinion, and I'm sure there are many who will offer a different take, I would use them if I have race conditions I'm worried about or for more complex code. This is too simpe of a function and made more complicated with states. I'd write it like:

if !Done  if DisableControls	Game.DisablePlayerControls(true, true, true, false, true, false, true)  endif  Done = Trueendif
Note: I changed the name from DoOnce to Done as it made more since to me...

Edit: Also, not sure why you'd want to make the default do nothing, as you have it.

Thanks Sollar!

Works like a charm :)
User avatar
Vincent Joe
 
Posts: 3370
Joined: Wed Sep 26, 2007 1:13 pm


Return to V - Skyrim