V
[void]
Guest
I've been trying to create a menu lately, but it just doesn't seem to work right and I don't know why. Maybe someone else can spot something?
Here's the event that creates it, in the player object's [press Enter]:
if room=room_2 or room=room_2_post{
if place_meeting(x,y,obj_wall_room2){
if obj_room2_text_controller.active=0{
instance_create(0,60,obj_textbox);
instance_create(10,70,obj_room2_text);
}
}
else
{
if !instance_exists(obj_menu_box){
instance_create(view_xview[0],view_yview[0],obj_menu_box);
instance_create(view_xview[0]+10,view_yview[0]+20,obj_menu);
}
}
}
else
{
}
And here's the code from each of the three objects that make up the menu:
Information about object: obj_menu_box
Sprite: spr_menu
Solid: false
Visible: true
Depth: 0
Persistent: true
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:
selecttalk=1;
selectreset=0;
selectquit=0;
selectsave=0;
selectnmm=0;
selectchrys=0;
selecttir=0;
selectsom=0;
image_index=0;
selectgroup=0;
selectruby=0;
selectyes=0;
selectno=0;
Step Event:
execute code:
obj_player.canmove=0;
if sprite_index=spr_menu{
if selectsave=1{
image_index=2;
}
if selectreset=1{
image_index=1;
}
if selecttalk=1{
image_index=0;
}
if selectquit=1{
image_index=3;
}
}
else
{
if sprite_index=spr_menu_decision{
if selectyes=1{
image_index=1;
}
if selectno=1{
image_index=0;
}
}
}
Information about object: obj_menu
Sprite:
Solid: false
Visible: true
Depth: -1
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:
text=1
str[1]=''
textmax=0
i=0
imax=0
nextsound=0
written=0
obj_player.canmove=0;
instance_create(x,y,obj_menu_select);
Destroy Event:
execute code:
obj_player.canmove=1;
Step Event:
execute code:
x=view_xview[0]+10;
y=view_yview[0]+10;
if i=imax{
written=1;
}
obj_player.canmove=0;
execute code:
imax=string_length(str[text])
if i<imax
{
i+=1
}
if keyboard_check_pressed(ord('Z'))
{
if i!=imax
{
i=imax
}
else
{
if text<textmax
{
text+=1
i=0
}
}
}
if i is less than imax
execute code:
nextsound += .5;
if nextsound = 1{
audio_play_sound(snd_plaintext,10,0);
nextsound = 0;
}
if i is equal to imax
stop sound snd_plaintext
Draw Event:
execute code:
draw_set_color(c_white)
draw_set_font(global.hudfontnew)
draw_text_transformed(x,y,string_copy(str[text],0,i),1,1,0)
Information about object: obj_menu_select
Sprite: spr_marker
Solid: false
Visible: true
Depth: -2
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Key Press Event for <Enter> Key:
execute code:
if obj_menu_box.selectsave=1{
game_save(savefile);
obj_menu.str[1]="[GAME SAVED]"
}
if obj_menu_box.selectreset=1{
obj_menu.str[1]="Are you sure? This will destroy all your progress."
obj_menu_box.sprite_index=spr_menu_decision;
obj_menu_box.selectno=1;
}
if obj_menu_box.selecttalk=1{
if global.nmmspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Nightmare Moon"
}
if global.chrysspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Chrysalis"
}
if global.somspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Sombra"
}
if global.tirspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Tirek"
}
if global.chrysspared=1 and global.somspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Chrysalis
-Talk to Sombra
-Talk to group"
}
if global.chrysspared=1 and global.tirspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Chrysalis
-Talk to Tirek
-Talk to group"
}
if global.somspared=1 and global.tirspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Sombra
-Talk to Tirek
-Talk to group"
}
if global.nmmspared=1 and global.tirspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Nightmare Moon
-Talk to Tirek
-Talk to group"
}
if global.chrysspared=1 and global.tirspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Chrysalis
-Talk to Tirek
-Talk to group"
}
if global.somspared=1 and global.nmmspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Sombra
-Talk to Nightmare Moon
-Talk to group"
}
if global.chrysspared=1 and global.somspared=1 and global.tirspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Chrysalis
-Talk to Sombra
-Talk to Tirek
-Talk to group"
}
if global.nmmspared=1 and global.chrysspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Nightmare Moon
-Talk to Chrysalis
-Talk to group"
}
if global.nmmspared=1 and global.chrysspared=1 and global.somspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Nightmare Moon
-Talk to Chrysalis
-Talk to Sombra
-Talk to group"
}
if global.nmmspared=1 and global.chrysspared=1 and global.tirspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Nightmare Moon
-Talk to Chrysalis
-Talk to Tirek
-Talk to group"
}
if global.nmmspared=1 and global.tirspared=1 and global.somspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Nightmare Moon
-Talk to Tirek
-Talk to Sombra
-Talk to group"
}
if global.nmmspared=1 and global.chrysspared=1 and global.somspared=1 and global.tirspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Nightmare Moon
-Talk to Chrysalis
-Talk to Sombra
-Talk to Tirek
-Talk to group"
}
else
{
obj_menu.str[1]="-Call Ruby"
}
}
if obj_menu_box.selectquit=1{
room_goto(rm_gameover);
}
else
{
obj_menu.str[1]="What would you like to do?"
}
Key Press Event for <Left> Key:
execute code:
audio_play_sound(snd_select,1,false);
if obj_menu_box.sprite_index=spr_menu{
if obj_menu_box.selectreset=1{
obj_menu_box.selectreset=0;
obj_menu_box.selecttalk=1;
}
if obj_menu_box.selecttalk=1{
obj_menu_box.selectquit=1;
obj_menu_box.selecttalk=0;
}
if obj_menu_box.selectsave=1{
obj_menu_box.selectreset=1;
obj_menu_box.selectsave=0;
}
if obj_menu_box.selectquit=1{
obj_menu_box.selectsave=1;
obj_menu_box.selectquit=0;
}
}
else
{
if obj_menu_box.sprite_index=spr_menu_decision{
if obj_menu_box.selectyes=1{
obj_menu_box.selectyes=0;
obj_menu_box.selectno=1;
}
if obj_menu_box.selectno=1{
obj_menu_box.selectyes=1;
obj_menu_box.selectno=0;
}
}
}
Key Press Event for <Right> Key:
execute code:
audio_play_sound(snd_select,1,false);
if obj_menu_box.sprite_index=spr_menu{
if obj_menu_box.selectreset=1{
obj_menu_box.selectreset=0;
obj_menu_box.selectsave=1;
}
if obj_menu_box.selecttalk=1{
obj_menu_box.selectreset=1;
obj_menu_box.selecttalk=0;
}
if obj_menu_box.selectsave=1{
obj_menu_box.selectsave=0;
obj_menu_box.selectquit=1;
}
if obj_menu_box.selectquit=1{
obj_menu_box.selectquit=0;
obj_menu_box.selecttalk=1;
}
}
else
{
if obj_menu_box.sprite_index=spr_menu_decision{
if obj_menu_box.selectyes=1{
obj_menu_box.selectyes=0;
obj_menu_box.selectno=1;
}
if obj_menu_box.selectno=1{
obj_menu_box.selectyes=1;
obj_menu_box.selectno=0;
}
}
}
So where I'm having trouble is during the key press Left and Right events for obj_menu_select.
When right is pressed and RESET is selected, it goes to TALK instead of SAVE. When left is pressed and RESET is selected, it goes to SAVE instead of TALK. It never, ever goes to QUIT, if right is pressed when on SAVE or left is pressed when on TALK.
Ideas?
Here's the event that creates it, in the player object's [press Enter]:
if room=room_2 or room=room_2_post{
if place_meeting(x,y,obj_wall_room2){
if obj_room2_text_controller.active=0{
instance_create(0,60,obj_textbox);
instance_create(10,70,obj_room2_text);
}
}
else
{
if !instance_exists(obj_menu_box){
instance_create(view_xview[0],view_yview[0],obj_menu_box);
instance_create(view_xview[0]+10,view_yview[0]+20,obj_menu);
}
}
}
else
{
}
And here's the code from each of the three objects that make up the menu:
Information about object: obj_menu_box
Sprite: spr_menu
Solid: false
Visible: true
Depth: 0
Persistent: true
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:
selecttalk=1;
selectreset=0;
selectquit=0;
selectsave=0;
selectnmm=0;
selectchrys=0;
selecttir=0;
selectsom=0;
image_index=0;
selectgroup=0;
selectruby=0;
selectyes=0;
selectno=0;
Step Event:
execute code:
obj_player.canmove=0;
if sprite_index=spr_menu{
if selectsave=1{
image_index=2;
}
if selectreset=1{
image_index=1;
}
if selecttalk=1{
image_index=0;
}
if selectquit=1{
image_index=3;
}
}
else
{
if sprite_index=spr_menu_decision{
if selectyes=1{
image_index=1;
}
if selectno=1{
image_index=0;
}
}
}
Information about object: obj_menu
Sprite:
Solid: false
Visible: true
Depth: -1
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:
text=1
str[1]=''
textmax=0
i=0
imax=0
nextsound=0
written=0
obj_player.canmove=0;
instance_create(x,y,obj_menu_select);
Destroy Event:
execute code:
obj_player.canmove=1;
Step Event:
execute code:
x=view_xview[0]+10;
y=view_yview[0]+10;
if i=imax{
written=1;
}
obj_player.canmove=0;
execute code:
imax=string_length(str[text])
if i<imax
{
i+=1
}
if keyboard_check_pressed(ord('Z'))
{
if i!=imax
{
i=imax
}
else
{
if text<textmax
{
text+=1
i=0
}
}
}
if i is less than imax
execute code:
nextsound += .5;
if nextsound = 1{
audio_play_sound(snd_plaintext,10,0);
nextsound = 0;
}
if i is equal to imax
stop sound snd_plaintext
Draw Event:
execute code:
draw_set_color(c_white)
draw_set_font(global.hudfontnew)
draw_text_transformed(x,y,string_copy(str[text],0,i),1,1,0)
Information about object: obj_menu_select
Sprite: spr_marker
Solid: false
Visible: true
Depth: -2
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Key Press Event for <Enter> Key:
execute code:
if obj_menu_box.selectsave=1{
game_save(savefile);
obj_menu.str[1]="[GAME SAVED]"
}
if obj_menu_box.selectreset=1{
obj_menu.str[1]="Are you sure? This will destroy all your progress."
obj_menu_box.sprite_index=spr_menu_decision;
obj_menu_box.selectno=1;
}
if obj_menu_box.selecttalk=1{
if global.nmmspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Nightmare Moon"
}
if global.chrysspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Chrysalis"
}
if global.somspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Sombra"
}
if global.tirspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Tirek"
}
if global.chrysspared=1 and global.somspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Chrysalis
-Talk to Sombra
-Talk to group"
}
if global.chrysspared=1 and global.tirspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Chrysalis
-Talk to Tirek
-Talk to group"
}
if global.somspared=1 and global.tirspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Sombra
-Talk to Tirek
-Talk to group"
}
if global.nmmspared=1 and global.tirspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Nightmare Moon
-Talk to Tirek
-Talk to group"
}
if global.chrysspared=1 and global.tirspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Chrysalis
-Talk to Tirek
-Talk to group"
}
if global.somspared=1 and global.nmmspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Sombra
-Talk to Nightmare Moon
-Talk to group"
}
if global.chrysspared=1 and global.somspared=1 and global.tirspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Chrysalis
-Talk to Sombra
-Talk to Tirek
-Talk to group"
}
if global.nmmspared=1 and global.chrysspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Nightmare Moon
-Talk to Chrysalis
-Talk to group"
}
if global.nmmspared=1 and global.chrysspared=1 and global.somspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Nightmare Moon
-Talk to Chrysalis
-Talk to Sombra
-Talk to group"
}
if global.nmmspared=1 and global.chrysspared=1 and global.tirspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Nightmare Moon
-Talk to Chrysalis
-Talk to Tirek
-Talk to group"
}
if global.nmmspared=1 and global.tirspared=1 and global.somspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Nightmare Moon
-Talk to Tirek
-Talk to Sombra
-Talk to group"
}
if global.nmmspared=1 and global.chrysspared=1 and global.somspared=1 and global.tirspared=1{
obj_menu.str[1]="-Call Ruby
-Talk to Nightmare Moon
-Talk to Chrysalis
-Talk to Sombra
-Talk to Tirek
-Talk to group"
}
else
{
obj_menu.str[1]="-Call Ruby"
}
}
if obj_menu_box.selectquit=1{
room_goto(rm_gameover);
}
else
{
obj_menu.str[1]="What would you like to do?"
}
Key Press Event for <Left> Key:
execute code:
audio_play_sound(snd_select,1,false);
if obj_menu_box.sprite_index=spr_menu{
if obj_menu_box.selectreset=1{
obj_menu_box.selectreset=0;
obj_menu_box.selecttalk=1;
}
if obj_menu_box.selecttalk=1{
obj_menu_box.selectquit=1;
obj_menu_box.selecttalk=0;
}
if obj_menu_box.selectsave=1{
obj_menu_box.selectreset=1;
obj_menu_box.selectsave=0;
}
if obj_menu_box.selectquit=1{
obj_menu_box.selectsave=1;
obj_menu_box.selectquit=0;
}
}
else
{
if obj_menu_box.sprite_index=spr_menu_decision{
if obj_menu_box.selectyes=1{
obj_menu_box.selectyes=0;
obj_menu_box.selectno=1;
}
if obj_menu_box.selectno=1{
obj_menu_box.selectyes=1;
obj_menu_box.selectno=0;
}
}
}
Key Press Event for <Right> Key:
execute code:
audio_play_sound(snd_select,1,false);
if obj_menu_box.sprite_index=spr_menu{
if obj_menu_box.selectreset=1{
obj_menu_box.selectreset=0;
obj_menu_box.selectsave=1;
}
if obj_menu_box.selecttalk=1{
obj_menu_box.selectreset=1;
obj_menu_box.selecttalk=0;
}
if obj_menu_box.selectsave=1{
obj_menu_box.selectsave=0;
obj_menu_box.selectquit=1;
}
if obj_menu_box.selectquit=1{
obj_menu_box.selectquit=0;
obj_menu_box.selecttalk=1;
}
}
else
{
if obj_menu_box.sprite_index=spr_menu_decision{
if obj_menu_box.selectyes=1{
obj_menu_box.selectyes=0;
obj_menu_box.selectno=1;
}
if obj_menu_box.selectno=1{
obj_menu_box.selectyes=1;
obj_menu_box.selectno=0;
}
}
}
So where I'm having trouble is during the key press Left and Right events for obj_menu_select.
When right is pressed and RESET is selected, it goes to TALK instead of SAVE. When left is pressed and RESET is selected, it goes to SAVE instead of TALK. It never, ever goes to QUIT, if right is pressed when on SAVE or left is pressed when on TALK.
Ideas?