 |
Castle Paradox
|
View previous topic :: View next topic |
Author |
Message |
bis_senchi

Joined: 08 Jun 2004 Posts: 460 Location: Reims, France
|
Posted: Tue Aug 10, 2010 6:43 am Post subject: help to implement the menu I've made for my game |
|
|
Hello eveyone! Once again I came with troubles in writing and implementing plotscripts
I've made a predefined menu (menu 6) for my game and I would like to appear in place of menu 0 each time the player presses esc
The trouble is that my menu can with plotscripting (as the player changes map for nicer game making and many datas are stored in variables)
#-----------------------------------------------------------------------------
plotscript, menu launches, begin
suspend npcs
suspend player #allows basic menu 0 not to appear
variable (handle)
set variable (YourMoney, party money) # cherche combien on a d'argent
fade screen out (0, 0, 0)
show backdrop (0)
set variable (YourM,current map) #permet d'enregistrer notre position dans le jeu
set variable (YourX,herox(me))
set variable (YourY,heroy(me))
set variable (MyPicSet, get hero picture(me)) #permet d'enregistrer notre apparence
set variable (heropic1, get hero picture(1))
set variable (heropic2, get hero picture(2))
set variable (heropic3, get hero picture(3))
camera follows npc (0)
teleport to map (18, 2, 4)
escape behaviour:= 4 #permet de donner le bon cas pour le retour
wait (1)
set hero picture (me, 0) # hero 0 became invisible by default
if (hero by slot (1) <> -1) then, begin # if slot (1) is occupied
set hero picture (1, 0)
end
if (hero by slot (2) <> -1) then, begin # if slot (2) is occupied
set hero picture (2, 0)
end
if (hero by slot (3) <> -1) then, begin # if slot (3) is occupied
set hero picture (3, 0)
end
$20= "P.Good" #chance par défaut enlevé plus tard
# string 8 et 11 servent déjà à afficher la magie dans les combats pour hakkai et sanzo réutilisés
# pour la chance et la magie dans le menu!
string from textbox (8, 53, 0) #text box 53 L0 -> chance
string from text box (11,53, 1) #text box 53 L1 -> money
show string at (8, 167, 1
show string at (11, 167, 2
handle:= open menu (6)
fade screen in
show map
end
#------------------------------------------------------------------------------
My question is the following : in the article it is written that launching a script just before the menu comes up to prevent menu 0 from appearing is not a recommended anymore.
Could somoene confirm this and tell if if under custom a line has be added to change the main menu reference?
If this new way exists how am I supposed to do with the rest of the script?
If the function that have been implemented "only" provides to make appear menu 6 instead of menu 0 when the player presses esc I will still have to find a way to launch the rest of the script.
http://hamsterrepublic.com/ohrrpgce/index.php/How_can_I_run_a_script_instead_of/before/after_the_menu_comes_up_.html
As always thanks a lot for help and advise! _________________ It's time to make games! |
|
Back to top |
|
 |
Bob the Hamster OHRRPGCE Developer

Joined: 22 Feb 2003 Posts: 2526 Location: Hamster Republic (Southern California Enclave)
|
Posted: Tue Aug 10, 2010 7:31 am Post subject: |
|
|
The current nightly builds have a new feature for making a different menu appear when you press ESC to close a menu.
It might help you do this with no scripting at all (or at least with less scripting) |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Wed Aug 11, 2010 3:03 am Post subject: |
|
|
So you want to run a script instead of opening the main menu when ESC is pressed, and that script opens the menu itself?
Well, there's no option to launch to script when a menu is opened (someone should add one!), so what that article says about the "Old Way" being obsolete isn't totally correct.
But what we really need is an option to launch a script instead of opening the main menu. Until it is implemented, the only way to do what you want is to follow the "Script Instead Of Menu" instructions in that article.
(The main menu is always menu 0, so you are meant to replace the default menu 0 instead of creating a new one.) _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
bis_senchi

Joined: 08 Jun 2004 Posts: 460 Location: Reims, France
|
Posted: Fri Aug 13, 2010 6:31 pm Post subject: I managed to solve several problems but... |
|
|
I managed to solve the problems by NOT using a loop to check if my script was already running at the beginning of my handler script!
I used the global variable to divide the script in sub-scripts
Code: |
#------------------------------------------------------------------------
plotscript, my handler, begin
if (key is pressed(key:esc), xor, key is pressed(key:alt)) then, begin
if (gamemenuisactive==false) then, begin
game menu
end, else, begin
#thus, game has not been launched
leave game menu
end #end of if (game menu is active)
end #end for the if key is pressed
end
#-------------------------------------------------------------------
|
After some hours of test I also managed to get rid of the error
Code: |
close menu invalid menu handle -1
call chain (current script last)
|
It was a problem due to script overloading but hspeak that complained he had no menu to close. I just needed to check if (top menu) returned true to solve this!
But as always with plotscriting a problem solved call another one not yet
solved to take its place!
I would like some pieces of advice for my item sub menu.
When the player presses the spare bar and chooses item in the menu
everything goes find. The script above launches and everything is ok on screen
The problem comes when I try to make the player go back from the item menu to the main menu when he/she presses esc.
wait for key (esc) and wait for scancode (I'll need both 01 ESC 56 ALT as the basic menu can be launched with those 2 keys) seems fine but I don't see the differences between both commands.
In what kind of situation are we supposed to use them? What are the differences between wait for key and wait for scancode ?
Other trouble : if I remember well wait for key stops the script until the
player has pressed the key which is expected but in my case the player can access a sub menu menu (use item) pressing esc
I think this is possible because the script has ended. If necessary I can reimplement it.
To sum things up I would like
1- make the script stop until the player press a key (esc or space bar)
2- when the player has pressed the key the key is identified (may be using scancode recording)
3- according to the key pressed there will be 2 behaviour
if the key is esc (or alt) the player goes back to the previous screen
if the key is the space bar then the sub menu will open
Could somoene help me to put this in plotscript language?
Code: |
#------------------------------------------------------------------------------
# item menu for the menu outside battle
plotscript, item menu, begin
fade screen out (0,0,0)
hide string (11) # hide luck and yens infos not in status menu
hide string (8)
close menu (top menu) # close previous menu : main menu 6
$0="Items"
string from textbox (1, 53, 2) #text box 53 L2 is for menu names
show string at (1, 17, 21) # Sub menu name location
escape behaviour:=2 #gives correct behaviour for escape key so that the player can leave without any pbs
wait(1) #very very important
open menu (2) #open item menu
wait (2) #make sure menu already poped up when screen goes back to normal
open menu (8) #menu use item activé par défaut
wait (4)
variable (handle)
handle:= find menu ID (2) # menu 2 desactivé
set menu bit (handle, menubit:no controls, off)
fade screen in
end #end for the plotscript
#------------------------------------------------------------------------------
|
As always thank you very much in advance for the help! _________________ It's time to make games! |
|
Back to top |
|
 |
bis_senchi

Joined: 08 Jun 2004 Posts: 460 Location: Reims, France
|
Posted: Tue Aug 17, 2010 12:49 am Post subject: And once again a problem |
|
|
I've got the following message from custom.exe
hspeak.exe wrote: |
write menu int : invalid menu handle -1
call chain (current script last)
use nikuman -> set menu off set y
|
When I enter the debugger it tolds me that
custom debugger wrote: |
set menu offsetx 1 3 6
0 use nikuman 7 called #1
# name death state CmdKn
|
Here is a extract of my script. I'm using set menu offset command this way but I may be wrong and that would explain why custom.exe complains.
Code: |
plotscript, extract of nikuman script, begin
variable (handle)
open menu (12) #hero slot menu Goku
handle:= find menu ID (13)
set menu offset x(handle, 40)
set menu offset y(handle, -60)
end #end of the script
|
Any help to understand what the debuggers says would be great. Good luck in making your games everybody! _________________ It's time to make games! |
|
Back to top |
|
 |
Bob the Hamster OHRRPGCE Developer

Joined: 22 Feb 2003 Posts: 2526 Location: Hamster Republic (Southern California Enclave)
|
Posted: Tue Aug 17, 2010 7:08 am Post subject: |
|
|
That error message means that the menu handle is invalid. The "find menu" command returns a zero if it can't find a menu handle.
Code: |
plotscript, extract of nikuman script, begin
variable (handle)
open menu (12) #hero slot menu Goku
handle:= find menu ID (13)
if(handle) then(
set menu offset x(handle, 40)
set menu offset y(handle, -60)
)
end #end of the script |
Did you mean to use 12 for the "open menu" command but 13 for the "find menu ID" command? Or were they both supposed to be the same number? |
|
Back to top |
|
 |
bis_senchi

Joined: 08 Jun 2004 Posts: 460 Location: Reims, France
|
Posted: Wed Aug 18, 2010 3:26 am Post subject: And another error deleted! Hurray! |
|
|
james paige wrote: |
Did you mean to use 12 for the "open menu" command but 13 for the "find menu ID" command? Or were they both supposed to be the same number?
|
Yes it exactly what I meant . The same figure were supposed to be used for both open menu and find menu id which was not the case in this part of the script!
Indeed this is why Hspeak.Exe complains!
I solved this. There were 3 errors of this kind in my script! Thanks for making me noticing it! Now there are no errors anymore!
I'm using 4 menus ( menu 11, menu 12, menu 13 and menu 14) as sub menus. There are all on screen at the same time and I would like the player to switch between them using the arrows.
When the player the player would press the right or the left arrow it would select the first item of the following menu in order.
For example menu 11 is selected and the player has the first item menu selected. If possible I would like that when the player press the right arrow the player switch menu and that after the key is pressed the menu 12 has been selected.
Do you think it is possible to do that? If yes how?
Thanks once more for helping me to get rid of this error! _________________ It's time to make games! |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Fri Aug 20, 2010 6:10 am Post subject: |
|
|
You can use "bring menu forward" in an onkeypress script to switch to a different menu, like this: (I haven't tested this script, but hopefully it is correct)
Code: | global variable (100, which submenu)
plotscript, onkeypress, begin
if (keyval(key:left) >> 1) then (which submenu -= 1)
if (keyval(key:right) >> 1) then (which submenu += 1)
if (which submenu << 11) then (which submenu := 14)
if (which submenu >> 14) then (which submenu := 11)
variable (handle)
handle := find menu ID(which submenu)
if (handle) then (bring menu forward(handle))
end |
("keyval" is similar to "key is pressed", but is better for this because it will only switch to another menu once each time the player presses a key.) _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
|
|
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
|