• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

string_char_at -- bug or feature?

T

Trylon

Guest
Was given the impression that string_char_at would return "" if index is does not point to a letter.

Description
You can use this function to return a specific character at a specific position within a string, with the index starting at 1 for the first character. If no character is found or the string is shorter than the value given to index, an empty string "" is returned.

But it seems that values less than 1 simply return the first character in the string:

left_char = string_char_at("acyclic",1);
//left_char is "a"

left_char = string_char_at("acyclic",0);
//left_char is "a"

left_char = string_char_at("acyclic",-1);
//left_char is "a"

left_char = string_char_at("acyclic",-2);
//left_char is "a"

If this the expected behavior perhaps it might be noted in the manual as it seems a bit unintuitive.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
If this the expected behavior perhaps it might be noted in the manual as it seems a bit unintuitive.
This is expected behaviour, yes, as the value is clamped to 1 at the lower end... and yes, it should be noted in the manual probably so please file a bug report. :)
 
T

Trylon

Guest
This is expected behaviour, yes, as the value is clamped to 1 at the lower end... and yes, it should be noted in the manual probably so please file a bug report. :)
Thanks for the reply -- will post as bug report as suggested.
 
Top