Page 1 of 1
Few Questions About Structures
Posted: Wed 16 Nov , 2011 8:46 pm
by LegendaryAgent
Hey im just starting with structs in uscript, im doing a for loop to fill up data in them, however theres a problem, i want the for loop to stop at the limit of the struct, in other words i want to measure how many uhm "pages" a structure has, i tried "i < struct1.length" but it didnt work, do i really have to force a static number or is there a special count to get the struct size?
thx in advance as usual!
Re: Few Questions About Structures
Posted: Wed 16 Nov , 2011 8:50 pm
by Azarael
Re: Few Questions About Structures
Posted: Wed 16 Nov , 2011 9:18 pm
by LegendaryAgent
Hey, thx a tons aza, no error reports now, im going to test ingame, when and if i can get it working i will post back reply with a small example if necessary.
BTW is it possible to declare a dynamic struct? with for example starting from 1 field and later automatically adding more field for the next data insertion? or do i have to make it static?
Thanks again for help
Re: Few Questions About Structures
Posted: Wed 16 Nov , 2011 10:06 pm
by LegendaryAgent
IT semms im running into a problem, how can i add a subclass of a class to the structure? for example, i want to add a reference to a specific powerup which is a subclass of rpgartifact in the structure list, if i try this:
Code: Select all
struct PowerUpStuff
{
var RPGArtifact SpecialPowerUp;
};
and i try to add for example PowerUp1 (which is a an extension of RPGArtifact, i cant access the PowerUp1 exclusive variables, it tells me that the variable i typed does not exist in RPGArtifact, even though its clearly a PowerUp1 extending from RPGArtifact, so it just cant access the variables from that powerup1 because they do not exist in RPGArtifact itself, is there any way i can add several different Subclasses of RPGArtifact in the struct?
Please let me know if i left you with a question mark, my english isnt that good sometimes so ill try to explain by other words if necessary xD
Thanks in advance!
Re: Few Questions About Structures
Posted: Wed 16 Nov , 2011 11:07 pm
by Azarael
Typecast
Re: Few Questions About Structures
Posted: Wed 16 Nov , 2011 11:29 pm
by LegendaryAgent
Azarael wrote:Typecast
you mean like
Subclass1(SpecialPowerUp).Whatever?
this is not viable, because im trying to do something with few subclasses, example
PowerUpList[0].SpecialPowerUp can be either a subclass1 or a subclass2 or a subclass3 or more in future who knows...
thats why i cant do subclass1(PowerUpList[0].SpecialPowerUp), because thats guessing and it can be wrong, most of the times ingame
Or maybe typecast means something different?
Any suggestion will do, aza and others
Re: Few Questions About Structures
Posted: Wed 16 Nov , 2011 11:41 pm
by Azarael
Your design is flawed. It would help to know what you are attempting to do.
In this case, you should have set up your superclass such that it is generic and can do everything, and then have subclasses use the various settings to implement their functionality.
Re: Few Questions About Structures
Posted: Wed 16 Nov , 2011 11:48 pm
by LegendaryAgent
Azarael wrote:If you can't or won't typecast, then your design is flawed and you need to rethink what you're doing.
its not that i dont want to, i even tried:
subclass1 extends rpgartifact
ClassInteraction.PowerUpList
.ThePowerUpName=subclass1(self); this obviously results in an error telling me its not needed to typecast it.
there has to be a way around this,
because if i manually typecast it in the Classinteraction it works fine, but as ive said int is relative, it can be either a subclass of a rpgartifact (subclass1) or a subclass of rpgartifact (subclass2) and so on...
Re: Few Questions About Structures
Posted: Thu 17 Nov , 2011 12:04 am
by LegendaryAgent
LegendaryAgent wrote:Azarael wrote:If you can't or won't typecast, then your design is flawed and you need to rethink what you're doing.
its not that i dont want to, i even tried:
subclass1 extends rpgartifact
ClassInteraction.PowerUpList
.ThePowerUpName=subclass1(self); this obviously results in an error telling me its not needed to typecast it.
there has to be a way around this,
because if i manually typecast it in the Classinteraction it works fine, but as ive said int is relative, it can be either a subclass of a rpgartifact (subclass1) or a subclass of rpgartifact (subclass2) and so on...
i know a way but i really hate it, i make a whole new primary class with all those variables... imo its powerfull lame there must be a way i can send into the struct already typecasted :\