Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Loriel's Message System -> GS2 (https://forums.graalonline.com/forums/showthread.php?t=61560)

Torankusu_2002 10-03-2005 03:42 AM

Loriel's Message System -> GS2
 
1 Attachment(s)
So, In my attempts to learn GS2 better, I figured I'd take a relatively simple script (Loriel's Message System), and convert it to use in GS2. I think I have most of it formatted, but there are things I am sure I am missing, because it doesn't display the message. Other than that, I get no errors in the script compiler for RC, but.....It still won't show the message?

NPC Code:


Code for the Test-String setter I am using.
// NPC made by Torankusu
//#CLIENTSIDE

function onCreated() {
setshape(1,32,32);

}
function onPlayerTouchsMe() {
client.addmessage = "This is a test";
}




Here's my version of Loriel's script.
NPC Code:


//#CLIENTSIDE


//Displaying the system messages
function onCreated(){
for (msgcount=0; strlen(makevar("this.msg" @ msgcount))>0; msgcount++){
this.msg(msgcount) =" ";
}
this.msg0 = "Welcome";
setTimer(0.05);
}

function onTimeout(){



//Get New Messages
len = client.addmessage.size();
for (i=0; i<len && msgcount<50; i++) {
// Never show more than 50 messages
if (strlen(getstring(client.addmessage)[i])>0) {
makevar("this.msg" @ msgcount),this.r,"getstring(client.addmessage)[i]";
msgcount ++;
}
}

if (i>0) client.addmessage = " ";
ydist = 20;
for (i=msgcount-1; i>=0; i--) {
size = cos((this.r-getstring(this.msg(i))[0])/10)*0.75;
si = 200+(msgcount-i)*3;
if (size>0.2) {
for (m=0; m<2; m++) {
showtext(si+m,screenwidth-20*size+m,screenheight-ydist+m,"Arial","r",makevar("this.msg" @ i));
changeimgzoom(si+m,size);
changeimgvis(si+m,14-m);
}
//screenwidth-24*size-(1-size)*16, Wtf do these do?
//screenheight-ydist-(1-size)*16; Wtf do these do?
changeimgvis(si+2,14);
changeimgzoom(si+2,size);
changeimgmode(si+2,1);
changeimgcolors(si,1,1,0.5,1);
changeimgcolors(si+1,0.7,0.4,0,1);
changeimgcolors(si+2,0.5,0.7,1,0.9);
ydist += size*20;
} else {
for (m=0; m<3; m++) hideimg(si+m);
for (j=i; j<msgcount; j++)
makevar("this.msg" @ j) = makevar("this.msg" @ j+1);

}
}
this.r += 0.05;
setTimer(0.05);
}




please point out any errors and their gs2 fixes. Like I said, I'm trying to learn to use the format better.


Also, attached is the original script. (maybe not original, but it's the working GS1 script I was using and converted.)

Admins 10-03-2005 04:28 PM

The usage of makevar for such stuff is not recommended since it makes things looks more complicated than needed and is slower than directly making up a correct variable name.

NPC Code:

setstring this.msg#v(msgcount),#v(this.r),"#I(client.addmess age,i)";
->
this.("msg" @ msgcount) = {this.r, client.addmessage[i]};

setstring this.msg#v(j),#s(this.msg#v(j+1));
->
this.("msg" @ j) = this.("msg" @ (j+1));


Torankusu_2002 10-03-2005 05:42 PM

I used makevar because Lance said he thought that might've been what was wrong with it.


All times are GMT +2. The time now is 06:54 PM.

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