Trouble with getbuttonpressed and activators

Post » Sat May 28, 2011 3:53 am

I've got this script attached to a table which is an activator (a copy of an existing activator table).

Spoiler
Begin Mf_card_tableShort ConVarShort ButtonIf ( OnActivate )	If ( ConVar == 0 )		MessageBox, "Lets play some cards!", "Continue"		Set ConVar to 1	EndIfEndIfIf ( ConVar )	Set Button to GetButtonPressed	If ( Button == -1 )		Return	ElseIf ( Button == 0 )		Set ConVar to 2	EndifEndifIf ( ConVar == 2 )	MessageBox, "What would you like to do?", "Deal'm", "Quit"	Set ConVar to 3EndifIf ( ConVar == 3 )	Set Button to GetButtonPressed	If ( Button == -1 )		Return	ElseIf ( Button == 0 )		Set ConVar to 4	Else		Set ConVar to 0	EndIfEndifIf ( ConVar == 4 )	MessageBox, "test test test"	Set ConVar to 0EndifEnd


When I activate it, it runs fine up until it gets to . When I hit the "Deal'm" button, it does nothing, the same messagebox is still there. If I Hit the "quit" button, it quits, but I can't activate the table again.

EDIT: :banghead: Ok, I don't understand this at all.

Spoiler
Begin Mf_card_tableShort ConVarShort ButtonShort ConVar2If ( OnActivate )	If ( ConVar == 0 )		MessageBox, "Lets play some cards!", "Continue"		Set ConVar to 1	EndIfEndIfIf ( ConVar )	Set Button to GetButtonPressed	If ( Button == -1 )		Return	ElseIf ( Button == 0 )		Set ConVar to 2	EndifEndifIf ( ConVar == 2 )	MessageBox, "What would you like to do?", "Deal", "Quit"	Set ConVar2 to 1	Set ConVar to 0EndifIf ( ConVar2 == 1 )	Set Button to GetButtonPressed	If ( Button == -1 )		Return	ElseIf ( Button == 0 )		Set ConVar2 to 2	ElseIf ( Button == 1 )		Set ConVar to 0		Set ConVar2 to 0	EndIfEndifIf ( ConVar2 == 2 )	MessageBox, "test test test"	Set ConVar2 to 0	Set ConVar to 0EndifEnd


It works fine now. I don't understand why I couldn't just pass that variable around. It stops working the third time it's changed.
User avatar
Latisha Fry
 
Posts: 3399
Joined: Sat Jun 24, 2006 6:42 am

Post » Fri May 27, 2011 9:09 pm

You have the code
If ( ConVar )        Set Button to GetButtonPressed        If ( Button == -1 )                Return        ElseIf ( Button == 0 )                Set ConVar to 2        EndifEndif


The compiler compiles it so that the if statement looks like this (Note the != 0)
If ( ConVar != 0 )        Set Button to GetButtonPressed        If ( Button == -1 )                Return        ElseIf ( Button == 0 )                Set ConVar to 2        EndifEndif


I am fairly sure you want
If ( ConVar == 1 )        Set Button to GetButtonPressed        If ( Button == -1 )                Return        ElseIf ( Button == 0 )                Set ConVar to 2        EndifEndif

User avatar
Melis Hristina
 
Posts: 3509
Joined: Sat Jun 17, 2006 10:36 pm

Post » Sat May 28, 2011 8:05 am

Thank you so freaking much for this answer. I've been having a lot of troubles on different scripts I've been working on and it is all because I though was the same as
User avatar
Jarrett Willis
 
Posts: 3409
Joined: Thu Jul 19, 2007 6:01 pm


Return to III - Morrowind