Am I doing this wrong?

Post » Sat May 28, 2011 10:30 am

If GetKeyPress 25 == 1	If Player.GetEquippedObject 5 H52BurstFire == 1		ShowMessage H52BurstFireMSG	EndIfEndIf


That's P by the way.

No matter what I do it won't show the message.
User avatar
Emmie Cate
 
Posts: 3372
Joined: Sun Mar 11, 2007 12:01 am

Post » Sat May 28, 2011 12:49 pm

What exactly are you going for here? Is this a menu you are trying to set up? Unless your using FOSE I don't know if GetKeyPress is even a function. Is it your variable or something? Perhaps you should be using http://geck.gamesas.com/index.php/GetButtonPressed if your setting up a menu. Then it might work... Give us more details, like what your going for and such.
User avatar
Alan Whiston
 
Posts: 3358
Joined: Sun May 06, 2007 4:07 pm

Post » Sat May 28, 2011 8:59 am

What exactly are you going for here? Is this a menu you are trying to set up? Unless your using FOSE I don't know if GetKeyPress is even a function. Is it your variable or something? Perhaps you should be using http://geck.gamesas.com/index.php/GetButtonPressed if your setting up a menu. Then it might work... Give us more details, like what your going for and such.


GetKeyPress is an FOSE functions. It checks to see if a specified key on the keyboard is pressed.

This is the very base of my menu. It is for showing my message for the menu.

I just want to see the damn message. I have tried three different ways before this, and everyone should work. I have used them before.
User avatar
Donatus Uwasomba
 
Posts: 3361
Joined: Sun May 27, 2007 7:22 pm

Post » Sat May 28, 2011 8:54 am

What's this line?

If Player.GetEquippedObject 5 H52BurstFire == 1


Maybe should be

set var1 to Player.GetEquippedObject 5
if var1 == H52BurstFire

edit:

The GetKeyPress should be like this I believe


If GetKeyPress 0 == 25

where 0 is the index, and 25 is the actual key.
User avatar
Dylan Markese
 
Posts: 3513
Joined: Sat Dec 01, 2007 11:58 am

Post » Sat May 28, 2011 2:07 pm

Tried http://fose.silverlock.org/fose_command_doc.html#IsKeyPressed? Here's how I'd probably go about it:

scn H52BurstFireObjectSCPTInt bPollInt iMessageBoxInt iButtonBegin OnEquip Player	Set bPoll to 1EndBegin OnUnequip Player	Set bPoll to 0EndBegin GameMode	If bPoll	Else		Return	EndIf	If iMessageBox		If (iMessageBox == 1)			Set iButton to GetButtonPressed			If (iButton == -1)				Return			Else				Set iMessageBox to -1				If (iButton == 0)				ElseIf (iButton == 1)				ElseIf (iButton == 2)				ElseIf (iButton == 3)				ElseIf (iButton == 4)				ElseIf (iButton == 5)				ElseIf (iButton == 6)				ElseIf (iButton == 7)				ElseIf (iButton == 8)				ElseIf (iButton == 9) ; Exit					EnablePlayerControls 1 1 0 0 1 0 0					Set iMessageBox to 0				EndIf			EndIf		Else;If (iMessageBox == -1)			ShowMessage H52BurstFireMSG			Set iMessageBox to 1		EndIf	ElseIf IsKeyPressed 25		DisablePlayerControls 1 1 0 0 1 0 0		Set iMessageBox to -1	EndIfEnd
That template should do it all with one object script, but I haven't tested it.
User avatar
Wayland Neace
 
Posts: 3430
Joined: Sat Aug 11, 2007 9:01 am

Post » Sat May 28, 2011 5:52 pm

If GetKeyPress 25 == 1	If Player.GetEquippedObject 5 H52BurstFire == 1		ShowMessage H52BurstFireMSG	EndIfEndIf


That's P by the way.



No matter what I do it won't show the message.


According to the doc, GetKeyPress returns the scan code of the key being pressed. You use it like this:
If ( GetKeyPress 0 ) == 25
, or

set ikeyhit to GetKeyPress 0if ikeyhit == 25etc.

