How do I update dialogue through slice collection?

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

bis_senchi
Red Slime
Posts: 64
Joined: Sat Apr 20, 2019 8:59 am

Post by bis_senchi »

Swordplay said:
are you using the latest version of the engine?
you can change the dimensions of any sprite set freely.
Yes I'm using the last version Gorgonzola. I noticed that you could change the size
of the sprite set but it don't feel the need to use this function (yet) but that may come as I also work on cutscene with slice collection.

You also said:
The sprite set or frame numbers can match the digits they represent.
Example: digit sprites for 0 to 9 are in sprite frames 0 to 9
If you have sprite frame 7, you have the digit 7
That's a good idea but I'll change it a bit palette 29 is by default and palette
13 put the figure in grey (selection) So set sprite palette is what will fit my need most

Code: Select all

card machine handling:=look up slice (sli: cm7 key)
set sprite palette (card machine handling, 13) #key 7 is selected

My weapon sprite (used as digits) works this way
1- weapon enemy sprite set 27
2- weapon enemy sprite set 28
3- weapon enemy sprite set 29
4- weapon enemy sprite set 30
5- weapon enemy sprite set 31
6- weapon enemy sprite set 32
7- weapon enemy sprite set 33
8- weapon enemy sprite set 34
9- weapon enemy sprite set 35
10- weapon enemy sprite set 36

Letter O - weapon ennemy sprite set 24
Letter K- weapon ennemy sprite set 31

So if I take back my keypressed script. If I'm on number 1 I can
1- go down and select number 4
2- go right and select number 2
3- go up and select number 0
4- go left and select number 3

Code: Select all

#------------------------------------------------------------------------------------------
#script for keyboard customisation
plotscript, mykeypressedscript, begin

#key implementation for card machine. Arrows used for moving on the numpad
#and d for validation of a figure and then the whole 8 digit card number

if (check tag (tag: card machine is used)==on) then, begin

    if(keypress(key:up)) then, begin
    card machine handling:=look up slice (sli: cm0 key)
    set sprite palette (card machine handling, 13) #key 0 is selected
    end #end for the if

    if(keypress(key:down)) then, begin
    card machine handling:=look up slice (sli: cm4 key)
    set sprite palette (card machine handling, 13) #key 4 is selected
    end #end for the if
 
    if(keypress(key:left)) then, begin
    card machine handling:=look up slice (sli: cm3 key)
    set sprite palette (card machine handling, 13) #key 3 is selected
    end #end for the if

    if(keypress(key:right)) then, begin
    card machine handling:=look up slice (sli: cm2 key)
    set sprite palette (card machine handling, 13) #key 2 is selected
    end #end for if 

    card machine handling:=look up slice (sli: cm1 key)
    set sprite palette (card machine handling, 12) #key 1 is unselected and get back to normal   

    if(keypress(key:d)) then, begin
    #d is used for validation process 1- first valid chosen digit
    #2- if the ok key is pressed with d then the whole card number verification process begin
    end #end for the if

end #end for the if check tag
end #end for the script
#--------------------------------------------------
If I'm on number all those figures will change. How should I combine this with the lines you wrote before?

Code: Select all

for(i,0,9,1)do(
IF(currently selected==i)THEN(load sprite set(i))
)

