Jump to content


Photo

Game Maker Suggestions


  • This topic is locked This topic is locked
1176 replies to this topic

#1121 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • Retired Staff
  • 9260 posts
  • Version:Unknown

Posted 18 April 2012 - 04:32 PM

Troll? I am simply stating that your method is illogical. 1 error for 1 function = waste of time.
Other methods are available, and I think you arer mad cause I am right... :biggrin:

- Good Fight

I think you missed the point of his post. He's not saying you should explicitly create an array of characters instead of a string. He's pointing out that, internally, a string is an array of characters. When you do this:

myString = "Hello";

What's happening internally is basically this, automatically, without you doing it:

char myString[6];
myStirng[0] = 'H';
myStirng[1] = 'e';
myStirng[2] = 'l';
myStirng[3] = 'l';
myStirng[4] = 'o';
myStirng[5] = '\0'; // That's a terminating null byte

So when you do string_char_at(myString, 5), it's simply returning myString[4]--in other words, string_char_at(str, N) returns str[N-1]. Because of this, it only makes sense that trying to get string_char_at(str, 0) should try to access str[-1] and error out.

Errors are designed to point out when you've accidentally messed something up in your code. Pretending that str[-1] = str[0] to suppress errors means if you have loops that go from 0 to N-1 instead of 1 to N, you'll have a hell of a time trying to uncover that problem.

I agree that, since GM will always (strangely) start strings at position 1, the least it can do is throw an error if you try to access a position before 1.

-IMP
  • 1

#1122 Big J

Big J

    GMC Member

  • GMC Member
  • 2818 posts
  • Version:GM8.1

Posted 18 April 2012 - 06:30 PM

Troll? I am simply stating that your method is illogical. 1 error for 1 function = waste of time.
Other methods are available, and I think you arer mad cause I am right... :biggrin:

- Good Fight

OK first, I'm not mad. Second, you're not right. Posting your flawed opinion over and over doesn't make it right. Showing an error message is not a waste of time. You know what is a waste of time? Game Maker hiding errors in my code and me spending time debugging it without an error message telling me what I did wrong. That is a waste of time. All Game Maker has to do is show a message to the effect of "Error: Zero string index" and that will point out exactly what went wrong. It wouldn't even be hard to add, considering I can do it myself by making a script that wraps the function, like this:
//stringCharAt(string, position)
var str, pos;
str = argument0;
pos = argument1;
if (pos < 1)
    show_error("Invalid string index less than 1", false);
if (pos > string_length(str))
    show_error("Invalid string index greater than the length.", false);
return string_char_at(str, pos);

Errors are designed to point out when you've accidentally messed something up in your code. Pretending that str[-1] = str[0] to suppress errors means if you have loops that go from 0 to N-1 instead of 1 to N, you'll have a hell of a time trying to uncover that problem.

I agree that, since GM will always (strangely) start strings at position 1, the least it can do is throw an error if you try to access a position before 1.

-IMP

See, IceMetalPunk knows what I'm talking about. This is the entire point of my post.

Edited by Big J, 18 April 2012 - 06:32 PM.

  • 1

#1123 kburkhart84

kburkhart84

    GMC Member

  • GMC Member
  • 1618 posts
  • Version:GM:Studio

Posted 18 April 2012 - 07:05 PM

IMP and Big J are right. In reality, strings are in fact arrays of characters, and this is so in any programming language, whether you see it or it is under the hood. Some languages let you access strings as arrays too, instead of having to use a function like string_char_at(), you can just say string[pos]. But then, in most languages, strings(and arrays of course) start at index 0, and I honestly think GM should be the same. But, if it isn't, it should be clearly defined(which in GM it is defined in the documentation).

As far as error handling, I'm firmly on the side of the more the better. Maybe it could be something optional, but generally, anything that could throw an error needs to throw the error, even if it is a non fatal error. For example, if I try to access the character at position 0, and GM wants to automatically give me the one at position 1 instead(since there is no position 0), instead of just doing it, it should either one, stop with an out of bounds error, or two, substitute the character for the next position, but emit to the message receiver/debug log what happened, so that us "normal" programmers who want to see any errors can fix it much easier. The same could aply to uninitialized variables. I hate it, but if yoyo would have wanted to leave the option in, they could do so, but everytime it set one to 0 because of it not being initialized/created beforehand, it should print a message.

