PDA

View Full Version : Problem?


godofwarares
02-23-2007, 10:19 PM
I have a problem when it comes to calling classes, I want to use a variable to hold the class name and use the :: operator to call it.

Here is a snippet from my code:


for ( temp.a = 0; temp.a < temp.getClasses.size(); temp.a++ )
{
temp.res;

this.join(temp.getClasses[temp.a]);

temp.res = battledata::start();

if (!temp.res)
{
return false;
}
}

return true;

^ That works, but this doesn't:

for ( temp.a = 0; temp.a < temp.getClasses.size(); temp.a++ )
{
temp.res;

this.join(temp.getClasses[temp.a]);

temp.res = (@ temp.getClasses[temp.a])::start();

if (!temp.res)
{
return false;
}
}

return true;


Any ideas?

xXziroXx
02-23-2007, 11:42 PM
Ugh, I cant even read the code thanks to the styling..

killerogue
02-23-2007, 11:43 PM
Ugh, I cant even read the code thanks to the styling..

Thank you, Ziro. That was extremely helpful. :whatever:

godofwarares
02-23-2007, 11:46 PM
Ugh, I cant even read the code thanks to the styling..

How can you not read it?!

:whatever:

xXziroXx
02-23-2007, 11:53 PM
How can you not read it?!

:whatever:

I just.. cant. Want to see how different your styling is to mine?


for (temp.a = 0; temp.a < temp.getClasses.size(); temp.a++) {
temp.res;

this.join(temp.getClasses[temp.a]);

temp.res = battledata::start();

if (!temp.res) return false;
}

return true;


That how I would have styled it. Now, give me a few seconds and I will TRY to check your script for errors.

Hmm. I'm not quite sure of what you are trying to accomplish, but, perhaps trying this will help?


for (a: temp.getClasses) {
temp.res;

this.join(a);

temp.res = (@a)::start();

if (!temp.res) return false;
}
return true;

Angel_Light
02-24-2007, 12:36 AM
ha mine is really different, no one else I know likes it but makes scripting and script reading easier for me. XP

Kristi
02-24-2007, 02:54 AM
Assuming that temp.getClasses is correctly assigned (please show us that code), we can only assume that (anything):: just doesnt work. for the sake of testing, try (@"battledata")::start

Tell me if that works or not. If it doesn't, looks like we need a new way to dynamically call a function from a class!

Edit:
I decided to not be lazy and try it, (@"anything")::whatever() will not work.

Esentially what you are doing is giving the same npc multiple start() functions. it would be like doing this.

function hi() {
return 2;
}

function hi() {
return 4;
}

Maybe you should find a better system? : (