Code: Select all

	
for(i,0,9,1)do(
if(selected(slice child(target,i))then(return(i))
)
# h
Anyway, thanks for your answers and pieces of advice.
Last edited by bis_senchi on Wed Mar 03, 2021 6:48 am, edited 2 times in total.
User avatar
SwordPlay
Chemical Slime
Posts: 966
Joined: Sun Jan 22, 2017 9:32 am
Location: London, England
Contact:

Post by SwordPlay »

you need a way to define the keypad. not instructions.
if you use instructions you will write it like this.

Code: Select all

IF(LEFT)THEN(
 SWITCH(key)DO(
 CASE(1)DO()
 CASE(2)DO(key:=1)
 CASE(3)DO(key:=2)
 CASE(4)DO()
 CASE(5)DO((key:=4)
 CASE(6)DO(key:=5)
 CASE(7)DO()
 CASE(8)DO(key:=7)
 CASE(9)DO(key:=8)
)
etc.,

we can get the row and column for any digit just by using its number.

you can see this using the following script and in the image attachment:

Code: Select all

plotscript, key, begin
if(new keypress(key:space))THEN(showxy)
end

plotscript, show xy, begin
variable(grid)
grid:=create grid(320,200)
set grid rows(grid,20)

variable(i)
variable(text)
for(i,1,9,1)do(

text:=create text
$1="No."
append number(1,i)
$1+", X:"
append number(1,((i--1),mod,3)) # offset is --1
$1+" Y:"
append number(1,(i--1)/3) # offset is --1
set slice text(text,1)
set parent(text,grid)
)
end
you can see i have used offsets to make the row and column start at 0.

You might need:
1. cases for reaching the edge of the keypad in each direction
2. a way to check the slice under the cursor, or the current selected key. this can be done by calculation from the digit or slice checking
3. a way to move the cursor image on-screen over the keypad.

You also need a special case for the bottom row.
Attachments
cgecjxygrid0005.png
cgecjxygrid0005.png (1.91 KiB) Viewed 3470 times
cgecjxygrid0004.png
cgecjxygrid0004.png (2.07 KiB) Viewed 3474 times
Last edited by SwordPlay on Wed Mar 03, 2021 9:52 pm, edited 5 times in total.
"Imagination. Life is your creation."
bis_senchi
Red Slime
Posts: 64
Joined: Sat Apr 20, 2019 8:59 am

Post by bis_senchi »

SwordPlay shared the code :

Code: Select all

 SWITCH(key)DO(
 CASE(1)DO()
 CASE(2)DO(key:=1)
 CASE(3)DO(key:=2)
 CASE(4)DO()
 CASE(5)DO((key:=4)
 CASE(6)DO(key:=5)
 CASE(7)DO()
 CASE(8)DO(key:=7)
 CASE(9)DO(key:=8)
) 
So let me check if I understood correctly.

key:=4 means it means that global variable key take value 4 isnt' it ?
You give instructions meaning you, the code implementer decide the value. But that
not what I need.

sword play also said:
we can get the row and column for any digit just by using its number.
So given my slice collection, should I put all my sprites which represents a digit on a grid?
Would that help the show xy sprite or is better if appear only for calculating where to put on screen the cursor? Is the use a cursor compulsory? (You often use one in your script)

Why did you choose to make appear the grid as the script launch? Is it just for the sake of the example?

Does the grid has to take all the screen or is ok if occupies only a part of the screen?

Sorry if it seems to be a lot of questions but I've never done that so there's a lot of things I don't understand. As always thanks for your numerous pieces of advice!
Last edited by bis_senchi on Fri Mar 05, 2021 5:15 am, edited 1 time in total.
User avatar
SwordPlay
Chemical Slime
Posts: 966
Joined: Sun Jan 22, 2017 9:32 am
Location: London, England
Contact:

Post by SwordPlay »

The image is just an example.

You can structure your code however you want.
"Imagination. Life is your creation."
bis_senchi
Red Slime
Posts: 64
Joined: Sat Apr 20, 2019 8:59 am

I see...

Post by bis_senchi »

I see. Thanks SwordPlay!

After some first tests wait for key (any key) will really be useful!
Could you (or somoene else) please give me advise about slice child handling?

As I explained before when if I want to make appear selected a figure, I just can
use the look up slice.

Code: Select all

 if(keypress(key:down)) then, begin
    card machine handling:=look up slice (sli: cm4 key)
    set sprite palette (card machine handling, 13) #key 4 is selected
    end #end for the if 
But for the ok key, I used a container with 2 sprite slice (one for each letter)
(Feel free to look at the screen shot on previous page of this thread)

I've given the container the look up slice cm ok. Those 2 sprites are therefor children of the container sprite with the lookup slice cm ok.
If I'm not mistaken it is perfectly possible to manipulate a child children with a look up slice.
I think I've done it with one my previous questions on how to make a menu in japanese.

So my question is : how do I combine plotscripts commands so that all the children
change their palette and appear selected and whole this at the same time?

Code: Select all

 if(keypress(key:down)) then, begin
    card machine handling:=look up slice (sli: cmok key)
    set sprite child?
    end #end for the if 
As always thanks in advance for your answers and pieces of advice!
Last edited by bis_senchi on Sun Mar 07, 2021 12:12 pm, edited 1 time in total.
bis_senchi
Red Slime
Posts: 64
Joined: Sat Apr 20, 2019 8:59 am

Post by bis_senchi »

Thank you Sword Play.
I finally managed to play the GameNumPad and even edit the rpg file. There's are an error message certainly due to the fact you're using a nigh-built.

What you have done is really what I would to do. Thanks a lot
Sadly I open the .txt file and there some part of the plotscripting that I still don't understand T_T

I'll come back to it later when my plotscripting knowledge has improved.
I still have trouble with selection and also child in slice collection. So I'll tackle this difficulty finds.
I'll come back to your script in NumPad.rpg later.
Thanks a million for making a sample rpg file for me. :)

Here is my new problem
Image

Code: Select all


# Trunk Menu: access to the cards in your trunk. You can pick card from there to your Deck 
plotscript, trunk menu, begin

suspend player
suspend npcs

variable (menu items2, menu cursor, collection)

collection:= load slice collection (2)
# I assume it has the "menu items" lookup code
menu items2 := lookup slice (sli: menu items, collection)

# And the menu cursor slice too, lookup code "menu cursor"
cursor := lookup slice (sli: menu cursor, collection)


while (true) do (
  if (key press (use key)) then (
    # Activate selected item (fill this in
    switch (selection) do (
      case(0) do, begin	 #Monster 1 Blue Eyes
	  $10="this is the legendary blue eyes white dragon"
	  wait (3)
	  show text box (88)
	  wait for text box
	  clear string (10)
	  end #end for case 0
	  
	  case(1) do, begin #Monster 2 Mystical Elf
	  $10="this is the Mystical Elf"
	  wait (3)
	  show text box (88)
	  wait for text box
	  clear string (10)
	  end #end for case 1
	  
      case(2) do, begin #Monster 3 Hitosu Me Giant
	  $10="this is Histosu me Giant"
	  wait (3)
	  show text box (88)
	  wait for text box
	  clear string (10)
	  end #end for case 2
	  
	  case(3) do, begin #Monster 3 Baby Dragon
	  $10="this is Baby Dragon"
	  wait (3)
	  show text box (88)
	  wait for text box
	  clear string (10)
	  end #end for case 3
	  
	  case(4) do, begin #Monster 4 Ryu Kishin
	  $10="this is Ryu Kishin"
	  wait (3)
	  show text box (88)
	  wait for text box
	  clear string (10)
	  end #end for case 4
	  
	  case(5) do, begin #Monster 5 Feral Imp
	  $10="this is Ryu Kishin"
	  wait (3)
	  show text box (88)
	  wait for text box
	  clear string (10)
	  end #end for case 5
	  
	  case(6) do, begin #Monster 6 Winged dragon
	  $10="this is Winged dragon, guardian of the forteress"
	  wait (3)
	  show text box (88)
	  wait for text box
	  clear string (10)
	  end #end for case 6
	  
	  
    ) #end for switch
    break  # exit
  )#end for the if


  # First change the currently selected slice to deselected appearence
  # (for simplicity, do this even if the selection doesn't change)
  sltest := slice child (menu items, selection)  # This is the slice for the (previous) selected item, which I assume is a text slice
  set text color (sltest, 15)  # Change this to normal text colour!

  # Change the selection
  if (key press(up key) || key press(down key)) then (selection -= 1)
  if (selection == -1) then (selection := 6)  # wrap around from first to last
  if (selection == 5) then (selection := 0) # wrap around from last to first
  

 # Then update the selected menu item to correct appearance
  sltest := slice child (menu items, selection)  # Slice for new selection
  set text color (sltest, 7)  # Change this to highlighted text colour!

  # Move the cursor
  put slice (cursor, slice x (sltest)-- -15, slice y (sltest)-- 1)
  
  wait
)
 

free slice (collection)

resume player
resume npcs
end#end for the script
For the code I took back the one made for my first menu in a previous threat which I also
tried to translated japanese
I started for the code because you have a lot of function in common the cursor which highltext
the arrows.

As it is right know, the code is full invalid slice handle. The command set text color and slice x and slice y don't work. As always any comments and pieces of advice are welcomed.
User avatar
SwordPlay
Chemical Slime
Posts: 966
Joined: Sun Jan 22, 2017 9:32 am
Location: London, England
Contact:

Post by SwordPlay »

if you have an invalid slice handle, there are some things you can do

1. you can check if a slice is valid. "slice is valid (sl)"
you can also use "slice is text (sl)" to check if its a text
you can put this into your script to make them fool-proof and not give errors.
IF(slice is text(Sl))THEN(set text color(sl,col))

2. even if you get a slice, you might get another slice by accident which is not the one you intended
You can do things to the slices so that you can see on-screen which slice you have a handle to.
For example, moving a slice up/down/left/right. changing its color. etc.,
you can also check its slice number.

3. remove it and test it separately
separate working/non-working parts.
you can try to comment out the lines which are giving you errors.

please take a screen shot of your error messages with F12, or send the rpg file, and i, or someone, will have a look at it.


I tried to recreate your script. I dont know if it works for you.

Code: Select all

# Trunk Menu: access to the cards in your trunk. You can pick card from there to your Deck
plotscript, trunk menu, begin

suspend player
suspend npcs

variable (menu items
, cursor, collection)

collection:= load slice collection (2)
# I assume it has the "menu items" lookup code
menu items := lookup slice (sli: menu items, collection)

# And the menu cursor slice too, lookup code "menu cursor"
cursor := lookup slice (sli: menu cursor, collection)

variable(selection, sltest)

while (true) do (
  if (key press (use key)) then (
    # Activate selected item (fill this in
    switch (selection) do (
      case(0) do, begin    #Monster 1 Blue Eyes
     $10="this is the legendary blue eyes white dragon"
     wait (3)
     show text box (88)
     wait for text box
     clear string (10)
     end #end for case 0
    
     case(1) do, begin #Monster 2 Mystical Elf
     $10="this is the Mystical Elf"
     wait (3)
     show text box (88)
     wait for text box
     clear string (10)
     end #end for case 1
    
      case(2) do, begin #Monster 3 Hitosu Me Giant
     $10="this is Histosu me Giant"
     wait (3)
     show text box (88)
     wait for text box
     clear string (10)
     end #end for case 2
    
     case(3) do, begin #Monster 3 Baby Dragon
     $10="this is Baby Dragon"
     wait (3)
     show text box (88)
     wait for text box
     clear string (10)
     end #end for case 3
    
     case(4) do, begin #Monster 4 Ryu Kishin
     $10="this is Ryu Kishin"
     wait (3)
     show text box (88)
     wait for text box
     clear string (10)
     end #end for case 4
    
     case(5) do, begin #Monster 5 Feral Imp
     $10="this is Ryu Kishin"
     wait (3)
     show text box (88)
     wait for text box
     clear string (10)
     end #end for case 5
    
     case(6) do, begin #Monster 6 Winged dragon
     $10="this is Winged dragon, guardian of the forteress"
     wait (3)
     show text box (88)
     wait for text box
     clear string (10)
     end #end for case 6
    
    
    ) #end for switch
    break  # exit
  )#end for the if


  # First change the currently selected slice to deselected appearence
  # (for simplicity, do this even if the selection doesn't change)
  sltest := slice child (menu items, selection)  # This is the slice for the (previous) selected item, which I assume is a text slice
  set text color (sltest, 15)  # Change this to normal text colour!

  # Change the selection
  if (key press(up key) || key press(down key)) then (selection -= 1)
  if (selection == -1) then (selection := 5)  # wrap around from first to last
  if (selection == 6) then (selection := 0) # wrap around from last to first
 show value(selection)

 # Then update the selected menu item to correct appearance
  sltest := slice child (menu items, selection)  # Slice for new selection
  set text color (sltest, 7)  # Change this to highlighted text colour!

  # Move the cursor
put slice (cursor, slice screen x (sltest)-- -15, slice screen y (sltest)-- 1) # 
 
  wait
)
 

free slice (collection)

resume player
resume npcs
end#end for the script 

put slice (cursor, slice screen x (sltest)-- -15, slice screen y (sltest)-- 1) #
If you look at the slices in the slice editor, you can see the x/y of the children is (0,0) relative to parent
so they all have the same x/y and the cursor will not move.
you want to get their x/y position on screen.
so you write:

put slice (cursor, slice screen x (sltest)-- -15, slice screen y (sltest)-- 1) #

alternatively you can set the cursor Y position to
(size of row)*slice child index

for example, in this script above, it would be
put slice (cursor, 15, 20*(slice child index(sltest)))


there is a minor change here. because of a mistake, it does not loop properly in your script.
if (selection == -1) then (selection := 5) # wrap around from first to last
if (selection == 6) then (selection := 0) # wrap around from last to first

you can do this as well

variable(upper limit, lower limit)
lower limit:=0
upper limit:=5

if (selection < lower limit) then (selection := upper limit) # wrap around from first to last
if (selection > upper limit) then (selection := lower limit) # wrap around from last to first
Attachments
bis senchi script0008.png
bis senchi script0008.png (5.6 KiB) Viewed 3381 times
bis senchi script0007.gif
bis senchi script0007.gif (6.67 KiB) Viewed 3384 times
Last edited by SwordPlay on Sun Mar 14, 2021 9:56 am, edited 6 times in total.
"Imagination. Life is your creation."
bis_senchi
Red Slime
Posts: 64
Joined: Sat Apr 20, 2019 8:59 am

I tried to test only a piece of the code but....

Post by bis_senchi »

As always thanks a lot for answering so quickly

I tried to test only the parts of the code as you suggested, I but I got another error: the script
was stuck into a infinite loop.

Here screenshots for the errors

Image

Image

Image

Image

As you can see they some of them but there are all linked to slice handling. So the variable
may problems to find the elements in the slice collection and triggering accordingly...
Last edited by bis_senchi on Mon Mar 15, 2021 5:43 am, edited 1 time in total.
User avatar
SwordPlay
Chemical Slime
Posts: 966
Joined: Sun Jan 22, 2017 9:32 am
Location: London, England
Contact:

Post by SwordPlay »

there is a menu option "Enter Script Debugger". From here you will see more exactly where your script has failed.
You can also use "Enter Slice Debugger" to view slices in more detail.
"Imagination. Life is your creation."
bis_senchi
Red Slime
Posts: 64
Joined: Sat Apr 20, 2019 8:59 am

Post by bis_senchi »

Here are the screenshots for the errors.


Image

Image

Image

Image

Image

Image

Image

Image

I've never used the slice debugger. How am I suppose to understand the screenshot?
Have a nice day!
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7658
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

The script debugger is saying that in the script "trunkmenu" there is an infinite "while" loop that has no wait commands in it.

If you can show us your current "trunkmenu" script, we may be able to spot the problem
bis_senchi
Red Slime
Posts: 64
Joined: Sat Apr 20, 2019 8:59 am

Post by bis_senchi »

Thanks for interest Bob!

I see my problem is that there is a while loop which can't stop. Indeed that could be the problem.

Here is the script you asked me to post. To be complete, this script is launch from a menu item of another called "YuGIOh Menu". So I also included them in the post along with their script definition.

Code: Select all

define script &#40;38, trunk menu, none&#41;

#----------------------------------------------------------------------------------------------
# Trunk Menu&#58; access to the cars in your trunk. You can pick card from there to your Deck, just like Kaiba 
plotscript, trunk menu, begin

suspend player
suspend npcs

variable &#40;menu items2, menu cursor, collection&#41;

collection&#58;= load slice collection &#40;2&#41;
# I assume it has the "menu items" lookup code
menu items2 &#58;= lookup slice &#40;sli&#58; menu items, collection&#41;

# And the menu cursor slice too, lookup code "menu cursor"
cursor &#58;= lookup slice &#40;sli&#58; menu cursor, collection&#41;


while &#40;true&#41; do &#40;
  if &#40;key press &#40;use key&#41;&#41; then &#40;
    # Activate selected item &#40;fill this in
    switch &#40;selection&#41; do &#40;
      case&#40;0&#41; do, begin	 #Monster 1 Blue Eyes
	  $10="this is the legendary blue eyes white dragon"
	  wait &#40;3&#41;
	  show text box &#40;88&#41;
	  wait for text box
	  clear string &#40;10&#41;
	  end #end for case 0
	  
	  case&#40;1&#41; do, begin #Monster 2 Mystical Elf
	  $10="this is the Mystical Elf"
	  wait &#40;3&#41;
	  show text box &#40;88&#41;
	  wait for text box
	  clear string &#40;10&#41;
	  end #end for case 1
	  
      case&#40;2&#41; do, begin #Monster 3 Hitosu Me Giant
	  $10="this is Histosu me Giant"
	  wait &#40;3&#41;
	  show text box &#40;88&#41;
	  wait for text box
	  clear string &#40;10&#41;
	  end #end for case 2
	  
	  case&#40;3&#41; do, begin #Monster 3 Baby Dragon
	  $10="this is Baby Dragon"
	  wait &#40;3&#41;
	  show text box &#40;88&#41;
	  wait for text box
	  clear string &#40;10&#41;
	  end #end for case 3
	  
	  case&#40;4&#41; do, begin #Monster 4 Ryu Kishin
	  $10="this is Ryu Kishin"
	  wait &#40;3&#41;
	  show text box &#40;88&#41;
	  wait for text box
	  clear string &#40;10&#41;
	  end #end for case 4
	  
	  case&#40;5&#41; do, begin #Monster 5 Feral Imp
	  $10="this is Ryu Kishin"
	  wait &#40;3&#41;
	  show text box &#40;88&#41;
	  wait for text box
	  clear string &#40;10&#41;
	  end #end for case 5
	  
	  case&#40;6&#41; do, begin #Monster 6 Winged dragon
	  $10="this is Winged dragon, guardian of the forteress"
	  wait &#40;3&#41;
	  show text box &#40;88&#41;
	  wait for text box
	  clear string &#40;10&#41;
	  end #end for case 6
	  
	  
    &#41; #end for switch
    break  # exit
  &#41;#end for the if


  # First change the currently selected slice to deselected appearence
  # &#40;for simplicity, do this even if the selection doesn't change&#41;
  sltest &#58;= slice child &#40;menu items, selection&#41;  # This is the slice for the &#40;previous&#41; selected item, which I assume is a text slice
  set text color &#40;sltest, 15&#41;  # Change this to normal text colour!

  # Change the selection
  variable&#40;upper limit, lower limit&#41;
  lower limit&#58;=0
  upper limit&#58;=5

  if &#40;selection < lower limit&#41; then &#40;selection &#58;= upper limit&#41; # wrap around from first to last
  if &#40;selection > upper limit&#41; then &#40;selection &#58;= lower limit&#41; # wrap around from last to first 
  show value &#40;selection&#41;    

  # Then update the selected menu item to correct appearance
  sltest &#58;= slice child &#40;menu items, selection&#41;  # Slice for new selection
  set text color &#40;sltest, 7&#41;  # Change this to highlighted text colour!

  # Move the cursor
  put slice &#40;cursor, 15, 20*&#40;slice child index&#40;sltest&#41;&#41;&#41; 
  
  wait
&#41;
 

free slice &#40;collection&#41;

resume player
resume npcs
end #end for the script
#------------------------------------------------------------------------

Here are the other scripts which interfer. I had the same kind of problems with my pause script
for my sailor moon game and when I wanted to make a npc (Luna) follow the main character / hero 0 (Usagi Tuskino).

If I remember correctly from what I learnt: you can't run a script which is itself inside a script...
except for a automnumber.

I'm thinking about making leave game menu also an autonumber script and I think that may be trunk menu should also become autonumber....

Code: Select all


define script &#40;24, mykeypressedscript,none&#41; #player unable to use keyboard
define script &#40;31, leave game menu, none&#41;
define script &#40;autonumber, game menu, none&#41;
#---------------------------------------------------------------------
# script pour lancer le menu du jeu
plotscript, mykeypressedscript, begin

# il est important que le code pour le menu "if key is pressed reste
# il est important que le code pour le menu "if key is pressed reste
# au début pour que le menu de base n'apparaissent pas 
if &#40;keyval&#40;key&#58;esc&#41;, xor, keyval&#40;key&#58;alt&#41;&#41; then, begin 
if &#40;gamemenuisactive==false&#41; then, begin 
suspend player
suspend npcs
wait &#40;3&#41; #just to be sure everything is suspended before going on
game menu
end, else, begin #thus, leave menu must be true 
leave game menu

end #end of if &#40;game menu is active&#41;
end #end for the if key is pressed

#------------------------------------------------------------------------------------
# game menu script 
plotscript, game menu, begin


switch &#40;main menu behaviour&#41; do, begin
case &#40;0&#41; do, begin
if &#40;check tag&#40;tag&#58; main menu open&#41; == Off&#41; then, begin # if status menu is not already opened open it
open menu &#40;9&#41;
wait &#40;1&#41;
set tag &#40;tag&#58; main menu open, On&#41;
end, else, begin #menu is already opened close it by triggering espace behaviour 0
wait &#40;1&#41;
set tag &#40;tag&#58; main menu open, off&#41;
resume player
resume npcs
end 
end #end for the case 

case &#40;1&#41; do, begin
escape menu behaviour&#58;=0
main menu behaviour&#58;=0
set tag &#40;tag&#58; main menu open, Off&#41;
menu handle&#58;= find menu ID&#40;9&#41;
close menu &#40;menu handle&#41; #main menu
wait &#40;1&#41;
resume player
resume npcs
end #end for the case 

end #end for switch
end #end of the plotscript
#-------------------------------------------------------

# script which leaves the game menu
plotscript, leave game menu, begin

while &#40;gamemenuisactive==true&#41; do, begin

switch &#40;escape menu behaviour&#41; do, begin

case &#40;0&#41; do, begin # only used for reseting menu system when you pass doors
if &#40;check tag&#40;tag&#58; main menu open&#41; == Off&#41; then, begin # if status menu is not already opened close it first
open menu &#40;9&#41;
wait &#40;1&#41;
set tag &#40;tag&#58; main menu open, ON&#41;
escape menu behaviour&#58;=1
end, else, begin

menu handle&#58;= find menu ID &#40;9&#41;
close menu &#40;menu handle&#41; #main menu
main menu behaviour&#58;=0
resume player
resume npcs
escape menu behaviour&#58;=1

end #end for the tag
end # end for the swith case 0

case&#40;1&#41; do, begin # only main menu and status menu are opened
if &#40;check tag&#40;tag&#58; status menu open&#41; == Off&#41; then, begin # if status menu is already opened close it first
gamemenuisactive&#58;= false
escape menu behaviour&#58;=1
wait &#40;1&#41;
status menu
end, else, begin  # if status menu is already closed opened close the top menu
clear string &#40;1&#41;
clear string &#40;2&#41;
gamemenuisactive&#58;= false
wait &#40;1&#41;
advance text box
resume box advance
resume player
resume npcs

end #end for the if check tag
end #end for the swith case 1

case&#40;2&#41; do, begin # only main menu and deck menu are opened
if &#40;check tag&#40;tag&#58; deck menu open&#41; == ON&#41; then, begin # if status menu is already opened close it first
variable &#40;handlegm&#41;
handlegm&#58;= find menu ID &#40;6&#41; 
close menu &#40;handle gm&#41; 
gamemenuisactive&#58;= false
set tag &#40;tag&#58; deck menu open, OFF&#41;
escape menu behaviour&#58;=0
wait &#40;1&#41;
resume player
resume npcs
end, else, begin  # if status menu is already closed opened close the top menu
close menu &#40;top menu&#41; #menu 6 alone -> top menu is required
gamemenuisactive&#58;= false
wait &#40;1&#41;
resume player
resume npcs
end #end for the if check tag
end #end for the swith case 1

case&#40;3&#41; do, begin # only main menu and trunk menu are opened
if &#40;check tag&#40;tag&#58; trunk menu open&#41; == ON&#41; then, begin # if status menu is already opened close it first

handlegm&#58;= find menu ID &#40;8&#41; 
close menu &#40;handle gm&#41; 
gamemenuisactive&#58;= false
set tag &#40;tag&#58; status menu open, OFF&#41;
escape menu behaviour&#58;=0
wait &#40;1&#41;
resume player
resume npcs
end, else, begin  # if status menu is already closed opened close the top menu
close menu &#40;top menu&#41; #menu 6 alone -> top menu is required
gamemenuisactive&#58;= false
wait &#40;1&#41;
resume player
resume npcs
end #end for the if check tag
end #end for the swith case 1


end #end for the while
end #end for the switch

end #end for the script
#---------------------------------------------------------------------------------

Anways as always thanks in advance for the remarks.
Last edited by bis_senchi on Thu Mar 18, 2021 6:16 am, edited 1 time in total.
bis_senchi
Red Slime
Posts: 64
Joined: Sat Apr 20, 2019 8:59 am

So anything strange in the script?

Post by bis_senchi »

So does anybody see something strange in the script?
User avatar
Spoonweaver
Liquid Metal King Slime
Posts: 6461
Joined: Mon Dec 08, 2008 7:07 am
Contact:

Post by Spoonweaver »

looks like you only have 2 issues
infinite while loop
and trying to free slices that are already clear and don't exist.
I see there's a few clear slice commands that don't have slice loading commands anywhere near them, on the second block of code.
bis_senchi
Red Slime
Posts: 64
Joined: Sat Apr 20, 2019 8:59 am

Post by bis_senchi »

Spoonweaver said:
looks like you only have 2 issues infinite while loop and trying to free slices that are already clear and don't exist. I see there's a few clear slice commands that don't have slice loading commands anywhere near them, on the second block of code.
That's it! That's the problem. There should not be only two issues but also one when the script is reseted.

To prevent a while loop for becoming infinite; I need a global variable and turn it true let's say:

Code: Select all

global 74, trunk menu on screen
Then, I add

Code: Select all

while &#40;trunk menu on screen == true&#41; do, begin

-
-
-

trunk menu on screen&#58;= false
wait &#40;1&#41;

end #end for the while
That would be when I press space and want to leave the menu. But my code below is when the script that make appears the menu is launch.
And there is still the problem of selection. When I press the space bar in front of the line mystical elf, I want to be able to display this card data. According to its location mushroom man, page 1/125 the actions will be different. I think I will add quit somewhere on the screen. This way, I'll have only a lines of code to write.

All this time the script "trunk menu" either should still run or keep beeing reset...
I still only have a part of the solution, so please don't hesitate to make remarks and give pieces of advice.

Thanks in advance very much for your help!
Last edited by bis_senchi on Mon Mar 29, 2021 5:52 am, edited 2 times in total.
Post Reply