wtf why isn't this working

Posted by NeutralReiddHotel on June 7, 2015, 12:36 a.m.

since i don't frequent the GMC anymore or yoyogames i'd figure i ask here

why this no work

   if (heal_step=0) {
      heal_number=-1;
      i=0;
      for (i=0;i>=6;i+=1) {
         if (slot[i+1,0]!=0) { // meaning in slot i, is there a species sitting there?
            heal_number+=1;
         } else { // if there isn't, end the loop
            i=6;
         }
         show_message("hey look at me i work");
      }
      heal_monitor=0;
      heal_ball_number=0;
      draw_heal_animation=true;
      heal_counter=30;
      show_message(string(heal_number));
   }

in specific, this part:

      for (i=0;i>=6;i+=1) {
         if (slot[i+1,0]!=0) { // meaning in slot i, is there a species sitting there?
            heal_number+=1;
         } else { // if there isn't, end the loop
            i=6;
         }
         show_message("hey look at me i work");
      }

running this gives me nothing. i fear i simply don't know how to run for statements, but I did one in another part of my game recently, and i have no idea why this doesn't work.

here's the video running:

so like, the video shows that the show_message("hey look at me i work"); part never runs, but the show_message(string(heal_number)); does. my goal is to make the heal_number equal the number of pokemon in my party, in this case, 2.

slot[0,0] is slot 0, and species id. slot 0 holds nothing

slot[1,0] holds charmander

slot[2,0] holds ghost.

what do i do now? i'm confused and i've spent weeks breaking my head with one line of code and i'm trying to avoid it this time if i can, because something tells me this is a SUPER simple fix im simply not seeing at the moment.

without this, healing a pokemon in my game will forever look retarded :(

Comments

Toast 9 years, 6 months ago

Curly braces in game maker are so annoying, you start off writing

if (blah) {

you then have to either put a

}

on the next line and go back up or

//write something inside curly brackets

and then the { is left open until you get down to }

goddamn that pisses me off

edit: ok I started looking how to actually do this properly because it annoys me so much. so far my best method is:

press F2, 2, write the condition, ctrl+down, ctrl+down, ctrl+right, ctrl+del, write the statement

Alert Games 9 years, 6 months ago

@Toast: I am very spoiled by VS2013 where it does all of that for you.

I used to write the brackets in the same line before I got used to the extra line. It looks better when nesting and indenting in my opinion. The same line is standard for javascript.

However, the standards for PHP and C# (and other languages) is to do it in this format

class ClassName
{
    void Method()
    {
        //code goes here. Takes extra line, but looks cleaner and spaced. Use F12
        //and built in IDE functions to maneuver through code... which GM doesnt really have
    }
}

Doesn't really matter for small amounts of code… but for consistency is nice.

Moikle 9 years, 6 months ago

My IDE corrects it to the way I like it with auto-format.

Quote:
I used to write the brackets in the same line before I got used to the extra line.

heh funny, I did the reverse

Castypher 9 years, 6 months ago

Standards only matter if you're working in a team. They're easy to adjust to if you ever need to join an existing project in the future. If you're the only one actively using the code, and a particular coding standard works for you, then by all means continue using it.

I don't believe anyone asked for a crash course and this isn't really helpful to Reidd. Don't force your standards on someone else, that's exactly what snobby programmers do. They are also the ones who say "Everyone else is doing it wrong and only my way is right." And then they rewrite the entire program and two months later, the code looks slightly prettier and nothing new got done.

Polyman's feedback, on the other hand, is helpful. More so than telling someone their brackets are in the wrong place.

Also, VS2013's new auto-formatting is incredibly annoying to me because it assumes that when I want to add a new bracket around an existing section (such as adding a new condition), it needs to close it immediately instead of letting me decide where that section ends. And then it starts fucking up my indentation and no one is happy.

Toast 9 years, 6 months ago

@Alert Yeah I was talking about game maker specifically. I have Sublime Text 2 and use it for most things, it's rather good. Game maker is rather not good

Alert Games 9 years, 6 months ago

On the contrary, it helps when developers discuss their preferences and reasoning behind them. Regardless, perhaps I should have said that if you are going to program in one of those languages, that is the suggested standard.

I guess it doesn't really matter because you can auto format a whole document before working on it anyway. As long as you indent properly either way is readable.

I like the auto-formatting cause I can code the same was as reidd here and VS will format it to 'standard' for me automatically. But anyway… Yeah GM better fix their shit before I make a better code editor for it or something

NeutralReiddHotel 9 years, 6 months ago

Quote:
imagine there's no heaven
overrated hippie song.

Quote:
Saw one of your other videos with the music, and it sounds amazing. I haven't kept up with your project at all, but I would play it when its closer to done
don't worry, there's not much to keep up. what you've heard of is what i've done: very little. but thanks for wanting to try it out :) if it's not fun at least you'll enjoy how close it is to an emulator and wonder, gee- why didn't reidd use all this time and effort on something that's not a fangame

