Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-03-2005, 03:42 AM
Torankusu_2002 Torankusu_2002 is offline
'been round.
Torankusu_2002's Avatar
Join Date: Nov 2001
Posts: 1,246
Torankusu_2002 is on a distinguished road
Loriel's Message System -> GS2

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.)
Attached Files
File Type: txt msgsys.txt (2.0 KB, 141 views)
__________________
torankusu's

Last edited by Torankusu_2002; 10-03-2005 at 04:51 AM..
Reply With Quote
  #2  
Old 10-03-2005, 04:28 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
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));

Reply With Quote
  #3  
Old 10-03-2005, 05:42 PM
Torankusu_2002 Torankusu_2002 is offline
'been round.
Torankusu_2002's Avatar
Join Date: Nov 2001
Posts: 1,246
Torankusu_2002 is on a distinguished road
I used makevar because Lance said he thought that might've been what was wrong with it.
__________________
torankusu's
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 07:28 PM.


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