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 06-05-2006, 03:14 PM
xshadx xshadx is offline
Development Staff
xshadx's Avatar
Join Date: May 2006
Posts: 161
xshadx is on a distinguished road
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 =)
__________________

Reply With Quote
  #2  
Old 06-05-2006, 03:19 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
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
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
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.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #3  
Old 06-05-2006, 03:27 PM
xshadx xshadx is offline
Development Staff
xshadx's Avatar
Join Date: May 2006
Posts: 161
xshadx is on a distinguished road
Hm, Cant Seem To Get It To Work.
Does The Img Height,Width go:
this.imgheight = #;HERE
OR
this.imgheight = #HERE;
__________________

Reply With Quote
  #4  
Old 06-05-2006, 03:29 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
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
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
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).
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #5  
Old 06-05-2006, 03:32 PM
xshadx xshadx is offline
Development Staff
xshadx's Avatar
Join Date: May 2006
Posts: 161
xshadx is on a distinguished road
hm, ok now i understand
__________________

Reply With Quote
  #6  
Old 06-05-2006, 03:39 PM
xshadx xshadx is offline
Development Staff
xshadx's Avatar
Join Date: May 2006
Posts: 161
xshadx is on a distinguished road
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);
}
__________________

Reply With Quote
  #7  
Old 06-05-2006, 04:23 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
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.
Reply With Quote
  #8  
Old 06-05-2006, 04:28 PM
xshadx xshadx is offline
Development Staff
xshadx's Avatar
Join Date: May 2006
Posts: 161
xshadx is on a distinguished road
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.
__________________

Reply With Quote
  #9  
Old 06-05-2006, 07:29 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
you could also do: this.imagewidth = getImgWidth("filename"); (might be able to use this.image instead of filename, but I'm not sure)
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #10  
Old 06-05-2006, 08:42 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
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
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Ah, THATS why imgwidth() never worked for me in GS2, its supposed to be getImgWidth()!
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #11  
Old 06-05-2006, 08:52 PM
xshadx xshadx is offline
Development Staff
xshadx's Avatar
Join Date: May 2006
Posts: 161
xshadx is on a distinguished road
Quote:
Originally Posted by xXziroXx
Ah, THATS why imgwidth() never worked for me in GS2, its supposed to be getImgWidth()!

Something he doesnt know!
__________________

Reply With Quote
  #12  
Old 06-05-2006, 08:57 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
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
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
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);

__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #13  
Old 06-05-2006, 09:00 PM
xshadx xshadx is offline
Development Staff
xshadx's Avatar
Join Date: May 2006
Posts: 161
xshadx is on a distinguished road
Thanks, Ziro :o
__________________

Reply With Quote
  #14  
Old 06-05-2006, 10:24 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
what is up with the space you put between the opening parenthesis and the first parameter? 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()
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #15  
Old 06-05-2006, 10:39 PM
xshadx xshadx is offline
Development Staff
xshadx's Avatar
Join Date: May 2006
Posts: 161
xshadx is on a distinguished road
:o
__________________

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 08:12 AM.


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