ID:139994
 
Code: Affinity Selection.
mob/var/tmp/CA=1

AffinityRight()
usr.CA++
if(usr.CA>7) usr.CA=1
switch(usr.CA)
if(1)
winset(usr,null,"affinitypic.image=['Avatar_Vongola.png']; affinityname.text='Sky'; affinitybio.image=['Bio_.png']")
usr.Affinity = "SkyAttempt"
if(2)
winset(usr,null,"affinitypic.image=['Avatar_Cavallone.png']; affinityname.text='Cloud'; affinitybio.image=['Bio_.png']")
usr.Affinity = "Cloud"
if(3)
winset(usr,null,"affinitypic.image=['Avatar_Giglio.png']; affinityname.text='Mist'; affinitybio.image=['Bio_.png']")
usr.Affinity = "Mist"
if(4)
winset(usr,null,"affinitypic.image=['Avatar_Gesso.png']; affinityname.text='Rain';affinitybio.image=['Bio_.png']")
usr.Affinity = "Rain"
if(5)
winset(usr,null,"affinitypic.image=['Avatar_Cavallone.png']; affinityname.text='Storm'; affinitybio.image=['Bio_.png']")
usr.Affinity = "Storm"
if(6)
winset(usr,null,"affinitypic.image=['Avatar_Giglio.png']; affinityname.text='Sun'; affinitybio.image=['Bio_.png']")
usr.Affinity = "Sun"
if(7)
winset(usr,null,"affinitypic.image=['Avatar_Gesso.png']; affinityname.text='Thunder'; affinitybio.image=['Bio_.png']")
usr.Affinity = "Thunder"


Problem description: Im not quite sure if this is an effective method of doing what it does if the "right" verb is called it simply cycles through the stages of the CA tmp var. but if they dont move their selection to begin with they dont get the "SkyAttempt" given to them unless they toggle back through to it.

A fix would be simply making the default var be a SkyAttempt as the attempt is calculated upon clicking the finish verb anyway.

Would there be a better way of coding this or would this suffice?

PS: Yes im aware there is repeats on the avatar it is merely there to ensure that the images changed as i do not have pics for the flames yet :D
Lists sound like most reasonable way to me.
var
listAffinity = list("SkyAttempt", "Cloud", "Mist", "Rain", "Storm", "Sun", "Thunder")
listAffinityText = list("Sky", "Cloud", "Mist", "Rain", "Storm", "Sun", "Thunder")
mob/var/tmp/CA=1

AffinityRight()
CA++
if(CA>7) CA=1
winset(src,null,"affinitypic.image=['Avatar_Vongola.png']; affinityname.text=listAffinityText[CA]; affinitybio.image=['Bio_.png']")
Affinity = listAffinity[CA]

But not sure if I typed it right :D, around that anyways
In response to Ripiz
Hmm i added in usr.CA for all the CA references but on move it doesnt seem to work it makes the text for the affinity

-Also without adding the usr.CA the compiler gets errors for each CA reference-

ListAffinity.. (and cuts off due to the label being to small)

EDIT: On expansion of label it goes ListAffinityText then goes through the numbers on click
In response to Midgetbuster
He forgot a pair of brackets. It should be [listAffinityText[CA]]
In response to Garthor
That works perfectly after adding the usr. before the CA references.

Although it now requires 4 lists to run properly one for Avatar one for bio one for text and the final to define the affinity.

None the less im guessing lists are alot more effective are they not?

var
listAffinity = list("SkyAttempt", "Cloud", "Mist", "Rain", "Storm", "Sun", "Thunder")
listAffinityText = list("Sky", "Cloud", "Mist", "Rain", "Storm", "Sun", "Thunder")
listAffinityPic = list("Avatar_Vongola.png", "Avatar_Cavallone.png", "Avatar_Giglio.png", "Avatar_Gesso.png", "Storm", "Sun", "Thunder")
listAffinityBio = list("Avatar_Vongola.png", "Avatar_Cavallone.png", "Avatar_Giglio.png", "Avatar_Gesso.png", "Storm", "Sun", "Thunder")

AffinityRight()
usr.CA++
if(usr.CA>7) usr.CA=1
winset(src,null,"affinitypic.image=[listAffinityPic[usr.CA]]; affinityname.text=[listAffinityText[usr.CA]]; affinitybio.image=[listAffinityBio[usr.CA]]")
usr.Affinity = listAffinity[usr.CA]


That works perfectly pretty much but there are two thingies that are similar. so in total would come to 8 lists for that purpose.