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 11-23-2008, 10:59 AM
Raeiphon Raeiphon is offline
I never asked for this.
Join Date: Jun 2005
Posts: 855
Raeiphon is on a distinguished road
this.attr[#] not carrying across, triggerclient not working either

NPC Code:

function onCreated()
{
showcharacter();
this.target = findplayer(this.owner);
this.attr[2] = new[5][2];
setTimer(.3);
}
function onPlayerChats()
{
if (player.account == "raeiphon" && player.chat.starts("/destroy")) { this.destroy(); }
if (player.account == "raeiphon" && player.chat.starts("/show")) { this.chat = this.attr[2][0]; }
if (player.account == "raeiphon" && player.chat.starts("/halt")) { triggerclient(); }
}
function onTimeout()
{
if (this.attr[2].size() > 5) { this.attr[2] = this.attr[2].subarray(0,5); }
this.attr[2].insert(0, {this.target.x,this.target.y});
triggerclient(this.attr[2]);
setTimer(.05);
}
//#CLIENTSIDE
function onCreated()
{
//setTimer(.3);
}
function onTimeout()
{
this.x = this.attr[3][4][0];
this.y = this.attr[3][4][1];
setTimer(.3);
}
function onActionClientside(var)
{
this.attr[3] = var;
}




Originally this started out just setting this.attr[3] on the serverside, since I was told by Tig that it apparently carries across through clientside/serverside barriers and whatnot. That quickly turned out to be false, so I stuck a triggerclient in the timeout to simulate this being the case.

However, it doesn't work. Simply does not work. This.attr[3] is 0 always. Don't tell me that attrs can't hold arrays either, because they can - a echo on the variable on the serverside tells us this (see /show).

Any ideas?
__________________

I hope for nothing. I fear nothing. I am free.
Reply With Quote
  #2  
Old 11-23-2008, 11:07 AM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
The problem here is that you are trying to use the attributes as arrays, which won't work. You can, however, use them as string, seperate each element with a comma, and use tokenize(",") on them when reading them. So they would be a semi-array, or something..
Anyway, when you've done converting your code to do that, it will also reflect itself between server- and clientside.
Reply With Quote
  #3  
Old 11-23-2008, 11:10 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Try this:
PHP Code:
function onCreated()

{
  
showcharacter();
  
this.target findplayer(this.owner);
  
this.attr[2] = new[5][2];

  
setTimer(.3);
}

function 
onPlayerChats()

{
  if (
player.account == "raeiphon" && player.chat.starts("/destroy")) { this.destroy(); }
  if (
player.account == "raeiphon" && player.chat.starts("/show")) { this.chat this.attr[2][0]; }
  if (
player.account == "raeiphon" && player.chat.starts("/halt")) { triggerclient(); }
}

function 
onTimeout()

{
  if (
this.attr[2].size() > 5) { this.attr[2] = this.attr[2].subarray(0,5); }
  
this.attr[2].insert(0, {this.target.x,this.target.y});
  
//triggerclient(this.attr[2]);
  
setTimer(.1);
}

//#CLIENTSIDE
function onCreated()
{
 
setTimer(.3);
}

function 
onTimeout()
{
  
this.chat this.attr[2];
  
this.this.attr[2][4][0];
  
this.this.attr[2][4][1];
  
setTimer(.3);

}

function 
onActionClientside(var)
{
this.attr[3] = var;

You've proven they attr's can store arrays... I'm just not sure if they can be passed to the clientside.
Reply With Quote
  #4  
Old 11-23-2008, 11:19 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
This is what I've come up with:
PHP Code:
function onCreated() {
  
this.attr[5] = {{5,2},{6,8},{2,4}};
}
//#CLIENTSIDE
function onCreated() {
  
setTimer(0.1);
}

function 
onTimeout() {
  
temp.test = (this.attr[5]);
  
this.chat test[2][1];
  
setTimer(0.1);

Will echo 4.
Reply With Quote
  #5  
Old 11-23-2008, 12:24 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
http://forums.graalonline.com/forums...ad.php?t=72413

__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #6  
Old 11-23-2008, 12:27 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Quote:
Originally Posted by xXziroXx View Post
No need to tokenize or anything, what I posted works fine
Reply With Quote
  #7  
Old 11-23-2008, 12:40 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by DustyPorViva View Post
No need to tokenize or anything, what I posted works fine
Mh, I tried several things to get arrays working with attributes on Era, and it didn't work for some reason. Weird.
Reply With Quote
  #8  
Old 11-23-2008, 12:46 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by Crow View Post
Mh, I tried several things to get arrays working with attributes on Era, and it didn't work for some reason. Weird.
That's because attributes doesn't support arrays, and you have to convert it into a string and then "pretend" it's an array. The only drawback is that it's impossible to use sub-arrays in it, since it won't be able to tell a difference between it.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #9  
Old 11-23-2008, 01:17 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
I had no problem with the script I posted. It works fine and I even did some pseudo-smooth-moving and such with the baddy. Subarrays worked and everything.
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 02:57 AM.


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