Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Need Simple Help! (https://forums.graalonline.com/forums/showthread.php?t=66481)

xshadx 06-05-2006 03:14 PM

Need Simple Help!
 
Ok Well, I'm not that good at scripting -_- I was wondering how you would script like a... NPC When you walk under it it goes clear so you can see your self then sets back. i know this is probably a simple seteffect but im just asking for help =)

xXziroXx 06-05-2006 03:19 PM

PHP Code:

//#CLIENTSIDE
function onCreated()
{
  
setImg"imagename");
  
this.imgwidth #;  // Set this to the pixel width of the image.
  
this.imgheight #;  // Set this to the pixel height of the image.

  
drawoverplayer();
  
dontblock();

  
setTimer.05);
}

function 
onTimeOut()
{
  if (
player.x in |x+ (this.imgwidth/16)|
    && 
player.y in |y+ (this.imgheight/16)|) {
    
setcoloreffect111.4);
  } else 
setcoloreffect1111);
  
setTimer.05);



Works in theory, didnt test it.

xshadx 06-05-2006 03:27 PM

Hm, Cant Seem To Get It To Work.
Does The Img Height,Width go:
this.imgheight = #;HERE
OR
this.imgheight = #HERE;

xXziroXx 06-05-2006 03:29 PM

Uh. Change # to the value of i.e. the imgage height. (Say its a block.png, then change both the imgheight and imgwidth value to 32).

xshadx 06-05-2006 03:32 PM

hm, ok now i understand

xshadx 06-05-2006 03:39 PM

What Im Using Is The Following, Maybe It Doesnt Work Because Im In Editor Mode? Maybe It's Because Im Missing Something.

//#CLIENTSIDE
function onCreated()
{
setImg( "block.png");
this.imgwidth = 32;
this.imgheight = 32;
drawoverplayer();
dontblock();

setTimer( .05);
}

function onTimeOut()
{
if (player.x in |x, x + (this.imgwidth/32)|
&& player.y in |y, y + (this.imgheight/32)|) {
setcoloreffect( 1, 1, 1, .4);
} else setcoloreffect( 1, 1, 1, 1);
setTimer( .05);
}

Gambet 06-05-2006 04:23 PM

Quote:

Originally Posted by xshadx
What Im Using Is The Following, Maybe It Doesnt Work Because Im In Editor Mode? Maybe It's Because Im Missing Something.

Without reading the script I can tell you that it won't work in editor mode. Editor mode does not support GS2, and you're attempting to code in GS2. And also, you should learn to use code tags when posting up code for review.

xshadx 06-05-2006 04:28 PM

Quote:

Originally Posted by Gambet
Without reading the script I can tell you that it won't work in editor mode. Editor mode does not support GS2, and you're attempting to code in GS2. And also, you should learn to use code tags when posting up code for review.


Thanks.

ApothiX 06-05-2006 07:29 PM

you could also do: this.imagewidth = getImgWidth("filename"); (might be able to use this.image instead of filename, but I'm not sure)

xXziroXx 06-05-2006 08:42 PM

Ah, THATS why imgwidth() never worked for me in GS2, its supposed to be getImgWidth()! :D

xshadx 06-05-2006 08:52 PM

Quote:

Originally Posted by xXziroXx
Ah, THATS why imgwidth() never worked for me in GS2, its supposed to be getImgWidth()! :D


^^ Something he doesnt know! :p

xXziroXx 06-05-2006 08:57 PM

Bored, might aswell improve it with getImgWidth/Height:


PHP Code:

//#CLIENTSIDE
function onCreated()
{
  
setImg"imagename");

  
drawoverplayer();
  
dontblock();

  
setTimer.05);
}

function 
onTimeOut()
{
  if (
player.x in |x+ (getImgWidththis.image)/16)|
    && 
player.y in |y+ (getImgHeightthis.image)/16)|) {
    
setcoloreffect111.4);
  } else 
setcoloreffect1111);
  
setTimer.05);



xshadx 06-05-2006 09:00 PM

Thanks, Ziro :o

ApothiX 06-05-2006 10:24 PM

what is up with the space you put between the opening parenthesis and the first parameter? x_x It's really ugly IMO. If you're going to do that, atleast put a space between the last parameter and the closing parenthesis.

Also, I forgot about this before, but because you are setting the image of the NPC you can use the 'this.width' and 'this.height' variables to get the width/height instead of using getImgWidth()/getImgHeight()

xshadx 06-05-2006 10:39 PM

:o

ApothiX 06-06-2006 12:32 AM

Quote:

Originally Posted by xshadx
:o

It works like that because setting the image automatically sets the setshape for it.

ZeLpH_MyStiK 06-06-2006 01:58 AM

Quote:

Originally Posted by xXziroXx
Ah, THATS why imgwidth() never worked for me in GS2, its supposed to be getImgWidth()! :D

Um no? imgwidth() works just as well as getimgwidth().

ApothiX 06-06-2006 05:51 AM

Quote:

Originally Posted by ZeLpH_MyStiK
Um no? imgwidth() works just as well as getimgwidth().

You can't use quotes with imgwidth(), as it's an old-gscript function.
imgwidth(imagename) will work, imgwidth("imgname") won't.

xXziroXx 06-06-2006 05:31 PM

Quote:

Originally Posted by ApothiX
You can't use quotes with imgwidth(), as it's an old-gscript function.
imgwidth(imagename) will work, imgwidth("imgname") won't.

Exactly. And since I hate combining GS1 with GS2, I simply started setting vars instead of the gs1 imgwidth().


All times are GMT +2. The time now is 08:33 AM.

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