- Code: Select all
struct Spell {
long x;
long y;
float z;
};
void PrintSpell(struct Spell ThisSpell){
PrintF("%d",ThisSpell.x);
PrintF("%d",ThisSpell.y);
PrintF("%f",ThisSpell.z);
}
void On_HK_5(){
struct Spell TestStruct;
TestStruct.x = 10;
TestStruct.y = 10;
TestStruct.z = 3.1415927;
PrintSpell(TestStruct);
}
And the errors seem to state that the datatype isn't valid.
- Code: Select all
ERROR: Invalid base size. File: C:\Users\Farmer\Desktop\testscript.lss
ERROR: Line: 8 Invalid type for variable “ThisSpell”. File: C:\Users\Farmer\Desktop\testscript.lss
ERROR: Line: 8 Unable to declare function. File: C:\Users\Farmer\Desktop\testscript.lss
Sorry if I'm asking alot of questions but it seems that the C syntax doesn't work. Would i need to pass the struct by reference? And is this LSS specific, or does this span into C / C++
EDIT: Solved this one. The answer is to pass the struct by reference and get the values of the members using ->.
The Working Code:
- Code: Select all
typedef struct {
long x;
long y;
float z;
}Spell;
void PrintSpell(Spell * ThisSpell){
PrintF("%d",ThisSpell->x);
PrintF("%d",ThisSpell->y);
PrintF("%f",ThisSpell->z);
}
void On_HK_5(){
Spell TestStruct;
TestStruct.x = 10;
TestStruct.y = 10;
TestStruct.z = 3.1415927;
PrintSpell(&TestStruct);
}