Benxamix2
|
 |
Posted on: May 13, 2014, 09:38:15 pm |
|
|
 Location: Chile Joined: Mar 2012
Posts: 69
|
Hey there! I'll be straightforward. I'm making multiple instances of an object in the same room. I want, however, to keep a specific variable different on each of them. I've set Instance Creation Codes in the room editor for this, but it seems to crash my game, "because there's an unspecified variable". I've made enough self-debugging in order to understand that this is what causes the error.
My question is: could you tell me the order of execution of these events, for future reference? Instance Creation - Create - Room Start
I'm assuming it's the one showing up but I'm not sure. However, if I'm right, I'd suggest to switch Instance Creation and Create, if possible. I don't see the point of it being different than that.
|
|
|
Logged
|
|
|
|
|
|
Goombert
|
 |
Reply #3 Posted on: May 14, 2014, 01:44:20 pm |
|
|
 Location: Cappuccino, CA Joined: Jan 2013
Posts: 2993
|
Yes Harri, you are correct, but Studio also does it backwards like we do for the same reason, I think.
|
|
|
Logged
|
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect. 
|
|
|
Benxamix2
|
 |
Reply #4 Posted on: May 14, 2014, 05:33:34 pm |
|
|
 Location: Chile Joined: Mar 2012
Posts: 69
|
Create->Instance Create->Game Start->Room Create->Room Start
That's something I won't forget, now. Also, "because there's an unspecified variable" should not crash your game. It should only show in debug mode and even if you press Ignore it should run. But you are right that you should fix them.
Well, it does. The only reason my game's crashing now is because I set custom instance creation codes, so to change already declared variables. I've debugged it by simply duplicating the room and deleting every instance's creation code, then running that new room first, so that every instance is set to default values. In this case, I'm using the following in my Object Create Event: local variant text="This is the default signboard text. If you're reading this, it's a bug. So please, tell my moron creator to fix it!"; And this is how a single instance code looks: text="Welcome to the first PIT² BETA! Move around with the arrow keys, and jump with the Space bar!"; To put it simple, again: if I do not use instance creation codes, my game works flawlessly. If I do, it crashes instantly when the room starts. I wasn't sure before, but I'm starting to think this is an ENIGMA bug.
|
|
« Last Edit: May 14, 2014, 08:53:17 pm by Benxamix2 »
|
Logged
|
|
|
|
|
Benxamix2
|
 |
Reply #6 Posted on: May 15, 2014, 04:11:20 pm |
|
|
 Location: Chile Joined: Mar 2012
Posts: 69
|
Try just text = "something" without the useless "local variant" stuff. Maybe it's a type bug in parser or something.
I wish it was. It didn't work, either... But I found out it works as long as I don't use strings. I've just submitted it to the bugtracker.
|
|
|
Logged
|
|
|
|
Darkstar2
|
 |
Reply #7 Posted on: May 15, 2014, 06:11:57 pm |
|
|
 Joined: Jan 2014
Posts: 1238
|
I can't reproduce your error, it works fine for me.
I created 3 different instances of the same object inside a room, noted the instance ID of each, then on each different instance I added a text string into the instance creation code. I copy/pasted your example, and for the other 2 used my own.
Then in the main object's draw event I added this debug to see if it works.
draw_text(10,10,string(100010.text));
This displayed Welcome to the first PIT² BETA! Move around with the arrow keys, and jump with the Space bar!
draw_text(10,10,string(100011.text));
This displayed the other text string I used.
and so forth, so I could individually set variables to each instance ID. TO access these you precede the variable with the instance ID as shown above.
With or without draw event, no crashes here.
|
|
|
Logged
|
|
|
|
Benxamix2
|
 |
Reply #8 Posted on: May 15, 2014, 07:31:09 pm |
|
|
 Location: Chile Joined: Mar 2012
Posts: 69
|
That just makes it weirder.
This was my code in the Draw Event. It does not work.
draw_text_ext(view_xview+160,view_yview+112,text,-1,200);
But if I do this, similar to you, it does... At least it doesn't crash, and it does shows a text.
draw_text_ext(view_xview+160,view_yview+112,100174.text,-1,200);
But, since I'll be having more than 1 signboard in the same room, and this only shows a single one's message... It's kind of a workaround, but does not serve to my purpose.
It doesn't work with self.text, or string(text) either.
|
|
« Last Edit: May 15, 2014, 09:20:43 pm by Benxamix2 »
|
Logged
|
|
|
|
Josh @ Dreamland
|
 |
Reply #9 Posted on: May 17, 2014, 09:09:03 am |
|
|
Prince of all Goldfish
 Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
So, Robert recently edited the draw_string function. It wouldn't surprise me if it crashes your game when passed an empty string or an uninitialized variable. Could you verify this by drawing string(string_length(text))? That will at least tell us what's going on.
Another item to consider is the fact that your string contains a "²" character. Did you modify your font to contain this glyph? Does it crash in debug mode? What happens if you remove this glyph?
|
|
|
Logged
|
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble "I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
|
|
|
Benxamix2
|
 |
Reply #10 Posted on: May 17, 2014, 07:57:50 pm |
|
|
 Location: Chile Joined: Mar 2012
Posts: 69
|
Another item to consider is the fact that your string contains a "²" character. Did you modify your font to contain this glyph? Does it crash in debug mode? What happens if you remove this glyph? That fixed it... Gosh! I feel dumb now! Forgot that character wasn't in the default font's char range (and I cannot change that anyway, so DAMN). So, Robert recently edited the draw_string function. It wouldn't surprise me if it crashes your game when passed an empty string or an uninitialized variable. Could you verify this by drawing string(string_length(text))? That will at least tell us what's going on. (Un)Surprisingly enough, it works and does draw the string's length. Thank you, Josh!
|
|
|
Logged
|
|
|
|
Josh @ Dreamland
|
 |
Reply #11 Posted on: May 18, 2014, 09:35:23 am |
|
|
Prince of all Goldfish
 Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
That's actually something we should probably run checking for, even outside debug mode. A null check after that lookup is basically free, and malformed strings happen all the time.
Anyway, no problem.
|
|
|
Logged
|
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble "I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
|
|
|
|