Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   worldx() and worldy() - pretty slow? (https://forums.graalonline.com/forums/showthread.php?t=79049)

Crow 03-16-2008 05:50 PM

worldx() and worldy() - pretty slow?
 
The conversion from screen coordinates to woorld coordinates via worldx() and worldy() seem to happen pretty slow. For example, when I'm showing an image on the tile layer, but its supposed to look like its on the screen layer, it would lag behind if I move. This is not the case btw.
Though, it would be useful if there was some other way that wouldnt be so damn slow and laggy. To be certain, I actually need something that returns the level x and y at the edges of your screen. Any ideas?

DustyPorViva 03-16-2008 06:05 PM

Ya, it definitely lags behind... making doing things like GUI's and such a pain... since they lag behind the player.

Crow 03-16-2008 06:08 PM

Quote:

Originally Posted by DustyPorViva (Post 1379998)
Ya, it definitely lags behind... making doing things like GUI's and such a pain... since they lag behind the player.

If that was saracastic, I guess you didnt get my point D: The main focus is the end of my post.

DustyPorViva 03-16-2008 06:10 PM

I don't fully read stuff... so you want a substitute formula or something for it?

Crow 03-16-2008 06:38 PM

Yea. Currently I'm using worldx(GraalControl.width, 0) to get the level x of the right window border of the client window, for example. But I need another way, because worldx() lags.

Tolnaftate2004 03-16-2008 08:46 PM

tx = mousex + (screenwidth-mousescreenx)/16
ty = mousey + (screenheight-mousescreeny)/16

I did not test this extensively, but it seems to me that it would work at least while the mouse is in the client window.

zokemon 03-16-2008 09:34 PM

worldx lags? Are you sure you aren't just implementing it wrong?

DustyPorViva 03-16-2008 09:41 PM

It doesn't 'lag' per say... but it doesn't update smoothly.

Crow 03-16-2008 10:09 PM

Quote:

Originally Posted by Tolnaftate2004 (Post 1380041)
tx = mousex + (screenwidth-mousescreenx)/16
ty = mousey + (screenheight-mousescreeny)/16

I did not test this extensively, but it seems to me that it would work at least while the mouse is in the client window.

I tested it. It still lags behind, but its not as bad as worldx() and worldy().
Though, since it still lags behind...I think I'm doing something wrong.

DustyPorViva 03-16-2008 10:16 PM

If this is in a custom movement script, try moving it before the change of the player's coordinates(or after... I forget), and it should make a big difference.

Crow 03-16-2008 10:21 PM

I guess its close. Its somewhat related to the player, maybe thats the reason. Though I cant place it inside the movement, its a gani script.

Edit: Actually, I guess I should have told you what I need this for exactly. I wonder why I didnt, should make things easier. I'm trying to mimic the behavior of the default nicks to not leave the Graal window if the player is still visible, so you will even see it if you are at the level edge or somebody is at the edge of your Graal window.

Edit2: What I got also works perfectly clientside, just other players see it lagging behind a bit if what I'm trying to mimic (see above) is "happening" or however you want to call that.

cbk1994 03-16-2008 11:08 PM

Quote:

Originally Posted by Crow (Post 1380071)
What I got also works perfectly clientside, just other players see it lagging behind a bit if what I'm trying to mimic (see above) is "happening" or however you want to call that.

Yes, I've always had this problem.

zokemon 03-17-2008 06:24 AM

I find gani scripts to buggy for nick/chat display. I just use a for (temp.p : players) loop that does a showimg for each player (on the level of course). The function for this I always call from my Movement script's onTimeout so I don't have to worry about that lag issue.

Crow 03-17-2008 04:07 PM

Quote:

Originally Posted by zokemon (Post 1380285)
I find gani scripts to buggy for nick/chat display. I just use a for (temp.p : players) loop that does a showimg for each player (on the level of course). The function for this I always call from my Movement script's onTimeout so I don't have to worry about that lag issue.

Hm. Well, might try that later.

Langford 04-14-2008 08:16 AM

What about if you use the player's x, y, and screenwidth to determine the x and y of the bounds of the current 'viewport'

ie. player's coords are (30,30), screenwidth is 1024, 30*16=480, the left bound should be playerx - 480 (give or take 16), and + 480 (or so) for the right hand bound. This could be locally run in a loop i think, though I am new to this language so I am not sure of it's loop/speed capabilities yet.

idk.. just an idea, hope you caught what I mean :)

Crow 04-14-2008 11:16 AM

I thought about using screenwidth and screenheight, but this wouldnt work when the player is near the level border and not centered anymore.

xXziroXx 04-14-2008 03:41 PM

Or on a gmap.

Admins 04-14-2008 06:46 PM

The screen is moved depending on the player, so it's natural that worldx/y are not same as at the end of the frame depending on in which gani script you are retrieving them. For stuff like nicknames (things displayed for all players) it can actually be faster to use a weapon script and cycle through the player list and display it manually, instead of running a separate gani script for all the players.

Crow 04-14-2008 07:22 PM

Quote:

Originally Posted by Stefan (Post 1385971)
The screen is moved depending on the player, so it's natural that worldx/y are not same as at the end of the frame depending on in which gani script you are retrieving them. For stuff like nicknames (things displayed for all players) it can actually be faster to use a weapon script and cycle through the player list and display it manually, instead of running a separate gani script for all the players.

Tried, images lag behind. Read forums, added after the lines where the player.x and player.y are updated. Logically doesnt update when the movement isnt used to move the player. Recommend something else D:


All times are GMT +2. The time now is 07:55 PM.

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