The problem GM has is in that since it was created with beginners in mind, it tried to be friendly, and in many instances too friendly. Example, it tries to hide that strings are actually arrays under the hood by making the first character position 1 instead of 0, but then it leaves arrays starting at '0'. This looks to me like trying to "make sense" since in theory the "first" character in a string is number 1 right? Yoyo is changing some of those things in Studio, and I wouldn't be surprised if many more were changed in GM9 considering the whole rewrite. I expect that strings will be having index of 0 for starting instead, and maybe they will be accessible via array operators(brackets[]) like many other languages.
  • 0

#1124 Pixlator

Pixlator

    GMC Member

  • New Member
  • 24 posts
  • Version:Unknown

Posted 18 April 2012 - 11:14 PM

Well said kburkhart84.
@ Big J - Why argue your point this far if you can create the error message yourself (Think About That)? Big J I recommend you know your functions inside and out to avoid errors.

I never said that the error itself is bad, just that it is not needed. If GM states that string indexes start at position 1 and not 0 then
you should know that using the function... if they do fix it then I then I can happily say I won't get the same problem in the future if I do the same thing as you Big J.

I know what you are getting at, and if YoYo wants to or doesn't want to fix that then good for them. What I am really trying to say is that
if one is going to program or do some sort of activity shouldn't they know the rules (in case of programming the properties of the functions being used)?

Personally I don't think that switching from 0 to 1 is an error. The problem is you do not take enough time to read the documentation provided. (GM documentation: "0=no occurrence" - That in itself has validated my previous posts)
That is what helps with debugging... you should know that. When in doubt read the documentation... (or ask the GMC to reveal your problem)

Anyways very interesting discussion, I quite enjoyed this argument. :P

Edited by Pixlator, 18 April 2012 - 11:17 PM.

  • 0

#1125 thatshelby

thatshelby

    GMC Member

  • GMC Member
  • 3823 posts
  • Version:GM8

Posted 18 April 2012 - 11:35 PM

Improvements to the GM sprite editor...

-.PAL palette loading
-tile previews (tiling it in a small preview window at 1x scale, maybe an option for h/v tiling only?)
-Default grid colors don't show up, you have to put them in yourself. It's important too, if you just doodle, the background colors can influence your work. At least, it happens to me.
-guideline placement



Backgrounds are also not drawn outside the room... I would love it if they were, to a degree, because it would be easier when you use the view_angle variable.
  • 0

#1126 Big J

Big J

    GMC Member

  • GMC Member
  • 2818 posts
  • Version:GM8.1

Posted 18 April 2012 - 11:40 PM

Well said kburkhart84.
@ Big J - Why argue your point this far if you can create the error message yourself (Think About That)? Big J I recommend you know your functions inside and out to avoid errors.

I never said that the error itself is bad, just that it is not needed. If GM states that string indexes start at position 1 and not 0 then
you should know that using the function... if they do fix it then I then I can happily say I won't get the same problem in the future if I do the same thing as you Big J.

I know what you are getting at, and if YoYo wants to or doesn't want to fix that then good for them. What I am really trying to say is that
if one is going to program or do some sort of activity shouldn't they know the rules (in case of programming the properties of the functions being used)?

Personally I don't think that switching from 0 to 1 is an error. The problem is you do not take enough time to read the documentation provided. (GM documentation: "0=no occurrence" - That in itself has validated my previous posts)
That is what helps with debugging... you should know that. When in doubt read the documentation... (or ask the GMC to reveal your problem)

Anyways very interesting discussion, I quite enjoyed this argument. :P

You just joined the GMC this month, so you haven't had any experience making mistakes in code and having Game Maker hide them so that you spend hours trying to figure out what went wrong. You probably still use Drag 'N' Drop and haven't written a single line of code in your life. Having to wrap a Game Maker function into a script to correct one tiny problem shouldn't be necessary, and it's a hassle. In addition, the added overhead of calling a script slows down the execution, but you wouldn't know that since you just barely started Game Maker on April 3rd. You also keep arguing that the error message is not needed. That's not true at all, it is needed. If you don't like error messages to help debug your code, turn them off in Global Game Settings --> Errors. Otherwise, all errors should be reported, not hidden. No one here knows every single Game Maker function inside and out, especially not you. Kindly go away and stop participating in a discussion where you don't understand the subject. Thanks.

Edited by Big J, 18 April 2012 - 11:42 PM.

  • 0

#1127 Pixlator

Pixlator

    GMC Member

  • New Member
  • 24 posts
  • Version:Unknown

Posted 19 April 2012 - 04:50 AM

You must be very inexperienced in GM yourself to assume I use D&D and know nothing of GM.
I don't use D&D and I have been on the GMC for around a year (I had a different account, but forgot the password lol).
I am quite experienced in GML. Yes I have been here since April 3rd, although that means nothing about what I have done
before hand. You must still be quite young to be so naive and to make such assumptions.

