Jump to content


Photo

Unknown Variable?


  • Please log in to reply
39 replies to this topic

#1 greatvenom

greatvenom

    GMC Member

  • GMC Member
  • 41 posts

Posted 24 March 2011 - 04:33 PM

Hi, my variable (enemy_attack) is unknown. It's an error message I get. I have already set enemy_attack to 1 with the Create event, but when I go to play the game, it says its an unknown variable.
I don't see it anywhere in the forums, so can someone please help?
Thanks
  • 0

#2 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • Retired Staff
  • 9314 posts
  • Version:Unknown

Posted 24 March 2011 - 05:11 PM

So you set enemy_attack's value in the CREATE event of an object? And where are you trying to access it?

-IMP ;) :)
  • 0

#3 onyex

onyex

    GMC Member

  • New Member
  • 10 posts

Posted 24 March 2011 - 07:56 PM

Make sure you are creating the variable in the same object you are using the "enemy attack" variable in.

For example:
obj_enemy
-create
--variable (enemy_attack = 1)
-collision (enemy)
--create object (enemy attack; 0,0)

-NOT-

obj_enemy
-create
--variable (enemy_attack = 1)

obj_player
-collision (enemy)
--create object (enemy attack; 0,0)

In order to do the example above, a global variable must be created in order for different objects to see the variable.

I hope this helps!

-onyex
  • 0

#4 greatvenom

greatvenom

    GMC Member

  • GMC Member
  • 41 posts

Posted 24 March 2011 - 07:58 PM

My friend from school helped me out, so it was solved. It was a Game Maker error, so I had to duplicate an obj_enemy, rename it to obj_tank, and set the enemy_attack to global. It works, so thanks for the help!
  • 0

#5 saim

saim

    GMC Member

  • New Member
  • 1085 posts

Posted 24 March 2011 - 08:26 PM

Just setting enemy_attack as a global variable would do. That's no game maker error.
  • 0

#6 greatvenom

greatvenom

    GMC Member

  • GMC Member
  • 41 posts

Posted 25 March 2011 - 12:39 AM

There was an error, because setting another variable worked before. I mean, I have an odd version of the program, and this has happened before.
  • 0

#7 Canite

Canite

    Canigget

  • GMC Member
  • 1358 posts
  • Version:GM8

Posted 25 March 2011 - 12:42 AM

There was an error, because setting another variable worked before. I mean, I have an odd version of the program, and this has happened before.

Odd version? This not a bug with GM, it is either a mistake you made, or you're using some cracked version of GM.

edit: And if this cracked version can't even recognize declared variables, it's useless, and the free lite edition of GM would be better.

Edited by Canite, 25 March 2011 - 12:43 AM.

  • 0

#8 sabriath

sabriath

    12013

  • GMC Member
  • 3149 posts

Posted 25 March 2011 - 12:47 AM

That's hilarious...here is what I saw:


first post: I have a bucket that I put water into, it's red...but for some reason the blue one has nothing in it.
next post: I fixed it, I painted the red bucket green, and then poured the water all over the ground, now all the buckets have wet bottoms.

awesome!
  • 0

#9 greatvenom

greatvenom

    GMC Member

  • GMC Member
  • 41 posts

Posted 25 March 2011 - 12:50 AM

sabriath... that was completely irrelevant... and no, it's not a crack, I didn't do anything wrong, it just didn't recognize variable attack for some reason, but recognized everything else.
  • 0

#10 sabriath

sabriath

    12013

  • GMC Member
  • 3149 posts

Posted 25 March 2011 - 12:58 AM

sabriath... that was completely irrelevant... and no, it's not a crack, I didn't do anything wrong, it just didn't recognize variable attack for some reason, but recognized everything else.

I'm 100% certain you don't know what you are doing. GM doesn't just randomly ignore commands given to it...it doesn't one day decide "I don't feel like working right now, your variables r belong to me now". It's not INTERCAL, and although bugs do creep in once in awhile where the compiler might skip a gmk block (which is very very very rare), a quick reload should fix the issue. You stated it isn't working at all, so that's not the problem.
  • 0

#11 greatvenom

greatvenom

    GMC Member

  • GMC Member
  • 41 posts

Posted 25 March 2011 - 01:23 AM

Does the word NOVICE mean anything to you?
  • 0

#12 sabriath

sabriath

    12013

  • GMC Member
  • 3149 posts

Posted 25 March 2011 - 02:45 AM

Does the word NOVICE mean anything to you?

nope

there is do, and don't do....no try

