AlexxEG Posted August 13, 2010 Share Posted August 13, 2010 I have this script for my mod (this is FAR from the final script, I trying to get it to work, then I will tweak it) that allow you to change the position of a ingame object, but it wont work.I'm guessing the "IsKeyPressed" function isn't the best way to go. I tryed GetKeyPress function, but I'm not 100% how to use it. Btw, the cooldown thing in script is so that when you hold down any of the Num buttons, the object wont be moving super fast. scn 00TTTestingScript Float Xp Float Yp Float Zp Float Xa Float Ya Float Za Float fScale Short IsOn Short sEnable ;Cooldown Int iStage Float fTimer Begin OnActivate if ( IsKeyPressed 22 == 1 ) if ( IsOn == 0 ) ShowMessage 00TTTesting01MESG Set Xp to GetPos X Set Yp to GetPos Y Set Zp to GetPos Z Set fScale to GetScale Set IsOn to 1 else ShowMessage 00TTTesting01MESG endif endif End Begin GameMode if ( IsOn == 0 ) Return elseif ( IsOn == 1 ) if ( iStage == 0 ) if ( IsKeyPressed 72 == 1 ) Set Xp to ( Xp + 1 ) Set iStage to 1 endif if ( IsKeyPressed 80 == 1 ) Set Xp to ( Xp - 1 ) Set iStage to 1 endif if ( IsKeyPressed 75 == 1 ) Set Yp to ( Yp + 1 ) Set iStage to 1 endif if ( IsKeyPressed 77 == 1 ) Set Yp to ( Yp - 1 ) Set iStage to 1 endif if ( IsKeyPressed 71 == 1 ) Set Zp to ( Zp + 1 ) Set iStage to 1 endif if ( IsKeyPressed 79 == 1 ) Set Zp to ( Zp - 1 ) Set iStage to 1 endif endif SetPos X Xp SetPos Y Yp SetPos Z Zp SetScale fScale if ( GetKeyPress 18 ) Disable Set sEnable to 1 Set IsOn to 2 endif elseif ( sEnable == 1 ) Enable Set sEnable to 0 Set IsOn to 0 endif if ( fTimer > 0 ) Set fTimer to fTimer - GetSecondsPassed elseif ( iStage == 1 ) Set iStage to 2 Set fTimer to 0.3 elseif ( iStage == 2 ) Set iStage to 0 endif End The messages only shows that the user has activated the function, or that it's already activated. Thanks in advance!^^ EDIT: I edited the script a bit Link to comment Share on other sites More sharing options...
rickerhk Posted August 13, 2010 Share Posted August 13, 2010 You use the GetkeyPressed like this: set iKey to GetKeyPress 0 Will get the first key pressed. http://cs.elderscrol...php/GetKeyPressIf no key is pressed, it returns 65535, so I guess you could use it like this to make sure you are capturing a key (in a gamemode block) Long iKey if (iKey == 0) set iKey to GetKeyPress 0 return elseif iKey == 65535 set iKey to 0 return else if (ikey == something1) do stuff elseif (ikey == something2 do stuff ... etc endif set ikey to 0 endif Link to comment Share on other sites More sharing options...
AlexxEG Posted August 14, 2010 Author Share Posted August 14, 2010 Thank you, it works now^^ Kudos Link to comment Share on other sites More sharing options...
AlexxEG Posted August 14, 2010 Author Share Posted August 14, 2010 I have another problem with finishing the placing. I changed the script to a quest, so that I can use it on several objects without writing the script over and over again on each object.The problem start from the "elseif ( iKey == 21 )" line. It's suppose the disable and enable so it updates collison and such, however nothing happens other than it loses the control over the object (which it's suppose to)This is the quest script: scn TTTestingScriptQ float Xp float Yp float Zp float Xa float Ya float Za float fScale int IsOn int iEnable int iKey int iSnap int iMenu int iButton ref rObject ;Cooldown int iStage float fTimer Begin GameMode if ( iStage == 0 ) if ( iKey == 0 ) set iKey to gkp 0 Return elseif ( iKey == 65535 ) set iKey to gkp 0 Return elseif ( iKey == 75 ) set Xp to ( Xp - 1 ) if ( iSnap == 1 ) set iStage to 1 else endif elseif ( iKey == 77 ) set Xp to ( Xp + 1 ) if ( iSnap == 1 ) set iStage to 1 else endif elseif ( iKey == 72 ) set Yp to ( Yp + 1 ) if ( iSnap == 1 ) set iStage to 1 else endif elseif ( iKey == 80 ) set Yp to ( Yp - 1 ) if ( iSnap == 1 ) set iStage to 1 else endif elseif ( iKey == 71 ) set Zp to ( Zp + 1 ) if ( iSnap == 1 ) set iStage to 1 else endif elseif ( iKey == 73 ) set Zp to ( Zp - 1 ) if ( iSnap == 1 ) set iStage to 1 else endif elseif ( iKey == 74 ) set fScale to ( fScale - 0.1 ) if ( iSnap == 1 ) set iStage to 1 else endif elseif ( iKey == 78 ) set fScale to ( fScale + 0.1 ) if ( iSnap == 1 ) set iStage to 1 else endif elseif ( iKey == 81 ) if ( iSnap == 0 ) set iSnap to 1 ShowMessage TTTesting03MESG else set iSnap to 0 ShowMessage TTTesting04MESG endif set iStage to 1 elseif ( iKey == 22 ) ShowMessage TTTestingConfigMESG set iMenu to 1 set IsOn to 2 elseif ( iKey == 21 ) rObject.Disable EnablePlayerControls set iEnable to 1 else set iKey to gkp 0 Return endif else endif rObject.SetPos X Xp rObject.SetPos Y Yp rObject.SetPos Z Zp rObject.SetScale fScale set iKey to 0 if ( iEnable == 1 ) rObject.Enable set iEnable to 0 set IsOn to 0 StopQuest TTTestingQ elseif ( iMenu == 1 ) set iButton to GetButtonPressed if ( iButton == 0 ) set fScale to 1 rObject.SetScale fScale set iButton to 0 set iMenu to 0 set IsOn to 1 elseif ( iButton == 1 ) ;Do nothing set iButton to 0 set iMenu to 0 set IsOn to 1 endif endif if ( fTimer > 0 ) Set fTimer to fTimer - GetSecondsPassed elseif ( iStage == 1 ) Set iStage to 2 Set fTimer to 0.3 elseif ( iStage == 2 ) Set iStage to 0 endif End And this is on the object: scn TTTestingScript Begin OnActivate if ( IsKeyPressed 22 == 1 ) if ( TTTestingQ.IsOn == 0 ) ShowMessage TTTesting01MESG DisablePlayerControls 0 1 1 0 0 0 set TTTestingQ.Xp to GetPos X set TTTestingQ.Yp to GetPos Y set TTTestingQ.Zp to GetPos Z set TTTestingQ.fScale to GetScale set TTTestingQ.IsOn to 1 set TTTestingQ.iStage to 1 set TTTestingQ.rObject to GetSelf StartQuest TTTestingQ else ShowMessage TTTesting02MESG endif endif End Link to comment Share on other sites More sharing options...
Recommended Posts