Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   variable values in string names (https://forums.graalonline.com/forums/showthread.php?t=66119)

excaliber7388 05-19-2006 09:58 PM

variable values in string names
 
Why won't this work? The trigger and parameter is being received fine, it's just not writing it in to the player's strings right:
PHP Code:

for(this.i=0;this.i<26;this.i++)
      {
        if(
client.varr_@this.i==|| this.i==25)
        {
          
client.varr_@this.i=params[2];
        } 
      } 


Admins 05-19-2006 10:31 PM

Must be
client.("varr_" @ this.i)

See http://wiki.graal.net/index.php/Crea...ring_variables

xXziroXx 05-19-2006 11:39 PM

And also, you might want to improve your styling..

excaliber7388 05-20-2006 02:51 AM

Also is it possible to add strings, like in C++ client.string1 may be 'hel' and client.string2 is 'lo' and client.string1+client.string2='hello'?

Luigi203 05-20-2006 03:18 AM

client.string1 = "hel";
client.string2 = "lo";
player.chat = client.string1 @ client.string2;

Thats what @ is. It appends two strings together.

excaliber7388 05-20-2006 03:33 AM

Well, I'm trying this, Shouldn't this work?
PHP Code:

      client.e_mail_messages=(client.e_mail_messages " Message: " client.("e_mail_" this.i)); 


Bl0nkt 05-20-2006 04:44 AM

You don't need parenthasis on the outside of the value.

NPC Code:
client.e_mail_messages = client.e_mail_messages @ " Message: " @ client.("e_mail_" @ this.i);



that would work.

Luigi203 05-20-2006 03:41 PM

What the hell, Hachi? It doesnt matter if he has 100 parentheses as long as he closes them up on the other side.

client.e_mail_messages=(((((client.e_mail_messages @ " Message: " @ client.("e_mail_" @ this.i))))));

would do the same thing as


client.e_mail_messages=client.e_mail_messages @ " Message: " @ client.("e_mail_" @ this.i);

To the author, what exactly are you trying to do? if client.e_mail_messages is a string list and you want to add to it use

client.e_mail_messages.add(" Message: " @ client.("e_mail_" @ this.i));

so, it will add to the actual list rather than appending to the end of the last thing in the list.

Skyld 05-20-2006 03:57 PM

Quote:

Originally Posted by excaliber7388
Why won't this work? The trigger and parameter is being received fine, it's just not writing it in to the player's strings right:

As Stefan said:
PHP Code:

this.index 3;
client.("foo_" this.index) = 4

... would be the same as doing:
PHP Code:

client.foo_3 4

Also.
PHP Code:

this.index 3;
client.("foo_" this.index).bar.baz 4

... would be the same as doing:
PHP Code:

client.foo_3.bar.baz 4


excaliber7388 05-21-2006 06:06 PM

1 Attachment(s)
Well, currently, I have a few problems. First, the quotes around all the variables, second word wrap isn't working, and finally, the "none" string for an empty message space isn't being read.
Test for none:
for(this.i=0;this.i<26;this.i++)
{
if(!client.("email_"@this.i)=="none")
{
client.email_messages.add(" Message: " @ client.("email_" @ this.i));
}
}
Screen shot of problem is below:

Bl0nkt 05-21-2006 06:11 PM

Quote:

Originally Posted by Bl0nkt
You don't need parenthasis on the outside of the value.

@ Mag (Luigi203) >:{

excaliber7388 05-21-2006 06:15 PM

XD Still, the "" confuse me, since they seem to be comming out of no where, ad not all the strings have extra ""

Skyld 05-21-2006 07:23 PM

Quote:

Originally Posted by excaliber7388
XD Still, the "" confuse me, since they seem to be comming out of no where, ad not all the strings have extra ""

The new engine, during array to string conversion, makes arrays take on an old engine "string list" appearance, i.e.
PHP Code:

this.foo = {"bar", {"baz""rtr"}}; 

... is essentially:
PHP Code:

setstring this.foo,"bar,"baz,rtr""


excaliber7388 05-21-2006 07:39 PM

Is it possible to inturupt this list to make it a vertical list?
ex:
Message: "hey",
Message "whatever",
etc

xXziroXx 05-21-2006 08:06 PM

Uh..

NPC Code:

this.var = {"message1", "message2"};
for (i = 0; i < this.var.size(); i ++) {
chat = this.var[i];
sleep(3);
}




I dont really get what you need help with..

excaliber7388 05-21-2006 08:15 PM

it's for displaying the string in the gui, I want it to seperate, so that each new message is on a sepperate line

xXziroXx 05-21-2006 08:18 PM

If you use a GuiMLTextCtrl you can do:


NPC Code:

new GuiWindowCtrl( "window" )
{
new GuiMLTextCtrl( "text1" ) {
x = 10, y = 10;
width = 150, height = 150;

text = "";
}
}



and to add text..

NPC Code:

text1.addtext( "text here", 0);


excaliber7388 05-21-2006 08:56 PM

Quote:

Originally Posted by xXziroXx
If you use a GuiMLTextCtrl you can do:


NPC Code:

new GuiWindowCtrl( "window" )
{
new GuiMLTextCtrl( "text1" ) {
x = 10, y = 10;
width = 150, height = 150;

text = "";
}
}



and to add text..

NPC Code:

text1.addtext( "text here", 0);


And will that work serverside, this is also for a chat window for an ingame DR chat, and every player will need to see what is changed.

xAndrewx 05-22-2006 07:11 PM

To add to an array
obj.add("lols");

to delete
obj.remove("lols"); <--Must be inside the array

to display
message( format("%s is the first index of the array", obj[0]) );

normally, you get left over "" for some reason, it's best to trim the obj
temp.trimmedaccount = player.account.trim();
obj.add( temp.trimmedaccount );


Infact, read this
http://wiki.graal.net/index.php/Crea...ject_functions


All times are GMT +2. The time now is 03:08 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.