Difference between revisions of "Talk:IsSneaking - Actor"
Jump to navigation
Jump to search
imported>MaboroshiDaikon (Not sure if this is working properly with Game.GetPlayer() reference.) |
imported>MaboroshiDaikon |
||
(10 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
==Syntax== | |||
I can get the following to work as expected: | I can get the following to work as expected: | ||
If (Game.GetPlayer().IsWeaponDrawn() == 1) | <source lang="papyrus">If (Game.GetPlayer().IsWeaponDrawn() == 1) | ||
;Do Something | |||
EndIf | EndIf</source> | ||
But the following does not: | But the following does not: | ||
If (Game.GetPlayer().IsSneaking() == 1) | <source lang="papyrus">If (Game.GetPlayer().IsSneaking() == 1) | ||
;Do Something | |||
EndIf | EndIf</source> | ||
Tried the following syntax and still no luck: | Tried the following syntax and still no luck: | ||
If (Game.GetPlayer().IsSneaking()) | <source lang="papyrus">If (Game.GetPlayer().IsSneaking()) | ||
;Do Something | |||
EndIf | EndIf</source> | ||
: This script worked exactly as I expected: | |||
<source lang="papyrus">Scriptname CodeTestScript extends Quest | |||
Event OnInit() | |||
RegisterForUpdate(3) | |||
EndEvent | |||
Event OnUpdate() | |||
if (Game.GetPlayer().IsSneaking()) | |||
Debug.Notification("Player is sneaking") | |||
else | |||
Debug.Notification("Player is not sneaking") | |||
endif | |||
EndEvent | |||
</source> | |||
: As a side note, this function returns a bool, so why are you comparing it with 1? It's more semantically correct, but just as superfluous, to compare it with true | |||
: -- [[User:Cipscis|Cipscis]] 23:11, 10 February 2012 (EST) | |||
:I was originally doing the comparison just as you did, but when that didn't work, I switched to the comparison with 1. | |||
:I deleted a bunch of code and comments as I've figured out what the issue is. In short, when activating a horse in sneak mode, the game takes the player out of sneak mode to mount the horse before the OnActivate block on the horse can run. Using a BlockActivation(true) on the horse ahead of time will allow you to properly check the OnSneak condition of the player. Afterwards, you can unblock the activation and activate the horse with the player actor reference to get the player to mount the horse if that is the desired effect. Not sure why the same doesn't apply for IsWeaponDrawn. | |||
: -- [[User:MaboroshiDaikon|MaboroshiDaikon]] 13:21, 12 February 2012 (CST) |
Latest revision as of 14:24, 12 February 2012
Syntax[edit source]
I can get the following to work as expected:
If (Game.GetPlayer().IsWeaponDrawn() == 1)
;Do Something
EndIf
But the following does not:
If (Game.GetPlayer().IsSneaking() == 1)
;Do Something
EndIf
Tried the following syntax and still no luck:
If (Game.GetPlayer().IsSneaking())
;Do Something
EndIf
- This script worked exactly as I expected:
Scriptname CodeTestScript extends Quest
Event OnInit()
RegisterForUpdate(3)
EndEvent
Event OnUpdate()
if (Game.GetPlayer().IsSneaking())
Debug.Notification("Player is sneaking")
else
Debug.Notification("Player is not sneaking")
endif
EndEvent
- As a side note, this function returns a bool, so why are you comparing it with 1? It's more semantically correct, but just as superfluous, to compare it with true
- -- Cipscis 23:11, 10 February 2012 (EST)
- I was originally doing the comparison just as you did, but when that didn't work, I switched to the comparison with 1.
- I deleted a bunch of code and comments as I've figured out what the issue is. In short, when activating a horse in sneak mode, the game takes the player out of sneak mode to mount the horse before the OnActivate block on the horse can run. Using a BlockActivation(true) on the horse ahead of time will allow you to properly check the OnSneak condition of the player. Afterwards, you can unblock the activation and activate the horse with the player actor reference to get the player to mount the horse if that is the desired effect. Not sure why the same doesn't apply for IsWeaponDrawn.
- -- MaboroshiDaikon 13:21, 12 February 2012 (CST)