Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: [Solved] Variables in resource names  (Read 1114 times)

0 Members and 1 Guest are viewing this topic.

Ryuza

That one guy
[Solved] Variables in resource names
« on: February 24, 2010, 04:52:46 pm »
  • RyuKage2007
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 290
Well, I think that is barely worth making a topic for but I'm having a bit of trouble. I'm trying to figure out how I would go about using the value of a variable as part of a resource name, for example, say I have the variable 'ballcolor' (which can equal "G" or "R") and I have two sprites 'spr_bal_G' and 'spr_ball_R' how would go about using that variable to make the sprite dependent on the variable, I thought it would be something like this but it doesn't work:

draw_sprite(spr_ball_+string(ballcolor), 0, x, y)

So in the end the sprite is spr_ball_R.

Thats the best example I could think of off the top of my head (not a very good one though as you could simply do image_blend, but thats not the point). I'm relatively sure I've used +string()+ in a different programming language, I just need to figure out the GM equivalent, if there is one. I'm sure its rather simple, I've been looking around GM help for an answer but haven't come across one yet. Anyone have any ideas?

« Last Edit: February 24, 2010, 05:20:57 pm by RyuKage2007 »
Logged
<- Koholint Island - MC Style  <- Link's Awakening Photo Recolors  <- Wind Waker 3D Resources <- Super Mario Bros Crossover
  • RyuKage2007's Youtube

DJvenom

super-sage
Re: Using variables in resource names
« Reply #1 on: February 24, 2010, 05:11:23 pm »
  • Colbydude was here.
  • *
  • Reputation: +7/-0
  • Offline Offline
  • Gender: Female
  • Posts: 2898
execute_string("sprite_index=spr_ball_"+string(ball_color)) in step event should work. i don't remember 100% if that's how the function works though. You can play around with it tho ;p
Logged
I do art
I ermmm... DID do art
I do art

Ryuza

That one guy
Re: [Solved] Using variables in resource names
« Reply #2 on: February 24, 2010, 05:20:43 pm »
  • RyuKage2007
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 290
Thanks DJ, it worked perfectly.
Logged
<- Koholint Island - MC Style  <- Link's Awakening Photo Recolors  <- Wind Waker 3D Resources <- Super Mario Bros Crossover
  • RyuKage2007's Youtube
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.173 seconds with 43 queries.

anything