GameMaker: Studio

GameMaker: Studio

View Stats:
How to get object id?
I'm trying this:

i = 0;
while (button > 0) i += 1;
button = object_get_name(self);

But got error...
< >
Showing 1-5 of 5 comments
AlexFzk Feb 19, 2015 @ 7:49am 
I don't know what you are trying to do, can you explain better? perhaps there is a easier way to do... and I strongly recommend to avoid "while" loops until you get more experience

those 3 lines of code are in step event?
Last edited by AlexFzk; Feb 19, 2015 @ 7:54am
Blind Feb 19, 2015 @ 8:52am 
id is locally stored as "id".

But... what? Your code thar doesn't seem like it should do anything, I can't even guess what it does
Sera Feb 19, 2015 @ 9:16am 
button_get_name() returns a string, which can't be compared to zero.

That said, I think what you want is an if statement, not a while loop. what you have there, even if you set button to id (which... you could skip entirely, since id is already stored, and what you really only need is to get ids of objects other than self), will loop forever once button exceeds zero, because nowhere in the following code does button get changed to below 0.

if button != 0 then { things }
76561198008241299 Feb 19, 2015 @ 11:48am 
Originally posted by alex amfm:
I don't know what you are trying to do, can you explain better?
I want create 3 buttons. Buttons can be with skin №1 or №2.
So i want randomise string into parent button and into buttons just draw(and write obj - type)
Zuxzy Feb 19, 2015 @ 3:21pm 
I dont know what you are trying to do in that code, but if you want the id of the object itself, you can use the id variable gamemaker has already set aside for you.

So
Button = id; //if im not mistaken

if you want the id of the object you collide with it should be:
Button = instance_place(x, y, objectname_youwantidoff); // this is usually used to distinguish different instances of the same object or its child object.

< >
Showing 1-5 of 5 comments
Per page: 1530 50

Date Posted: Feb 19, 2015 @ 3:22am
Posts: 5