Can I use an items self.name to choose an attribute instead, to tidy my rules???
StormyStudio
United KingdomMember Posts: 3,989
Ok, I think I've seen this done before. Just not sure if I'm doing it right. (I'm not)
I have some integer attributes setup
game.slot_1
game.slot_2
game.slot_3
Then I have 3 actors (all original prototypes), I've opened each one (not pressed the big padlock) and changed their names to 1, 2 and 3.
Now can I refer to them in a rule (with in the edit prototype section)
for example
if game.slot_(self.Name) = 5 then do such and such.
Rather than
if game.slot_1 = 5 then do such and such.
I've tried the above, and it changes the rule (self.Name) to 1, when I close and reopen it. (and deletes my (self.Name)
should i try
game.slot_+(self.Name)
or something like that, or is it simply not possible.
.............
I want to do this, so I can easily change rules for 5 different actors, without tonnes of rules, or changing them separately for each actor.
I'm actually making a demo 'collected items menu' which I'll upload once it works perfectly and tidily. Plus use a variation of it in my game.
I have some integer attributes setup
game.slot_1
game.slot_2
game.slot_3
Then I have 3 actors (all original prototypes), I've opened each one (not pressed the big padlock) and changed their names to 1, 2 and 3.
Now can I refer to them in a rule (with in the edit prototype section)
for example
if game.slot_(self.Name) = 5 then do such and such.
Rather than
if game.slot_1 = 5 then do such and such.
I've tried the above, and it changes the rule (self.Name) to 1, when I close and reopen it. (and deletes my (self.Name)
should i try
game.slot_+(self.Name)
or something like that, or is it simply not possible.
.............
I want to do this, so I can easily change rules for 5 different actors, without tonnes of rules, or changing them separately for each actor.
I'm actually making a demo 'collected items menu' which I'll upload once it works perfectly and tidily. Plus use a variation of it in my game.
Comments
To concatenate strings you use double dots (..), so I think you'd use "game.slot_"..(self.Name) in Expression Editor. The trouble is that from memory Rules only allow comparison of a single attribute against an expression, not two expressions against one another (ran into this last night). You'd have to store "game.slot_"..(self.Name) to a string Attribute then Chaco against that.
As for whether (self.Name) yields the name of the prototype or the instance, I'm not sure, sorry.
This is at best only part of the answer, but I'm sure some helpful expert will be floating about to set you straight soon (hark! A distant bleating…?)
Just tried the ..(Self.Name)
but get the same thing, it turns it into the name of the actor, and does not keep it open for other prototypes.
I'll wait to see if any other replies come in, other wise try the "game.slot_" string attribute idea.
thanks..
EDIT: I'm actually going to hit the hay, with hope in my eyes, that some kind sole will explain the best way to solve this problem. (7 long evenings, and 1 day solidly pushing my grey matter working on my game is taking its toll. Will make time to relax and watch 'Dexter' tomorrow.