Page 1 of 1
How to define image to a Variable? SOLVED
Posted: Thu Dec 22, 2011 5:38 pm
by NickelBuckle9
So, I figured out how to get the variables working. I now have a variable "HAIR" which specifies the correct image file in the correct format:
Pictures/H1A.png
by using something like this:
Code: Select all
$ HAIR = "Pictures/H" + HAIRSTYLE + HAIRCOLOR + ".png"
Is there any way to define the image "hair" by using this variable?
Code: Select all
image hair = HAIR
image hair = str(HAIR)
#and...
image hair = "[HAIR]"
# don't work D: What do I do???
image hair = "[HAIR]" comes the closet to working, as it runs smoothly until it must display the image. However, red text appears that says:
"Image 'Pictures/H25B.png' not found"
Any ideas? Thank you so much!
Re: Simple Variables not working...?
Posted: Thu Dec 22, 2011 7:20 pm
by Mild Curry
Hmm...try it this way:
Code: Select all
$ HAIR = "Pictures/H" + str(HAIRSTYLE) + str(HAIRCOLOR) + ".png"
It's basically assuring the game that those variables are strings too, and therefore part of the larger string.
Re: Simple Variables not working...?
Posted: Thu Dec 22, 2011 7:26 pm
by NickelBuckle9
Mild Curry wrote:Hmm...try it this way:
Code: Select all
$ HAIR = "Pictures/H" + str(HAIRSTYLE) + str(HAIRCOLOR) + ".png"
It's basically assuring the game that those variables are strings too, and therefore part of the larger string.
Thanks! ...but I managed to figure out why it wasn't working. Apparently it needs to be in the actual game script after the start label, not at the beginning.
Would you have any idea how to use this variable to define an image? I edited the topic as you replied it seems. >_>
Re: How to define image to a Variable?
Posted: Fri Dec 23, 2011 3:17 am
by Mild Curry
Hmm...that's odd. "image hair = HAIR" works fine for me.
Well, anyway, you don't want to define 'hair' as an image. I don't think images defined in init blocks can be changed.
Try this:
Code: Select all
$ HAIR = "Pictures/H" + HAIRSTYLE + HAIRCOLOR + ".png"
show expression HAIR
*sorry if this is irrelevant again*
Re: How to define image to a Variable?
Posted: Fri Dec 23, 2011 12:16 pm
by NickelBuckle9
Mild Curry wrote:Hmm...that's odd. "image hair = HAIR" works fine for me.
Well, anyway, you don't want to define 'hair' as an image. I don't think images defined in init blocks can be changed.
Try this:
Code: Select all
$ HAIR = "Pictures/H" + HAIRSTYLE + HAIRCOLOR + ".png"
show expression HAIR
*sorry if this is irrelevant again*
AHHHH! It worked! Thank you so much! You just saved my over 150 lines of repetitive code, haha. <3