Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help String reference within constant name (Advanced)
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#7
RE: String reference within constant name (Advanced)

If I understand correctly your scenario, you just want an action, like remove an item,
if a variable, like x1y1 is set true, and matches with the item's number stored in its name.

I just tested and this is how it worked for me:

PHP Code: (Select All)
//public arrays x and y, size 10, false by default.
    
bool[] (10false);
    
bool[] (10false);

void RemoveAnItem string &in asItem )
{
    
string strIndex StringSubasItem410 );
    
int iIndex GetIndexstrIndex );
    
    if (
x[iIndex] and y[iIndex]) { RemoveItemasItem ) }


I'm sure you understand what that function is doing, you're even gonna improve it. Btw, you need this function I just did:

PHP Code: (Select All)
int GetIndex string &in strIndex )
{
    
int aiMax 10;
    for (
int i=0;i<aiMax;i++) {
        if (
"a"+== "a"+strIndex) { return i;}
    }
    return 
0;


So, if you pass RemoveItem("item5"), the function checks x[5] and y[5], if both are true, item5 is removed.

I don't know how you planned to change these variables named x2y3, etc, but it's the same way for x[] and y[].

Am I missing something? Oh the variables are all set to check to 10, you may want to change that.

03-09-2014, 11:23 AM
Find


Messages In This Thread
RE: String reference within constant name (Advanced) - by Daemian - 03-09-2014, 11:23 AM



Users browsing this thread: 2 Guest(s)