Jump to content
Sign in to follow this  
olseric

Dynamic Object Names

Recommended Posts

I need an expert opinion on this one.

I'm trying to make targets randomly pop-up in a given time frame...in short, the problem that I'm having is the script won't acknowledge the dynamically generated object names.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">target1 setdammage 0.8

Will work just fine...but...

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_targetname = target1

_targetname setdammage 0.8

Will not work at all.

Suggestions?  Ideas?  

I think the easy way would be to get the now string value variable converted back to an object, however, I can't seem to figure out how.  Furthermore, I have already considered passing an array to it, however, I want to somehow "short form" this.

Thanks for your help in advance.

Share this post


Link to post
Share on other sites

"targetname" could be a reserved variable. Give it a different name and try again.

Share this post


Link to post
Share on other sites

Okay, tried that, no avail. I should add this. The error that I'm getting is an "Object Expected, Sting Presented" one.

Basically, what I'm doing to create the random object selector is taking a number and slapping it on the end of target using the format command...i.e.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_thistarget = format ["target%1",_number];

Apparently, this is causing it to be treated as a string. So, the question of the day is, is there some way to change the variable type? Or, is there a way to join two variables to achieve my overall goal here?

Share this post


Link to post
Share on other sites

Hmm try

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_thistarget = call format ["target%1",_number];

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×