GetButtonPressed Not Working

Post » Sun Jan 02, 2011 4:57 am

The Emperor has two alternate pieces of dialog, one when he talks to the player the first time and the one when he talks to the player the last time. I'm trying to make a menu that will show up when you load the mod and allow you to select which set of dialogs you want. I got the menu to work alright - but nothing else works because GetButtonPressed always returns -1 rather then 0 or 1 which is what I need. Any ideas?

ScriptName DialogChooserScriptShort DialogChooserShort DialogChoiceShort DialogChosenBegin GameMode	If DialogChosen == 0	MessageBox "Which dialogs would you like to activate?" "Original" "Alternate"	Set DialogChooser To GetButtonPressed	Set DialogChosen To 1	EndIf	If DialogChooser == 0	Set DialogChoice To 0	ElseIf DialogChooser == 1	Set DialogChoice To 1	EndIfEnd


- Ryan Paul Fialcowitz
User avatar
Richard Thompson
 
Posts: 3302
Joined: Mon Jun 04, 2007 3:49 am

Post » Sun Jan 02, 2011 5:19 am

You're doing it in the wrong order, is all. Here's a template:

short Chosenshort Choosingshort ChoiceBegin GameMode	If Chosen == 0		MessageBox "Question Goes Here" "Answer 1" "Answer 2"		set Choosing to 1		set Chosen to 1	EndIf	If Choosing == 1		Set Choice to GetButtonPressed		If Choice == 0			;do stuff for Answer 1			set Choosing to 0		ElseIf Choice == 1			;do stuff for Answer 2			set Choosing to 0		EndIf	EndIfEnd


Basically, you have to set a variable as a flag for when the script should start listening for the response ("Choosing", in this case), and then set something to GetButtonPressed. Then you have to set your flag variable back to 0 as soon as a choice has been made to kill the messagebox.

Hope this helps!
User avatar
Meghan Terry
 
Posts: 3414
Joined: Sun Aug 12, 2007 11:53 am

Post » Sun Jan 02, 2011 2:32 am

You're doing it in the wrong order, is all. Here's a template:

short Chosenshort Choosingshort ChoiceBegin GameMode	If Chosen == 0		MessageBox "Question Goes Here" "Answer 1" "Answer 2"		set Choosing to 1		set Chosen to 1	EndIf	If Choosing == 1		Set Choice to GetButtonPressed		If Choice == 0			;do stuff for Answer 1			set Choosing to 0		ElseIf Choice == 1			;do stuff for Answer 2			set Choosing to 0		EndIf	EndIfEnd


Basically, you have to set a variable as a flag for when the script should start listening for the response ("Choosing", in this case), and then set something to GetButtonPressed. Then you have to set your flag variable back to 0 as soon as a choice has been made to kill the messagebox.

Hope this helps!


GetButtonPressed is still returning -1 rather then 0 or 1.

- Ryan Paul Fialcowitz
User avatar
Kayla Bee
 
Posts: 3349
Joined: Fri Aug 24, 2007 5:34 pm

Post » Sun Jan 02, 2011 4:24 am

-1 means no button has been pressed yet, that the script can determine.
Post your current script.
User avatar
Olga Xx
 
Posts: 3437
Joined: Tue Jul 11, 2006 8:31 pm

Post » Sun Jan 02, 2011 10:25 am

-1 means no button has been pressed yet, that the script can determine.
Post your current script.


I just tried the above script again and it seems to be working. Previously I was testing it with saved games which didn't work, but it seems to work with new games. Hopefully there won't be any more issues. Thanks for the help.

- Ryan Paul Fialcowitz
User avatar
Glu Glu
 
Posts: 3352
Joined: Sun Apr 01, 2007 5:39 am

Post » Sun Jan 02, 2011 11:42 am

edit: nevermind, you've fixed it :)
User avatar
Sebrina Johnstone
 
Posts: 3456
Joined: Sat Jun 24, 2006 12:58 pm

Post » Sun Jan 02, 2011 7:44 am

edit: nevermind, you've fixed it :)


Not quite. I'd like to be able to reset the mod via a keyboard combination so that I can get the menu again- but I unsure as to how to accomplish this. Even when run with The Script Extender, The Construction Set doesn't like the IsKeyPressed3 command, I would assume this is because I am using it incorrectly. Any advice, as always, would be appreciated.

ScriptName DialogChooserScriptShort ChoiceShort DialogShort PlayerHasChosenBegin GameMode	If IsKeyPressed3 == 52 && IsKeyPressed == 53		Set PlayerHasChosen To 0	EndIf	If PlayerHasChosen == 0		MessageBox "Would you like to activate the alternate dialogs?" "Of course!" "No, I'd really rather not."			Set Dialog To 1			Set PlayerHasChosen To 1	EndIf	If Dialog == 1		Set Choice To GetButtonPressed		If Choice == 0			Set Dialog To 0		ElseIf Choice == 1			Set Dialog To 0		EndIf	EndIfEnd


- Ryan Paul Fialcowitz
User avatar
Ryan Lutz
 
Posts: 3465
Joined: Sun Sep 09, 2007 12:39 pm

Post » Sun Jan 02, 2011 6:20 am

If IsKeyPressed3 == 52 && IsKeyPressed == 53


Try this:

If IsKeyPressed3 52 == 1 && IsKeyPressed3 53 == 1
User avatar
herrade
 
Posts: 3469
Joined: Thu Apr 05, 2007 1:09 pm

Post » Sun Jan 02, 2011 7:00 am

Try this:

If IsKeyPressed3 52 == 1 && IsKeyPressed3 53 == 1


Thanks dude, worked like a charm. For anyone interested the mod can be found at: https://sites.google.com/site/ryanpaulfialcowitz/

- Ryan Paul Fialcowitz
User avatar
Mizz.Jayy
 
Posts: 3483
Joined: Sat Mar 03, 2007 5:56 pm


Return to IV - Oblivion