• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Have text only appear in certain rooms

B

BandiPat

Guest
It's been bugging me how I can't seem to figure this out, and anything logical I could come up with did nothing. Either the HUD only winds up as "invisible" for one of the rooms, or none at all. Not as I've intended it to do.
So what I'm trying to do is have an object draw out the HUD, unless you're in one of a few rooms. What I have now is this:

Code:
if !room = rm_menu || rm_warp_main
    {
    draw_set_font(fnt_hud); 
    draw_set_halign(fa_left);
    draw_set_valign(fa_center);
    draw_set_colour(c_red);
    draw_text(view_xview+1062,view_yview+32,"DEATHS: " + string(global.deaths));
    draw_set_colour(c_yellow);
    draw_text(view_xview+32,view_yview+32,"COINS LEFT: " + string(global.coins));
    draw_set_colour(c_aqua);
    draw_text(view_xview+640,view_yview+32,levelname);
    }
I've also tried using these:
Code:
if !room = rm_menu || !room = rm_warp_main

if !room = rm_menu && rm_warp_main

if !room = rm_menu && !room = rm_warp_main
Again, none of these did anything. They would either work for only the first room listed or not at all. I'm stumped.
 

RangerX

Member
Use a switch in your draw event. Basically but a room per case (or more if some are identical)

Code:
switch (room_name)
{
      case Room 1:
              {
               draw what appears in room 1;
               }
      break;

      case Room 2:
              {
               draw what appears in room 2;
              }
      break;
}

and so on.
 
T

TDSrock

Guest
The main issue here I suspect is that those if statements are malformed. GML thinks it's all great but when interputing them I guess it will make a mistake with this.
The full correct syntax for a if stamtent is as follows:
Code:
if ( conditional ) {
   //do stuff
}
A complex if stament could look something like this(only using Boolean values)
Code:
if( bob || (greg && !geoff)){
   //does stuff if bob is true or if both greg is true AND geoff is false
}
if( bob == true || (greg == true && geoff != true)){
   //does stuff if bob is true or if both greg is true AND geoff is false
}
Maybe this will clear it up?

A switch is a logical way to go here though as you will constantly be checking the same value, so adding more things will be allot easier.
A good thing to know with switches is that there is also a Default case.
That case will run if all cases above it do not work.

EDIT: Aura is spot on. Something I failed to notice. Your if statements are indeed even more malformed then I thought. GML error handles it away though... Ontop of the fact that your using Boolean comparison operators wrong. I've added a fully written out version of the same if statement I had originally to show how comparisons should be done as well. Note that it makes no sense to check Booleans using them as the operation returns a Boolean.
 
Last edited by a moderator:
A

Aura

Guest
That's not how you use || and &&. It should have complete expressions on both of its sides, so it should be room != rm_menu && room != rm_wrap_menu not room != rm_menu && rm_wrap_menu.

Code:
if (room != rm_menu && room != rm_wrap_menu)
{
   //...
}
...wil make the text get drawn in all rooms that you place an instance of this object in but rm_menu and rm_wrap_up.

Code:
if (room == rm_menu || room == rm_wrap_menu)
{
   //...
}
...will make the text get drawn only in rm_menu or rm_main.
 
S

Snail Man

Guest
I'd say that your order of operations in your code is screwing you up. Saying "!room == rm_menu" translates to if the NOT ROOM is rm_menu, which makes no sense. Change it to "room != rm_menu" to fix this issue
 
Top