Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   For() with strings? (https://forums.graalonline.com/forums/showthread.php?t=76742)

RyDaze 09-11-2007 10:49 PM

For() with strings?
 
Ok i want to make scripts short and simple as possible.. So is there any way to make a script using the for() to add a number and get the string info with out just making the string like a word (i have problems with this z.Z)..

PHP Code:

//#CLIENTSIDE
function onCreated(){
  
this.station 1;
  
onLoad();
}
function 
onLoad(){
  
temp.startstring "serverr.station"//serverr.station.# = info,info,info...;
  
temp.stations serverr.stations//serverr.stations = 2;
  
for(i=0i<temp.stations+1i++) {
    
this.station i;
  }
  
onRadio();
}
function 
onRadio(){
  
temp.info = @temp.startstring"." @this.station//this post to return.. info,info,info...;
  //but it just returns 0 or just thinks its just "server.station.1" (thinks of it as a word not a string)



Inverness 09-11-2007 11:16 PM

PHP Code:

//#CLIENTSIDE
function onCreated() {
  
this.station 1;
  
onLoad();
}
function 
onLoad() {
  
temp.startstring "serverr.station"//serverr.station.# = info,info,info...;
  
temp.stations serverr.stations//serverr.stations = 2;
  
for (0temp.stations 1++) {
    
this.station i;
  }
  
onRadio();
}
function 
onRadio() {
  
temp.info serverr.station.(@ this.station); //this post to return.. info,info,info...;
  //but it just returns 0 or just thinks its just "server.station.1" (thinks of it as a word not a string)


temp. strings are unique to a function and cannot be accessed outside of the function, they are cleared when the function ends.

Also, I really have no idea what you're trying to do with that script, it doesn't look like its doing anything.

RyDaze 09-11-2007 11:22 PM

its just an example, like theres a server string called, "serverr.station.1="head.png","UniStation","RyDaze : Hello","stationlink","hat-.png"

Anywho im trying to make a script that takes for() and takes info from a server string, aka "this.stationinfo = @serverr.station@ "." @this.station;"
this.stationinfo = this.stationinfo.tokenize();

than after that works i can use the "this.stationinfo[1]" and stuff for the radio display instead of making it detect check what station your on and than making the script really long depending on how many stations there are.. so i wont have to add like another display for station2 that contains station2 strings.. i want it to be one display that auto changes the this.stationinfo, when this.station changes to a diffrent #.

DustyPorViva 09-11-2007 11:31 PM

temp.stations.size()+1

RyDaze 09-11-2007 11:37 PM

Ok.. maybe im not getting my problem out clearly? or something.. So here goes nothing!

Quote:

Anywho im trying to make a script that takes for() and takes info from a server string, aka "this.stationinfo = @serverr.station@ "." @this.station;"
this.stationinfo = this.stationinfo.tokenize();
Thats the part i really having a problem to do.. because when ever i try something like that, the first part "this.stationinfo = @serverr.station@ "." @this.station;" it just displays as text instead of a string.. So how i make it get info from the string even if the this.station changes from = 1 to 2 or w\e?

Twinny 09-11-2007 11:42 PM

this.stationinfo = serverr.station.(@this.station).tokenize();

maybe? The script doesn't make much sense in the end... Perhaps onRadio should be doing

return serverr.station.(@this.station).tokenize(); if you want the function to return an array to the calling function.

DustyPorViva 09-11-2007 11:46 PM

Well for one:
temp.startstring = "serverr.station";
temp.startstring is going to = serverr.station, not the value of serverr.station, because you enclosed the variable in quotations.
temp.startstring = serverr.station;
Also what Inverness said, you can't pass temp.vars from one function to another(unless you pass the temp.var in the function parameters, which you should do in this case).

Googi 09-11-2007 11:54 PM

Quote:

Originally Posted by RyDaze (Post 1347214)
So how i make it get info from the string even if the this.station changes from = 1 to 2 or w\e?

Like Inverness said, serverr.station.(@ this.station) should do it for you. If that doesn't work it might be serverr.station.(this.station)

RyDaze 09-12-2007 12:30 AM

Ok, thanks :)


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

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