Strings

RocketTo5

Member
I'm not quite understanding this

GML:
//My string, argument0, is = obj_i_crown
str = argument0

new_str = string_delete(str,1,4)

obj_hud.new_str += 1
So basically I am trying to access one of my instances, take the name of it, obj_i_crown, and cut it down to i_crown and make it a variable. I just need to access obj_hud.i_crown, and increase the count by 1. Instead, I believe I am literally accessing obj_hud.new_str, which isn't a variable obviously. How can I do this?
 

Nidoking

Member
You're trying to use reflection. I advise against that in general. You'd be better off finding another way to relate these strings to information, like a map or struct. However, if you absolutely must do what you're trying to do, try variable_instance_set.
 

RocketTo5

Member
You're trying to use reflection. I advise against that in general. You'd be better off finding another way to relate these strings to information, like a map or struct. However, if you absolutely must do what you're trying to do, try variable_instance_set.
Oh okay, appreciate that intel đź‘Ť
 
Top