A true novice would try to solve a root of a problem without blaming the tools they use. What you did was solve a surface problem (making the variable global doesn't change the fact that you are using it in the wrong place). A lot of the people here are willing to help you solve the root of your problems so that you don't come crawling back in here with the same type of question later. What you did was snubbed the tool because it couldn't possibly be your fault, and now we all know that you'll be coming back in a few weeks with another problem that would have and could have been solved right here right now.
  • 0

#13 greatvenom

greatvenom

    GMC Member

  • GMC Member
  • 41 posts

Posted 25 March 2011 - 03:08 AM

Well you will get no where in life with THAT attitude :P
  • 0

#14 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • Retired Staff
  • 9314 posts
  • Version:Unknown

Posted 25 March 2011 - 04:59 AM

Even if you are a novice, deciding that if something doesn't work right it must be the IDE's fault is ridiculous. That's like saying "I never pressed the power button, but my TV's not turning on, so it must be broken; I can fix it by buying a new TV." Terrible logic to live by, and I'm using the word "logic" lightly.

In fact, though there are plenty of bugs in GM, 90% of the time something doesn't work in ANY language, it's the programmer's fault. Coming from experience, that is.

-IMP ;) :)
  • 0

#15 sabriath

sabriath

    12013

  • GMC Member
  • 3149 posts

Posted 25 March 2011 - 08:17 AM

By the way, my last post had a hidden message in it....if you haven't already seen it, try and find it.
  • 0

#16 MasterOfKings

MasterOfKings

    The True Master

  • GMC Member
  • 4888 posts
  • Version:GM8

Posted 25 March 2011 - 08:23 AM

A poor workman blames his tools... And computers never make mistakes, people cause them to make mistakes.

On that note, I'll leave you all to it.

-MoK
  • 0

#17 saim

saim

    GMC Member

  • New Member
  • 1085 posts

Posted 25 March 2011 - 12:13 PM

You problem was that you were adressing a variable from another object, so the object calling it couldn't recognize it.
When you declared it as a global variable, every object had access to it, includding the one you wanted.
Copying, renaming or anything else wasn't required.

That's true. Honest. No GM error.
While novice, we usually get a lot of bugs that we have a hard time figuring out what went wrong, but usually, that's our logic problems, not the GM's. Things that go wrong all the time are easy, just take the error report and try to figure out what may be causing it. Things that go wrong only now and then are the hard part, you keep thinking "if there is an error, why does it WORK most of the time?", but that's also our logic problem. There was this one time in... let me see... 2 years of game making, that the error was not my logic. I tried to run 2 games at once and my video card couldn't handle it, prompting a surface problem (both games made in lite version, meaning I didn't mess with surfaces). I got really curious, how could I have a surface problem without using surfaces? Again, no GM error, just a hardware limitation and the fact that the surfaces are used to draw everything in the game, even if we don't directly play with them.
I have seen many reports of bugged versions, but most of the time, it ended up being users mistakes. When there actually is a bugged copy, the normal error is that GM doesn't start or the games do not start.
  • 0

#18 greatvenom

greatvenom

    GMC Member

  • GMC Member
  • 41 posts

Posted 25 March 2011 - 02:36 PM

Thank you saim. At least you didn't call me stupid. My friend looked at the version and it is in fact a bugged version. Yes, sabraith, I found your "hidden" message. If you're just going to call me stupid, don't respond to my post. My version is bugged because this is about the 10th time something like this has happened, that worked for my friend's version (3 years game maker experience). With that note said, you all (except saim and the others who helped me) are jerks who shouldn't be responding to my post only if you're going to insult me.
  • 0

#19 saim

saim

    GMC Member

  • New Member
  • 1085 posts

Posted 25 March 2011 - 05:12 PM

Don't feel bad about the things people said. Bugged versions are really rare and we all - includding me - got used to misbelieve reports of bugged versions, because it is really common to get those reports when the problem is actually in the human part. I mean, you're not the first one to say that your problems are caused by a GM error.
Besides, you DID fix it doing, amongst other things, change the variable to global, like we were implying that you should.

Being the 10th time something like that happens does not mean that your version is bugged. The same file that gave you the error work on other versions, probably does. But you still have to check if, for example, you're using a GM7 function in a GM8 copy and your friend has an older version, or vice-versa. Not likely, since it was a variable problem.
Basically, what everybody was saying (in less kind words) was "there is a logical problem there that you're the only who can't see. How can we open your eyes to that?".
  • 0

#20 greatvenom

greatvenom

    GMC Member

  • GMC Member
  • 41 posts

Posted 25 March 2011 - 05:33 PM

Well, they could have been a bit nicer about it. The thing that confuses me is that if enemy_can_shoot works by setting it in code, why won't enemy_attack work the same way? Why do I have to change it to global?
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users