In this case, 0 is the index of the first key pressed.

http://cs.elderscrolls.com/constwiki/index.php/GetKeyPress
User avatar
Cash n Class
 
Posts: 3430
Joined: Wed Jun 28, 2006 10:01 am

Post » Sat May 28, 2011 5:02 am

As JustinOther suggested, you should definitely be using http://fose.silverlock.org/fose_command_doc.html#IsKeyPressed for this.

Cipscis
User avatar
Destinyscharm
 
Posts: 3404
Joined: Sun Jul 23, 2006 6:06 pm

Post » Sat May 28, 2011 6:53 pm

I've used JustinOther's advice. It works perfectly. Thanks Justin.
User avatar
John N
 
Posts: 3458
Joined: Sun Aug 26, 2007 5:11 pm

Post » Sat May 28, 2011 10:57 am

As JustinOther suggested, you should definitely be using http://fose.silverlock.org/fose_command_doc.html#IsKeyPressed for this.

Cipscis
It's fun to be right. :D

[lord knows I've been wrong enough times]
I've used JustinOther's advice. It works perfectly. Thanks Justin.
To give credit where due, I learned that from HugePinball's original code from FOOK's hotkey polling quest. Monkey see; monkey do, much like that Cipscis style early return. ^__^ I'm glad that helped though. Did that template's menu and buttons work out all right? I hadn't compiled it and attached it to anything to test it out.
User avatar
Stephani Silva
 
Posts: 3372
Joined: Wed Jan 17, 2007 10:11 pm

Post » Sat May 28, 2011 7:48 am

It's fun to be right. :D

[lord knows I've been wrong enough times]
To give credit where due, I learned that from HugePinball's original code from FOOK's hotkey polling quest. Monkey see; monkey do, much like that Cipscis style early return. ^__^ I'm glad that helped though. Did that template's menu and buttons work out all right? I hadn't compiled it and attached it to anything to test it out.


I did had to add an OnSell block to set bPoll to 0. That, and you had a semicolom somewhere which needed to be an l. It is working perfectly though. Thanks again, and thank HugePinball for me when you can :)

I do have a question though. Why do you disable the players controls? The player can't do anything while in a meny anyway, right?
User avatar
Manny(BAKE)
 
Posts: 3407
Joined: Thu Oct 25, 2007 9:14 am

Post » Sat May 28, 2011 10:59 am

I did had to add an OnSell block to set bPoll to 0. That, and you had a semicolom somewhere which needed to be an l. It is working perfectly though. Thanks again, and thank HugePinball for me when you can :)

I do have a question though. Why do you disable the players controls? The player can't do anything while in a meny anyway, right?
  • OnSell: Oh? I was sure the OnDrop and/or OnUnequip blocks would have covered that. *tests*
    Result: I set up the bPoll var as a global, then checked it after selling the item, the var had reverted to 0, so either the OnUnequip or the OnDrop block seems to have taken care of that, making an OnSell block extraneous.
  • Commented '(iMessageBox == -1)': Since the only other possibility is that (iMessageBox == 1), 'Else' should suffice as the 'If iMessageBox' block will only run when iMessageBox has a non-zero value. Was it really not working until uncommented? *tests*
    Result: I just checked the menu, which worked fine with that condition left as 'Else'. Although it's not drastically more efficient or anything, 'Else' is a little cheaper than 'ElseIf (iMessageBox == -1)' and behaves identically.
  • DisablePlayerControls: That's just to keep the camera from moving around while pressing buttons until exiting the menu.


Sorry, I'm not trying to second guess anything, but had to see for myself if either of those issues called for different approaches in the future and all went well with that script just as it was. http://www.mediafire.com/?jjzzlztz2jz, just in case some subtle difference necessitated either alteration. The bPoll equivalent is GLOB, so one can ~Show GLOB to easily check the var.

Edit: The OnDrop block can also be cut. Dropping or selling the item forces the OnUnequip block to run if it's equipped.
User avatar
Catherine N
 
Posts: 3407
Joined: Sat Jan 27, 2007 9:58 pm


Return to Fallout 3