Concatenate for variables?
3itg
Member, PRO Posts: 382
I have an actor that can spawn a number of times.
I track its location.
I have it set its ID like so:
self.id = game.AICount
game.AICount+1
then I use that ID to do stuff...
if self.ID = 1: Constrain game.Position1X to self.position.x
Constrain game.Position1Y to self.position.Y
if self.ID = 2: Constrain game.Position2X to self.position.x
Constrain game.Position2Y to self.position.Y
can rules for every ID be avoided by concatenating self.ID with the Static part of the variable name?
I cant figure out how this could be used as the first variable (its not possible to enter expressions there...)
but it sure would be awesome to be able to do something like game.Position..self.ID and have it produce a proper Variable name that could be worked with, like game.Position..self.ID is equal to game.Position1 (when self.ID = 1).
It would also save me hundreds of rules.
This is in a very, very heavy actor that spawns multiple times. Lots of rules... Crashes creator(with all the rules minimized it will open without crashing)... its a rough story.
But anyway, removing rules has proven to work great for alleviating the performance issue.
I reduced the actors number of rules by 20% using this technique where is was possible, but now I have a bunch of other rules based on IF statements and the self.ID... This is probably another 20% or a little more, if these can be reduced then I'll really be in business.
I track its location.
I have it set its ID like so:
self.id = game.AICount
game.AICount+1
then I use that ID to do stuff...
if self.ID = 1: Constrain game.Position1X to self.position.x
Constrain game.Position1Y to self.position.Y
if self.ID = 2: Constrain game.Position2X to self.position.x
Constrain game.Position2Y to self.position.Y
can rules for every ID be avoided by concatenating self.ID with the Static part of the variable name?
I cant figure out how this could be used as the first variable (its not possible to enter expressions there...)
but it sure would be awesome to be able to do something like game.Position..self.ID and have it produce a proper Variable name that could be worked with, like game.Position..self.ID is equal to game.Position1 (when self.ID = 1).
It would also save me hundreds of rules.
This is in a very, very heavy actor that spawns multiple times. Lots of rules... Crashes creator(with all the rules minimized it will open without crashing)... its a rough story.
But anyway, removing rules has proven to work great for alleviating the performance issue.
I reduced the actors number of rules by 20% using this technique where is was possible, but now I have a bunch of other rules based on IF statements and the self.ID... This is probably another 20% or a little more, if these can be reduced then I'll really be in business.
Comments
or is it because I said "concatenate"?
Since there doesn't seem to be a workaround to concatenating for a variable name, Would adding each statement to the previous statements "Otherwise" help reduce the load?
example:
__Rule1 No Otherwise_____
if self.ID = 1: Constrain game.Position1X to self.position.x
Constrain game.Position1Y to self.position.Y
if self.ID = 2: Constrain game.Position2X to self.position.x
Constrain game.Position2Y to self.position.Y
_________________________
__Rule2 With Otherwise__
if self.ID = 1: Constrain game.Position1X to self.position.x
Constrain game.Position1Y to self.position.Y
OTHERWISE
if self.ID = 2: Constrain game.Position2X to self.position.x
Constrain game.Position2Y to self.position.Y
_________________________
Any one have experience with this?
Constrain PosX to TableCellValue([Table],self.ID,1)
Constrain PosY to TableCellValue([Table],self.ID,2)
I use tables alot but this specific issue I cant seem to wrap my head around.
When I looked previously, It didnt seem possible.