Few Questions About Structures
-
- Member
- Posts: 80
- Joined: Thu 29 Sep , 2011 12:26 am
- Contact:
Few Questions About Structures
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!
thx in advance as usual!
- Azarael
- UT2004 Administrator
- Posts: 5365
- Joined: Thu 11 Feb , 2010 10:52 pm
-
- Member
- Posts: 80
- Joined: Thu 29 Sep , 2011 12:26 am
- Contact:
Re: Few Questions About Structures
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
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
-
- Member
- Posts: 80
- Joined: Thu 29 Sep , 2011 12:26 am
- Contact:
Re: Few Questions About Structures
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:
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!
Code: Select all
struct PowerUpStuff
{
var RPGArtifact SpecialPowerUp;
};
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!
- Azarael
- UT2004 Administrator
- Posts: 5365
- Joined: Thu 11 Feb , 2010 10:52 pm
Re: Few Questions About Structures
Typecast
-
- Member
- Posts: 80
- Joined: Thu 29 Sep , 2011 12:26 am
- Contact:
Re: Few Questions About Structures
you mean likeAzarael wrote:Typecast
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
- Azarael
- UT2004 Administrator
- Posts: 5365
- Joined: Thu 11 Feb , 2010 10:52 pm
Re: Few Questions About Structures
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.
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.
-
- Member
- Posts: 80
- Joined: Thu 29 Sep , 2011 12:26 am
- Contact:
Re: Few Questions About Structures
its not that i dont want to, i even tried:Azarael wrote:If you can't or won't typecast, then your design is flawed and you need to rethink what you're doing.
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...
-
- Member
- Posts: 80
- Joined: Thu 29 Sep , 2011 12:26 am
- Contact:
Re: Few Questions About Structures
LegendaryAgent wrote:its not that i dont want to, i even tried:Azarael wrote:If you can't or won't typecast, then your design is flawed and you need to rethink what you're doing.
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 :\
Who is online
Users browsing this forum: No registered users and 1 guest