Having to wrap 1 tiny error like that into a game means you probably are going to exit the game after seeing the error to fix the code.
So speed isn't a problem, and after you have fixed the code you can delete the script error and move on. You have no right telling me to leave a forum I have every right to be here whenever I choose. I have stated my points, proven them (with FACTS) and agreed with you to some extent and you are angry about... 1 error that you can create yourself?

Again do not make such assumptions, stop being so naive, grow up and move on. Give me facts that prove this error is so changing and soo... amazing that you need to argue this much over it...

-- Such a discussion doesn't need trolls, naive, nor ignorant children posting in it (such as yourself).
(I enjoy posting and feeding your rant - I can go on forever) Although I am done posting about this.
I will however post any functions or things in game maker that would actually be "helpful", and I will not be leaving the GMC anytime soon...

Edited by Pixlator, 19 April 2012 - 04:55 AM.

  • 0

#1128 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • Global Moderators
  • 14392 posts
  • Version:GM:Studio

Posted 19 April 2012 - 05:11 AM

Warned & Warned... you guys stop being so childish.
  • 1

#1129 Pixlator

Pixlator

    GMC Member

  • New Member
  • 24 posts
  • Version:Unknown

Posted 19 April 2012 - 09:22 AM

Haha I agree. ^_^
Hence the ending of my last post. :P
  • 0

#1130 Big J

Big J

    GMC Member

  • GMC Member
  • 2818 posts
  • Version:GM8.1

Posted 19 April 2012 - 10:16 AM

You must be very inexperienced in GM yourself to assume I use D&D and know nothing of GM.
I don't use D&D and I have been on the GMC for around a year (I had a different account, but forgot the password lol).
I am quite experienced in GML. Yes I have been here since April 3rd, although that means nothing about what I have done
before hand. You must still be quite young to be so naive and to make such assumptions.

Having to wrap 1 tiny error like that into a game means you probably are going to exit the game after seeing the error to fix the code.
So speed isn't a problem, and after you have fixed the code you can delete the script error and move on. You have no right telling me to leave a forum I have every right to be here whenever I choose. I have stated my points, proven them (with FACTS) and agreed with you to some extent and you are angry about... 1 error that you can create yourself?

Again do not make such assumptions, stop being so naive, grow up and move on. Give me facts that prove this error is so changing and soo... amazing that you need to argue this much over it...

-- Such a discussion doesn't need trolls, naive, nor ignorant children posting in it (such as yourself).
(I enjoy posting and feeding your rant - I can go on forever) Although I am done posting about this.
I will however post any functions or things in game maker that would actually be "helpful", and I will not be leaving the GMC anytime soon...

I have 7+ years experience with Game Maker. You haven't proven anything with facts except that you like debugging an off-by-one error in string handling to be a nightmare instead of easy. Once gain, I am not talking about debugging a simple 1 line script. I have proven my points with facts and experience. I've already experienced the frustration of getting unexpected results in string handling and spending hours tracing over the script looking for the problem. No, reading the documentation and finding out strings start at 1 does not help me locate the error. There's 50+ lines of code that is parsing a string and reading certain information from it. The error in the code is hidden, due to the flawed implementation (no error message when doing it incorrectly). In real programming languages, you get errors when you make mistakes, so it should be like that in Game Maker as well, especially since my suggestion isn't at all unreasonable and is indeed a good legit request. This is the Game Maker suggestion topic, not the I-need-help-debugging-my-string-code topic, so you've taken the wrong approach to posting in this topic. I'm perfectly capable of using the string handling functions in Game Maker, I'd just like to see proper error handling, not just for me, but for anybody else who uses Game Maker. In fact, this suggestion wouldn't even affect your ability to use Game Maker, since obviously, you've never made this kind of mistake in a long script.

Here's a summary of the facts:

Fact 1: Arrays start at 0 in most languages and so do strings.

Fact 2: Most users will assume strings start at 0 in Game Maker, just like arrays. I have answered countless Novice Q&A topics over the years dealing with this hidden error. They wouldn't have needed to post at all if GM would just be honest and not "lie" and return the value of position 1 when position 0 is accessed.

Fact 3: Invalid array indices give error messages, letting the programmer know that their code is accessing an index that is out of bounds. For example, if their array only has 5 elements, numbered 0 through 4, and they try to read array[5], GM lets them know they went out of bounds, so this is an issue with consistency in throwing errors.

