The Actor class in gzdoom.pk3 defines several fields of type uint8. For example, this data type is used for the following fields: "frame" (apparently, the current sprite frame), "movedir", and several others. However, it appears to be impossible to even
declare - let alone assign to! - a local variable of this type. For example, this ZScript will make GZDoom produce an error message:
Code: Select all
version "3.4"
class Test
{
void TestFunc()
{
uint8 test;
}
}
Code: Select all
Script error, "zscript.txt:ZSCRIPT" line 7:
Invalid statement
Trying to declare a local variable of this type and immediately assign to it will produce a more interesting error message:
Code: Select all
version "3.4"
class Test
{
void TestFunc()
{
uint8 test = 0;
}
}
Code: Select all
Script error, "zscript.txt:ZSCRIPT" line 7:
Cannot initialize non-scalar variable test here
I have no idea how uint8 could be a non-scalar type, because its name suggests that it's just a single-byte number. And in fact, it really is. However, it also appears that integer literals cannot be cast to uint8, as the following script will produce another error message:
Code: Select all
version "3.4"
class Test
{
uint8 TestFunc()
{
return 0;
}
}
Code: Select all
Script error, "zscript.txt:ZSCRIPT" line 7:
Trying to cast to invalid type.
My use case is the following: I've been trying to implement a function that would return a sprite frame that is supposed to be later assigned to the calling actor. However, in addition to the above issues, it seems there is also no way to convert character literals (such as "A", "B", "C" etc.) to values of this type.
[edit] Heh, forgot the question itself. Well, it's kind of natural... What makes this type so special and what is the reason for restricting its usage?
[edit2] It appears that values of the "frame" field can be converted to characters with this simple statement:
The reverse is also possible (just subtract int("A") instead). This also raises a question: is this an official way or is it subject to change in the future? The original question about the uint8 type still stands.