Quote:
Are you running Game Maker on linux? You can do that now?
i do this strictly because it somehow runs better on linux performance-wise and I like running linux better than booting windows 8. but no, there's no sound, so I woulnd't recommend it for playing games. midi's don't work and wav's don't always work either.

Quote:
polysterene man best 64d member of the year award for exceeding excellence
this isn't sarcasm. considering how sarcastic the internet is, i feel like i have to clarify

i do appreciate the time u took to look over my code. this is private shit, and having my code be private means that i do a lot of stupid shit that goes unchecked. so the fact that you went over mine and saw the mistakes does mean a lot because i'll take learning anywhere i can get it nowadays. i agree, i shouldn't be breaking my head and instead be asking more questions here..

in the third block of code u wrote, i actually DO want it to skip over a result if for example, i have two spots taken by spots one and two, but i have one empty in three but yet somehow have one in four. i want it to skip that fourth slot because it shouldn't have been there to begin with, that's not how the pokemon games run. the pokemon party of six slots is under very high supervision, and the slots are very carefully placed and not handed out like candy, so there should never be an empty spot before a full slot. that part is intentional.

and i only wanted to explain that because i remember a comment from you years ago that said you didn't play many games growing up so you don't know how a lot of popular games work. i'd figure i explain that part, but i will fix the other things you suggested. thanks man :) and tell me if i got the wrong member on that game-less childhood, of course.

Quote:
Also put the curly braces on a new line after the statement conditions? … plz…
no.

Quote:
I don't believe anyone asked for a crash course and this isn't really helpful to Reidd. Don't force your standards on someone else, that's exactly what snobby programmers do.
thanks for having my back kilin, but don't worry since i don't feel anything is being forced to me. i never agreed to change my style of coding to begin with. after many, many years of coding like this i don't see a good reason to re-write my own internal wiring PLUS my game. unless i'm getting paid to do it, to which i see no cash with the offer.

Polystyrene Man 9 years, 6 months ago

Aw Steve, I meant no harm and it looks like Reidd appreciated the help. I don't think of these as stupid mistakes – in fact reidd's workarounds are pretty clever. Having someone read/nitpick over your shoulder is indeed annoying, that I can understand

Reidd, you're thinking of the right person. I played a select few games growing up, and continue to not play many games as an adult ;)

Moikle 9 years, 6 months ago

I find that making mistakes is the best way to learn the inner workings of WHY you do things a certain way. When everything is working, it just works, and it is harder to grasp exactly how it does.

eagly 9 years, 6 months ago

Quote:
When everything is working, it just works, and it is harder to grasp exactly how it does.
There was a guy on my uni course like this. He'd get help from the tutors for ages in every tutorial and whenever I asked him why he was doing something the way he was, or to explain his code, he'd just say "I dunno, it just works."

It was immensely frustrating.