Fact 4: Due to GM hiding this error, and some other errors as well, such as list indices being out of bounds, debugging this can be an absolute nightmare. My suggestion is not just about "one error I can create myself". Claims like that are made when the poster is shortsighted and cannot see the whole picture. The intent was to suggest that hidden errors not be hidden. Here's another example:
list = ds_list_create();
ds_list_add(list, 0); //position 0
ds_list_add(list, 1); //position 1
ds_list_add(list, 2); //position 2
ds_list_add(list, 3); //position 3
show_message(string(ds_list_find_value(list, 4))); //read position 4, it returns 0! No error at all

//Inconsistency between simple arrays and lists/grids/whatever else.
By the way, these code samples are known as "test cases". Of course I would never write code like this in practice, it simply demonstrates that GM hides errors when accessing strings and data structures. There's all kinds of hidden errors like this, not just the one that I used as an example in the past few posts. Hiding errors is a huge show-stopper when it comes to debugging code that is not working. Anybody with programming experience will tell you this, it's a simple fact and is not up for debate. ;)

Also, I never asked you to leave the GMC, only to stop debating subjects that you do not fully understand. Your suggestion of draw_set_depth() was perhaps a legitimate suggestion (and was suggested countless times in the past. I know, the topic is too long and you didn't have time to read the whole thing like I did), but once you were explained why it's not possible or too expensive, you retracted your argument, which was smart. My suggestion is actually expanding upon Yal's original suggestion of proper errors for data structures, and you turned it into a mess by insisting that we're wrong. What you should have done was read the facts and then agree that we are right, or say that we have legitimate points and that you personally don't feel it is important.

Also, icuurd12b42 shouldn't read or moderate the GMC while drunk.

Edited by Big J, 19 April 2012 - 10:33 AM.

  • 0

#1131 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • Global Moderators
  • 14392 posts
  • Version:GM:Studio

Posted 19 April 2012 - 04:32 PM

You guy were reported by users that are getting annoyed, hence the action taking. Now ease off, you both got your last post on the subject.
  • 2

#1132 GStick

GStick

    All Secrets Exposed

  • GMC Member
  • 1576 posts
  • Version:GM:Studio

Posted 19 April 2012 - 09:54 PM

Literally just thought of this one...

Returns on a with statement.

var retval;
retval = with (instance)
{
    dostuff();
    
    return true;
}

if (retval)
{
    show_message("You returned a value in a with statement. Cool.");
}

It would be a neat little feature. It wouldn't really provide you with anything you can't already do, but it could have a lot of small uses everywhere if it existed. There might even be more standard ideas to propose here instead (methods). People would also probably abuse it and use it as a way to write small inline scripts. That's cool too, but obviously wouldn't be the purpose.

I got the idea looking at this script of mine that I was reading over. It requires the object to look at a certain object next to it and uses that object for collision and variable checking.

Obviously this isn't a well formed idea. It's just one that popped in my head, but I thought it was interesting enough that I'd post it here.
  • 0

#1133 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • Retired Staff
  • 9260 posts
  • Version:Unknown

Posted 19 April 2012 - 10:55 PM

Literally just thought of this one...

Returns on a with statement.

var retval;
retval = with (instance)
{
    dostuff();
    
    return true;
}

if (retval)
{
    show_message("You returned a value in a with statement. Cool.");
}

It would be a neat little feature. It wouldn't really provide you with anything you can't already do, but it could have a lot of small uses everywhere if it existed. There might even be more standard ideas to propose here instead (methods). People would also probably abuse it and use it as a way to write small inline scripts. That's cool too, but obviously wouldn't be the purpose.

I got the idea looking at this script of mine that I was reading over. It requires the object to look at a certain object next to it and uses that object for collision and variable checking.

Obviously this isn't a well formed idea. It's just one that popped in my head, but I thought it was interesting enough that I'd post it here.

That's just awkward. The with() is a syntactical construct, not a script/function/method. Treating it like one just looks weird and unnatural :lol: . Besides, what's wrong with this?:

var retval;
with (instance)
{
    dostuff();
    
    retval = true;
}

if (retval)
{
    show_message("You returned a value in a with statement. Cool.");
}

-IMP
  • 0

#1134 GStick

GStick

    All Secrets Exposed

  • GMC Member
  • 1576 posts
  • Version:GM:Studio

Posted 19 April 2012 - 11:53 PM

I know. :)

But the problem I have with doing it that way is that its not... specific.

with (instance)
{
    dostuff();
    
    retval = true;
}

