Author Topic: Using %blah['blah'] stuff.  (Read 2134 times)

Yeah but how? You can't even pass an array as a parameter. That's absurd?
True.

A terrible feature that can act like an array is still far better than no array at all. Also, rather than set each array item, why not load from a file into the array? Easier to change, data removed from code, you can have it dynamically find the upper bound at load-time.

Also: array as a parameter: Can be done, if the array is defined on a scriptObject, although that is barely better than making it global...


Anyway, more on topic:
You can use an array anywhere you can use a regular variable, it isn't that hard to use once you know how.

You can use an array anywhere you can use a regular variable, it isn't that hard to use once you know how.
i already knew this

i just want to know how to set them. :U

How do you set %i? %i[3] works identically. It will automatically add a new variable when you use a new index. %a["stuff"] is also valid, and you do not need to define it ahead of time. Other variables, too. %a[getrandom(0, 999999999999999) @ "blocks"] is a perfectly valid variable, though good luck ever finding it again... (without srand, of course)

so if i did something like

%client.bear[1] = 5;
%client.bear[2] = 6;

I'd be able to echo %client.bear[1] and it'd be 5, and %client.bear[2] would be 6?


And more-so to that,

%client.bear[1] = 5;
%client.bear[2] = 6;
for(%x=1;%x<=2;%x++)
echo(%client.bear[%x]);

This would echo
5
6

Could I get some help? After reading this topic I tried to make a simple script but it seems to think that there is something wrong with it.

Code: [Select]
functionserverCmdtest (%client)
{
$RandomArray[1]="Random One";
$RandomArray[2]="Random Two";
$RandomArray[3]="Random Three";

%RandomTest = getrandom(1,3);

MessageClient(%client, "", $RandomArray[%RandomTest]);

}



MessageClient(%client, '', $RandomArray[%RandomTest]);

two single quotes

Its always the simple stuff isn't it lol ty Kalphiter.
hmm nvm, it still doesn't wan't to work.
« Last Edit: October 14, 2010, 09:37:25 PM by Gartanium »

MessageClient(%client, '', $RandomArray[%RandomTest]);

two single quotes
An empty tagged string will be the same as a blank string.

The problem is that there's no space between function and serverCmdTest

Could I get some help? After reading this topic I tried to make a simple script but it seems to think that there is something wrong with it.

Code: [Select]
functionserverCmdtest (%client)
{
$RandomArray[1]="Random One";
$RandomArray[2]="Random Two";
$RandomArray[3]="Random Three";

%RandomTest = getrandom(1,3);

MessageClient(%client, "", $RandomArray[%RandomTest]);

}






Code: [Select]
function serverCmdtest(%client)
{
$RandomArray[1]="Random One";
$RandomArray[2]="Random Two";
$RandomArray[3]="Random Three";

%RandomTest = getrandom(1,3);

MessageClient(%client, '', $RandomArray[%RandomTest]);

}



okay so i was right about how to use them.
Thanks, guys. :D