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.)