Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   setimg/setimgpart? offset (https://forums.graalonline.com/forums/showthread.php?t=72513)

JkWhoSaysNi 02-28-2007 10:38 PM

setimg/setimgpart? offset
 
Is there any way to set where the img starts (in pixels) relative to the NPC? I'd like to use setimgpart() but basically do:

setimgpart("image.png",-10,0,width,height);

to give the image a transparent border on the left of 10px. Is this at all possible? I could do it with showimg, but it doesn't move in pixels unless I set the layer to 5 but with the layer at 5 i can't easily put the image in the correct place relative to the level.


Is this possible?

Thanks.

napo_p2p 02-28-2007 11:23 PM

Quote:

Originally Posted by JkWhoSaysNi (Post 1283169)
I could do it with showimg, but it doesn't move in pixels unless I set the layer to 5 but with the layer at 5 i can't easily put the image in the correct place relative to the level.

Well, you can use the layer of 5 and use:
worldx(screenx, screeny);
worldy(screenx, screeny);

To convert screen coordinates to level coordinates.

Angel_Light 03-01-2007 12:36 AM

Quote:

Originally Posted by napo_p2p (Post 1283179)
Well, you can use the layer of 5 and use:
worldx(screenx, screeny);
worldy(screenx, screeny);

Please explain this :o

Gambet 03-01-2007 12:49 AM

Quote:

Originally Posted by Angel_Light (Post 1283217)
Please explain this :o


Converts things such as mousex and mousey to level coordinates.

napo_p2p 03-01-2007 12:55 AM

Quote:

Originally Posted by Angel_Light (Post 1283217)
Please explain this :o

"Converts screen coordinates to level coordinates"

Each function takes two screen coordinates (an x and a y), then returns the level x or y (depending on the function).

Play around with it....

PHP Code:

//#CLIENTSIDE
function onMouseDown() {
  
player.chat  worldx(mousescreenxmousescreenySPC worldy(mousescreenxmousescreeny);


That would be more or less the same thing as outputting mousex and mousey.

I'm not entirely sure about gmap behavior though, but those can be easily converted too.

Quote:

Originally Posted by Gambet (Post 1283222)
Converts things such as mousex and mousey to level coordinates.

I think mousex and mousey are already in level coordinates...

Gambet 03-01-2007 01:00 AM

Quote:

Originally Posted by napo_p2p (Post 1283227)
I think mousex and mousey are already in level coordinates...


Not sure actually.


How we normally make checks it would appear to be the position in the level, but I double checked and looked at the worldx/worldy descriptions and they stated that mousex was screen position, which ultimately wouldn't make much sense.

The worldx description and the mousex description state that they are two different things x-x

Tolnaftate2004 03-01-2007 02:55 AM

mousex/y is in level coordinates, though it may give different values than worldx/y. mousex/y may only be relative to a flat gmap (I don't think so, but maybe...) whereas worldx/y varies depending on the terrain, and thus the need for both x and y parameters.

Angel_Light 03-01-2007 03:04 AM

ah, I get it, Thanks Napo

Kristi 03-01-2007 10:52 AM

Quote:

Originally Posted by JkWhoSaysNi (Post 1283169)
Is there any way to set where the img starts (in pixels) relative to the NPC? I'd like to use setimgpart() but basically do:

setimgpart("image.png",-10,0,width,height);

to give the image a transparent border on the left of 10px. Is this at all possible? I could do it with showimg, but it doesn't move in pixels unless I set the layer to 5 but with the layer at 5 i can't easily put the image in the correct place relative to the level.


Is this possible?

Thanks.

This thread seems to have derailed a little. layer 3 and lower places the showimg per tile. if you want to move it just a pixel, well its just a little math.
One tile is 16x16 pixels, so if you want to move it a pixel on the level space, you move it by 1/16 tiles, which is equal to one pixel =)

zokemon 03-01-2007 11:06 AM

Quote:

Originally Posted by Kristi (Post 1283321)
This thread seems to have derailed a little. layer 3 and lower places the showimg per tile. if you want to move it just a pixel, well its just a little math.
One tile is 16x16 pixels, so if you want to move it a pixel on the level space, you move it by 1/16 tiles, which is equal to one pixel =)

But then you are changing the real position. He wants to be able to offset the image displayed, not the object displaying it (such as a npc or a TShowImg)

Kristi 03-01-2007 11:11 AM

Quote:

Originally Posted by zokemon (Post 1283324)
But then you are changing the real position. He wants to be able to offset the image displayed, not the object displaying it (such as a npc or a TShowImg)

No, what I started is exactly what he wanted.
" I could do it with showimg, but it doesn't move in pixels unless I set the layer to 5 but with the layer at 5 i can't easily put the image in the correct place relative to the level."
He only looked at the showimgpart as an alternative because he didnt know how to move it by pixel on the level layer (showimgpart allows a pixel manipulation on this layer, so he thought it was the way to go).

Crow 03-01-2007 04:16 PM

Quote:

Originally Posted by Kristi (Post 1283326)
No, what I started is exactly what he wanted.
" I could do it with showimg, but it doesn't move in pixels unless I set the layer to 5 but with the layer at 5 i can't easily put the image in the correct place relative to the level."
He only looked at the showimgpart as an alternative because he didnt know how to move it by pixel on the level layer (showimgpart allows a pixel manipulation on this layer, so he thought it was the way to go).

Wtf, it doesnt? What about something like ->
PHP Code:

showimg 200,blah.png,30 16,30

The x would then be 30 + 1 pixel ;>

JkWhoSaysNi 03-01-2007 06:05 PM

Can things be moved by small amounts like 1px serverside though?

I cant seem to get anything to move that little.

Crow 03-01-2007 06:15 PM

Quote:

Originally Posted by JkWhoSaysNi (Post 1283366)
Can things be moved by small amounts like 1px serverside though?

I cant seem to get anything to move that little.

Should work o.O Not sure though.

JkWhoSaysNi 03-01-2007 06:21 PM

Well it's actually part of an NPC. I'm using setimgpart() to show part of an npc but i need the npc to move slightly.

Kristi 03-01-2007 09:32 PM

Quote:

Originally Posted by JkWhoSaysNi (Post 1283366)
Can things be moved by small amounts like 1px serverside though?

I cant seem to get anything to move that little.

serverside only displays with an accurcy of .5 tiles. why not put the showimg in the clientside anyway...

Crow 03-01-2007 10:14 PM

Maybe display the image with an index below 200 instead of using a serverside script? Well, maybe you are already doing this, not sure.

JkWhoSaysNi 03-01-2007 10:39 PM

Quote:

Originally Posted by Kristi (Post 1283495)
serverside only displays with an accurcy of .5 tiles. why not put the showimg in the clientside anyway...

The NPC is a door which I want everyone in the level to see open/close at the same time.

I guess i'll have to use showimg to do it.

Edit: do serverside showanis have a accuracy of .5 tiles too? I'm doing showanis with indexes < 200 and clientside they look fine but for everyone else they're in the wrong place (rounded to .5 tiles by the looks of it)

Gambet 03-01-2007 10:42 PM

Quote:

Originally Posted by JkWhoSaysNi (Post 1283520)
The NPC is a door which I want everyone in the level to see open/close at the same time.

I guess i'll have to use showimg to do it.


Well, you can always set the img to a blank img on the serverside via setimg().

napo_p2p 03-01-2007 11:47 PM

Quote:

Originally Posted by JkWhoSaysNi (Post 1283520)
The NPC is a door which I want everyone in the level to see open/close at the same time.

I guess i'll have to use showimg to do it.

Edit: do serverside showanis have a accuracy of .5 tiles too? I'm doing showanis with indexes < 200 and clientside they look fine but for everyone else they're in the wrong place (rounded to .5 tiles by the looks of it)

It would be easier to just edit the gani and adjust the positioning of the door in there.

If the gani sprites are positioned correctly, then all you have to do is use setcharprop.

Kristi 03-02-2007 06:33 AM

Quote:

Originally Posted by JkWhoSaysNi (Post 1283520)
The NPC is a door which I want everyone in the level to see open/close at the same time.

I guess i'll have to use showimg to do it.

Edit: do serverside showanis have a accuracy of .5 tiles too? I'm doing showanis with indexes < 200 and clientside they look fine but for everyone else they're in the wrong place (rounded to .5 tiles by the looks of it)

Anis = rounded, although you answered your own question

if its opening, use an ani instead, so the opening animation looks smooth. you shouldnt be looping an npc animation serverside, which im assuming youre trying to do if its pixel by pixel


All times are GMT +2. The time now is 09:10 PM.

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