Now, from context you could tell that retval was a temp variable and the name "retval" makes it kind of obvious anyway, but can you really be sure? I'm not really defending my idea, because like you said it's a bit awkward and like I said it wasn't a full idea, just something I thought of literally seconds before posting. But you can't be completely sure that retval is not a variable owned by instance. That's even more awkward to me.

// this of course would be extremely awkward like you pointed out
if (with (instance)
{
    return true;
})
{
    // do stuff
}

But I like the idea of it.
  • 0

#1135 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • Retired Staff
  • 9260 posts
  • Version:Unknown

Posted 20 April 2012 - 12:08 AM

I know. :)

But the problem I have with doing it that way is that its not... specific.

with (instance)
{
    dostuff();
    
    retval = true;
}

Now, from context you could tell that retval was a temp variable and the name "retval" makes it kind of obvious anyway, but can you really be sure? I'm not really defending my idea, because like you said it's a bit awkward and like I said it wasn't a full idea, just something I thought of literally seconds before posting. But you can't be completely sure that retval is not a variable owned by instance. That's even more awkward to me.

// this of course would be extremely awkward like you pointed out
if (with (instance)
{
    return true;
})
{
    // do stuff
}

But I like the idea of it.

That's what the var retval; at the top is for. It's a scope declaration. It doesn't matter if the instance has a local variable named "retval", as that will NOT be used in this code. Instead, it'll use the script-local variable retval and won't ever touch the instance-local variable.

-IMP
  • 0

#1136 Big J

Big J

    GMC Member

  • GMC Member
  • 2818 posts
  • Version:GM8.1

Posted 20 April 2012 - 12:16 AM

Yeah, the temporary variable is a little bit like a global variable... except it's temporary. The method that IMP has described does work. I've use that in the past where I needed to count all instances where a certain variable equals a certain value. From my point of view, the temporary variable is placed in global scope, and then deleted at the end of the code. :)
  • 0

#1137 GStick

GStick

    All Secrets Exposed

  • GMC Member
  • 1576 posts
  • Version:GM:Studio

Posted 20 April 2012 - 12:25 AM

I know, I use it to. That's the type of code I was glancing at that made the idea pop into my head. :lol: But I was looking at it and went "This isn't very clear. with is telling me that this is happening to another object, yet it's... not." It would just be neat to have something similar, and more apparent of what it's actually doing. Not necessarily the exact idea I proposed.

Or heck, if you were to use an idea like that one, just limit the scope of with to only include the object in with and have some keyword for getting the calling object:
with (instance)
{
    caller.variable = 0;
}

Or whatever. Weird ideas for sure... :yes:
  • 0

#1138 Desert Dog

Desert Dog

    GMC Member

  • Global Moderators
  • 6409 posts
  • Version:Unknown

Posted 20 April 2012 - 01:27 AM

I know, I use it to. That's the type of code I was glancing at that made the idea pop into my head. :lol: But I was looking at it and went "This isn't very clear. with is telling me that this is happening to another object, yet it's... not." It would just be neat to have something similar, and more apparent of what it's actually doing. Not necessarily the exact idea I proposed.

Or heck, if you were to use an idea like that one, just limit the scope of with to only include the object in with and have some keyword for getting the calling object:

with (instance)
{
    caller.variable = 0;
}

Or whatever. Weird ideas for sure... :yes:


You can. It's other.variable=0;

Edit: Worth noting. You use other.variable with an ordinary variable in the 'other' object, but you do not use it for a temporary variable. (you just use it as mentioned in posts above)
I believe it throws an error if you try to do 'other.temporary_variable', or at least, screws up.

Edited by Desert Dog, 20 April 2012 - 01:31 AM.

  • 0

#1139 GStick

GStick

    All Secrets Exposed

  • GMC Member
  • 1576 posts
  • Version:GM:Studio

Posted 20 April 2012 - 02:20 AM

Really? Why isn't that documented? All these years...

edit: I should probably make it more clear, I'm referring to your edit about temporary variables. I'm not sure I've ever even tried it with temp variables.

Edited by GStick, 20 April 2012 - 02:21 AM.

  • 0

#1140 Desert Dog

Desert Dog

    GMC Member

  • Global Moderators
  • 6409 posts
  • Version:Unknown

Posted 20 April 2012 - 03:07 AM

I don't think a temporary variables counts as an instance variable. I don't know how you'd describe it, it's almost 'global', but only within a particular piece of code. (it ceases to exist outside that code/script, as you will know)

So using other.temp_variable doesn't make sense, because temporary variables don't *have* an instance they exist in.

This is my best guess. I should probably start testing around now, I'm relying on memory.. :tongue:
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users