EDIT: I'm being stupid, read my own reply below.
I've been writing some test code to learn how AGS implements OOP. So my very first struct in AGS looks like this:
Code: ags Obviously, it's a try to implement a Collection object in AGS that is a bit more dynamic than to work with arrays (the code works fine BTW).
My question is why I'm required to implement the set_Count() function for a writeonly attribute, I understand that within the struct I can use this.Count but in my case I only use the count (with lowercase letters) to change the Count property. In my opinion, the set_Count() function should be voluntary to implement, AGS should be smart enough to just throw a runtime error if I ever use this.Count = someValue in my code if I haven't implemented the set_Count() function.
Another question related to my implementation above: This List struct only accepts strings. Is there any generic type in AGS that can accept any value, either a number or a String, such as an object (and I'm talking about the type here, not Room Object)?
I've been writing some test code to learn how AGS implements OOP. So my very first struct in AGS looks like this:
struct List
{
protected int arrSize;
protected String list[];
protected int count;
import writeprotected attribute int Count;
import attribute String Items[];
import int Add(String value);
import function Remove(int idx);
import int get_Count();
protected import function set_Count();
import String geti_Items(int idx);
import function seti_Items(int idx, String value);
protected import function ExpandArray();
};
My question is why I'm required to implement the set_Count() function for a writeonly attribute, I understand that within the struct I can use this.Count but in my case I only use the count (with lowercase letters) to change the Count property. In my opinion, the set_Count() function should be voluntary to implement, AGS should be smart enough to just throw a runtime error if I ever use this.Count = someValue in my code if I haven't implemented the set_Count() function.
Another question related to my implementation above: This List struct only accepts strings. Is there any generic type in AGS that can accept any value, either a number or a String, such as an object (and I'm talking about the type here, not Room Object)?