Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Variables problem (https://forums.graalonline.com/forums/showthread.php?t=66292)

wild8900 05-28-2006 06:47 PM

Variables problem
 
I got a particle script from a friend to learn but I coudnt put it in the level right. I got it actualy to appear in the level (the script is a class) but I cant get the x to appear at this.smokex and this.smokey even though in the script I have it set to be there.
NPC Code:
// NPC made by Irata
if (created){
this.smokex=x;
this.smokey=y;
}
join smoketest;



and in the particle script I use
NPC Code:
if (created||timeout){
with (findimg(200)){
x=this.smokex;
y=this.smokey;
}


timeout=0.05;
}

ApothiX 05-29-2006 01:09 AM

PHP Code:

with (findimg(200)){
x=this.smokex;
y=this.smokey;


You need to use thiso. if you're in a with() block.

wild8900 05-29-2006 01:37 AM

I just put that but it didnt work.
PHP Code:

if (created||timeout){
  
with (findimg(200)) {
  
x=thiso.smokex;
  
y=thiso.smokey;
    }
    
timeout=0.05;


Im guessing its reading the var wrong from the basic script with join in it.
PHP Code:

if (created){
this.smokex=x;
this.smokey=y;
}
join smoketest

This is the basic object (in the level)

ApothiX 05-29-2006 06:29 AM

do you have attachtoowner set in the particle? and what layer are you using for the particles? If you're using 4+ (I believe) they are screen coordinates and not level coordinates.

wild8900 05-29-2006 09:25 AM

this is all I used in the object in the level:
PHP Code:

if (created){
this.smokex=x;
this.smokey=y;
}
join smoketest

i used attachtoowner just now. Didnt work.
And the layer is 2

Luigi203 05-29-2006 10:07 AM

PHP Code:

if (created){ 
thiso.smokex=x
thiso.smokey=y



You have to set thiso.smokex and thiso.smokey which is compeletely different from this.smokex and this.smokey.

ApothiX 05-29-2006 04:35 PM

Quote:

Originally Posted by wild8900
this is all I used in the object in the level:
PHP Code:

if (created){
this.smokex=x;
this.smokey=y;
}
join smoketest

i used attachtoowner just now. Didnt work.
And the layer is 2

Could I see some of the particle modifyer code? Perhaps you are using some kind of static x and y modification in the code, and are not relying on the position of the NPC.


Quote:

Originally Posted by Luigi203
PHP Code:

if (created){ 
thiso.smokex=x
thiso.smokey=y



You have to set thiso.smokex and thiso.smokey which is compeletely different from this.smokex and this.smokey.

.. thiso. is used to access this. variables in the parent.

PHP Code:

function onCreated() {
  
this.test "Weee";

  
with(findNPC("SomeDB-NPC")) {
    
this.blah thiso.test;
  }


this.blah in SomeDB-NPC will now contain "Weee"

Please do not post advice if you don't know what you're talking about.


All times are GMT +2. The time now is 06:21 AM.

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