Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   dynamic setshape2? (https://forums.graalonline.com/forums/showthread.php?t=53186)

Andy0687 06-16-2004 09:13 AM

dynamic setshape2?
 
Ok so i dont really know if this is possibile or not yet, i know what im trying to do, and ive done it every way i can really think of.

What i was trying to do was use imgwidth and imgheight to get the first two numbers for setshape2 then based on that, turn it into the correct tiletype.

So here is what i did

NPC Code:

this.length = imglength(chair1.png);
this.width = imgwidth(chair1.png);



from that i get i think 5 for length and 3 for width, anyways

then I got here, and its where i have my question
NPC Code:

setshape2 this.length,this.width,{tiletypes};



now i guess what im wondering is if its possibile to set the tiletypes based on the length and width of an image, Say i had two diffrent chairs, but one is larger then the other. Mabye there is something i have overlooked, or this just isnt possibile yet. (or at all ever? :( )

VeX_RaT_Boy 06-16-2004 02:45 PM

Quote:

Originally Posted by Andy0687
Ok so i dont really know if this is possibile or not yet, i know what im trying to do, and ive done it every way i can really think of.

What i was trying to do was use imgwidth and imgheight to get the first two numbers for setshape2 then based on that, turn it into the correct tiletype.

So here is what i did

NPC Code:

this.length = imglength(chair1.png);
this.width = imgwidth(chair1.png);



from that i get i think 5 for length and 3 for width, anyways

then I got here, and its where i have my question
NPC Code:

setshape2 this.length,this.width,{tiletypes};



now i guess what im wondering is if its possibile to set the tiletypes based on the length and width of an image, Say i had two diffrent chairs, but one is larger then the other. Mabye there is something i have overlooked, or this just isnt possibile yet. (or at all ever? :( )

imgwidth and imglenght will return the size in pixels, so Î guess you should do this for the size in tiles:
NPC Code:

setshape2 int(this.length/16),int(this.widht/16),{tiletypes};


Dach 06-16-2004 05:53 PM

dunno if you can pass arrays to the command, but try creating an array with the tiletypes;
array = {22,22,22,0,22,0};
or so (probably need to use a for loop) and pass it like so
setshape2 int(this.length/16),int(this.width/16),array;

works on showpoly, well I think it does... my script that uses that doesn't work for everyone for some reason...

Duwul 06-16-2004 07:26 PM

I'm pretty sure you can use arrays for setshape2. I've seen it done before.

Goboom 06-16-2004 09:47 PM

I used arrays a while ago with setshape, it worked from time to time but not all the time, never understood why. This is SOOOOOO a Kai answer that you need.

Andy0687 06-17-2004 02:45 AM

its not so much getting the array i need, its passing the array into it.

ive tried for loops and stuff, but i guess im just pretty bad with setting it up

like for example i decided mabye i could pass it as an index of a string, but that showed no results either.

Goboom 06-17-2004 03:29 AM

NPC Code:
this.width = int(width);
this.height = int(height);
setarray this.array,this.width * this.height;
for (i=0;i < this.width;i++) {
for (j=0;j < this.height;j++) {
this.array[i+j*this.width] = 3;
}
}
setshape2 this.width,this.height,this.array;


Try that.

VeX_RaT_Boy 06-17-2004 10:15 AM

....that would still turn out in pixels, and setshape2 uses tiles.

calum 06-17-2004 10:04 PM

Shouldn't it be...
NPC Code:

this.height = imgheight(chair1.png);
this.width = imgwidth(chair1.png);


Dach 06-20-2004 07:55 PM

Quote:

Originally Posted by calum
Shouldn't it be...
NPC Code:

this.height = imgheight(chair1.png);
this.width = imgwidth(chair1.png);


width and height are npc variables that return the pixel size of the npc (that has a size, of course), there isn't anything left to explain, save for just giving you a script (which Goboom practically did :\ )


All times are GMT +2. The time now is 02:56 AM.

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