Castle Paradox Forum Index Castle Paradox

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Gamelist   Review List   Song List   All Journals   Site Stats   Search Gamelist   IRC Chat Room

Closing Multiple Menus

 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
NeoSpade
Of course!




Joined: 23 Sep 2008
Posts: 249
Location: Wales GB

PostPosted: Wed Jan 13, 2010 4:13 am    Post subject: Closing Multiple Menus Reply with quote

Right, I'm using a custom menu script and I'm using the ESC key, all the menu's allow scripts and gameplay to continue and besides the main menu the other 2 menus have the 'no player control' bitset.

Now they all open at the same time nicely, however when trying to close them, it's a different story, heres the script:

Code:
plotscript,mainmenu,begin
variable (handle1)
variable (handle2)
if
   (check tag (tag:mainmenu==ON))
then
   (if (key is pressed (01))
   then
      (close menu (handle1)
      close menu (handle2)
      set tag (tag:mainmenu==OFF))
   else
      end
else
   (if (key is pressed (01))
   then
      (open menu (2,false)
      handle1:=find menu ID (2)
      wait for menu (2)
      open menu (1,false)
      handle2:=find menu ID (1)
      wait for menu (1)
      open menu (0,false)
      wait for menu (0)
      set tag (tag:mainmenu==ON))
   else
      end
end


What am I doing wrong?
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Wed Jan 13, 2010 7:12 am    Post subject: Reply with quote

handle1 and handle2 are local variables. Whenever a script is run, its variables start with value '0'. They are not remembered between different runs of a script! You need to use global variables. See 'What are the differences between a variable and a global variable?' And you'll want to choose more specific names than handle1 and handle2 to avoid confusion.

Also, this is wrong:
Code:
if
   (check tag (tag:mainmenu==ON))

You want this:
Code:
if (check tag (tag:mainmenu) == ON) then (

which is the same as this (which I prefer):
Code:
if (check tag (tag:mainmenu)) then (


Similarily:
Code:
set tag (tag:mainmenu==OFF)

should be
Code:
set tag (tag:mainmenu, OFF)


...

Code:
   else
      end

I assume that this is meant to be an 'empty' else case. 'end' does not work in this way. The fact that this compiled at all is another bug in HSpeak (really have to catch these bugs, they cripple the minds of users :P) An empty else looks like else() (which is the same as else, begin, end). However, normally instead of an empty else case, you just omit the else altogether. It's optional:
Code:
if (...) then (...)
or
if (...) then (...) else (...)


'wait for menu' takes a menu handle not a menu ID as argument. However, you should remove all of these lines are they are not needed and (would) do nothing. All menu commands occur instantly. 'wait for menu' is for waiting for the player to close a menu, not for waiting for a command to take effect.

A hint: you can write "key is pressed (key:esc)" rather than "key is pressed (1)" if you include 'scancode.hsi'

And one more: "open menu" returns a handle to the menu it opened, so you can replace
Code:
      open menu (1,false)
      handle2:=find menu ID (1)

with
Code:
     handle2 := open menu (1,false)

_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group