Page 1 of 1

MWSE + getButtonPressed = null?

PostPosted: Wed Aug 12, 2009 3:13 pm
by melian
In the script I've been working on, I found that setting a var to getButtonPressed would get something that couldn't be used as a whilex condition since it got interpreted as null. Setting another var to the first one and using that instead worked. So I just wanted to know: Is this supposed to happen? Seems a bit weird :confused:

Re: MWSE + getButtonPressed = null?

PostPosted: Fri Aug 14, 2009 10:23 am
by Fliggerty
Are you using a MessageBox with multiple buttons, or just a single one?  The first button always has a value of 0, so you can't use that as a True value for ifx or whilex.

-1 = MessageBox is still displayed, no button pressed
0 = 1st button pressed
1 = 2nd button pressed, etc

Re: MWSE + getButtonPressed = null?

PostPosted: Fri Aug 14, 2009 10:45 am
by melian
I'm aware of that, and it's definitely not the problem. Firstly, it's not 0, it's null. I don't have a non-working version handy, but basically that part went kinda like this:
Code: Select all
if ( bcheck > 0 )
       set button to GetButtonPressed
       if ( button == -1 )
               return
       endif
       set button to ( button + 1 )
       if ( button > bcheck )
               ;stop the script
       else
               ;do stuff, like setting nextstate to 1 or whatever
       endif
       set bcheck to 0
endif

ifx ( nextstate )
       ;set to anotherstate, etc
       whilex ( button )
               ;do other stuff (reading files mostly)
               xLogMessage "the value of button is %d" button
               set button to ( button - 1 )
       endwhile
endif


So when I did that with the xLogMessage in there, I got a thousand messages telling me "the value of button is " (exactly like that, ie null) - and it *always* got stuck in an infinite loop regardless of how many choices there were and which one was chosen. Obviously null is 'true' as far as MWSE is concerned.

When I changed it to "set var2 to ( button + 1)" and used var2 for the rest, it worked.

Anyway... I guess I should do some more testing, then. Could be interesting :sheo:

Re: MWSE + getButtonPressed = null?

PostPosted: Fri Aug 14, 2009 11:35 am
by Fliggerty
What did your xLogMessage look like?  Did you insert the value of button with "%d" button so it writes a string?

Re: MWSE + getButtonPressed = null?

PostPosted: Fri Aug 14, 2009 12:34 pm
by melian
Well I don't have the file anymore, but here's an excerpt from memory:
Code: Select all
xLogMessage "the value of button is %d" button

would produce this in MWSELog:
Code: Select all
the value of button is
the value of button is
the value of button is
the value of button is
the value of button is
the value of button is
the value of button is


Sorry, haven't done any proper testing yet - been trying to get LAL figured out :grin: I'll get to it soon.

Re: MWSE + getButtonPressed = null?

PostPosted: Fri Aug 14, 2009 5:17 pm
by Jac
melian wrote:Sorry, haven't done any proper testing yet - been trying to get LAL figured out :grin: I'll get to it soon.

What you were trying to do with it? BTW, I still have Cello's tutorial on adding additional animations via the scripts I can send your way if you want it. It mainly deals with adding in the offsets, so it might be limited use.

Re: MWSE + getButtonPressed = null?

PostPosted: Fri Aug 14, 2009 6:04 pm
by peachykeen
[whispers]0 is null ;)[/whispers]

Edit: and your log doesn't explain either. If it were an uninitialized or null variable, it would still return something when used in formatting. A number can't actually be null, as such (and null is just #DEFINEd as 0, usually).

Re: MWSE + getButtonPressed = null?

PostPosted: Fri Aug 14, 2009 10:04 pm
by melian
I've done some proper tests at last and apparently I got something wrong somewhere - the button thing is working for me now and I can't replicate the problem. (This is why I hate asking questions. I always wind up wasting people's time and looking stupid! :banghead: ) Sorry guys!

Jac - I was actually just trying to get it set up to run it with my game, but yes I'd be interested in the tutorial as well, thanks :smile: