• 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.

 (suggestion) support hex()conversion method?

can the yoyo game devs add the ability to convert real and strings to hex?

this would allow people to do something like hex("$FF") or hex(255) which would return a string literal of $FF
 
can the yoyo game devs add the ability to convert real and strings to hex?

this would allow people to do something like hex("$FF") or hex(255) which would return a string literal of $FF
not sure what you want.... I don't think 255 or $FF makes any diference....
if you use array[$03] or array[3] it's the same... the representation only changes in the editor, it's always compiled to a real number.

the text to number convertion can be done via script...
 
not without it being in string form

-open up gms2.0 and create a object.
-add a create event and add a line reading..
Code:
hex1 = real("$FF");
-put it in a room and run it in debug mode.
you'll see that it either throws an error during the compile or is 0 when it should return be 255.
 
not without it being in string form

-open up gms2.0 and create a object.
-add a create event and add a line reading..
Code:
hex1 = real("$FF");
-put it in a room and run it in debug mode.
you'll see that it either throws an error during the compile or is 0 when it should return be 255.

Because I said you could convert it via script... you have to create the script yourself...


Code:
var t = string_upper(argument0);
var len = string_length(t);
if (string_char_at(t, 0) == "$")
{
    var b, n = 0, e = 0
    while (--len) {
        b = string_byte_at(a, len + 1);
        if (b > 47 && b < 58) {
            n+= (b - 48) * power(16,e++);
        } else if (b > 64 && b < 71) {
            n+= (b - 55) * power(16,e++);
        } else {
            n = 0; break;
        }
    }
}
return n;
you can name it parse_hex("$FF") and it returns 255...
 
Top