Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Future Improvements (https://forums.graalonline.com/forums/forumdisplay.php?f=10)
-   -   onImage(filename,x,y) (https://forums.graalonline.com/forums/showthread.php?t=42162)

Kaimetsu 01-22-2003 04:03 AM

onImage(filename,x,y)
 
Returns true if the point you specified is on the image and false if it falls on one of the transparent regions. I guess there are multiple this could be implemented:

1) The coordinates are given relative to the top-left corner of the image so the image doesn't need to be shown to be checked.
2) Instead of 'filename', the function takes image index (as used in showimg) and subsequently interprets the x and y as level or screen coordinates (depending on the draw layer of the given image).

Good for inventory systems - I can check if the player clicked on the apple rather than just checking against its bounding box. It opens up a few possibilities (systems like Ultima's, for example) and refines others. Let me know if the description wasn't clear enough.

tlf288 01-22-2003 04:09 AM

I like the idea. I could see it being very usefull.

Maybe even something that returns the ID or filename of the image the mouse is on would be even better?

Kaimetsu 01-22-2003 05:04 AM

Quote:

Originally posted by tlf288
I like the idea. I could see it being very usefull.

Maybe even something that returns the ID or filename of the image the mouse is on would be even better?

Easier to use, but not necessarily as flexible. Plus image index doesn't always directly correlate to object indices.

G_yoshi 01-22-2003 05:22 AM

Re: onImage(filename,x,y)
 
Quote:

Originally posted by Kaimetsu
Returns true if the point you specified is on the image and false if it falls on one of the transparent regions. I guess there are multiple this could be implemented:

1) The coordinates are given relative to the top-left corner of the image so the image doesn't need to be shown to be checked.
2) Instead of 'filename', the function takes image index (as used in showimg) and subsequently interprets the x and y as level or screen coordinates (depending on the draw layer of the given image).

Good for inventory systems - I can check if the player clicked on the apple rather than just checking against its bounding box. It opens up a few possibilities (systems like Ultima's, for example) and refines others. Let me know if the description wasn't clear enough.

I'm all for it. Better than doing if (mousex in |a,b|....) {}. Thats kind of how triggeraction works if I'm not mistaken (your proposed idea)?

Butz 01-22-2003 05:28 AM

It could be used for collision detection for other things too.

Kaimetsu 01-22-2003 05:48 AM

Re: Re: onImage(filename,x,y)
 
Quote:

Originally posted by G_yoshi


I'm all for it. Better than doing if (mousex in |a,b|....) {}. Thats kind of how triggeraction works if I'm not mistaken

I think triggeraction works that way, yeah. So I'm sure there must be code in the engine that already does something like this - it just needs to be tied to a script command.

CheeToS2 01-22-2003 01:18 PM

good idea, making ranges is a pain -_-

tlf288 01-22-2003 10:23 PM

Quote:

Originally posted by CheeToS2
making ranges is a pain
Pain isn't even the half of it. It is horrible finding the x\y the whole thing takes up. This is a great suggestion and should be implemented without a doubt.

tlf288 01-24-2003 05:58 AM

I was thinking while in the shower....

Wouldn't testimg(x,y) be not only more constant to the graal scripting language, but more practical? It would return the index of the image located at the given x and y position and you could test if it was true.

edit: Sorry for double post :\

Kaimetsu 01-24-2003 06:09 AM

Quote:

Originally posted by tlf288
Wouldn't testimg(x,y) be not only more constant to the graal scripting language, but more practical? It would return the index of the image located at the given x and y position and you could test if it was true.
More consistent, yes, but certainly not more practical. It would limit what we could do. What if we want to check this stuff before drawing the image? Maybe the intended position of the image depends on the result of the function. What if we have overlapping images? We don't want the front ones to mask out the back. Things like that, y'know? It just makes the function too high-level, and obliterates some of its functionality.

Admins 01-24-2003 06:11 AM

Both testimg and isonimg would be good I think. The function isonimg would be more efficient if you want to only check a few things and don't want to care about overlapping images.
The functions testimg, testnpc etc. should be changed to give the index of the first object found, and also fill an array with the indexes of all objects found on the given position, sorted by the drawing order.
(since the variables can be normal variables and arrays at the same time it might be useful, and it would be compatible with old scripts).

Python523 01-24-2003 06:26 AM

Quote:

Originally posted by Stefan
Both testimg and isonimg would be good I think. The function isonimg would be more efficient if you want to only check a few things and don't want to care about overlapping images.
The functions testimg, testnpc etc. should be changed to give the index of the first object found, and also fill an array with the indexes of all objects found on the given position, sorted by the drawing order.
(since the variables can be normal variables and arrays at the same time it might be useful, and it would be compatible with old scripts).

sounds great :) I think i suggested making an array of all found indexes awhile ago, I'm glad to see it might be added

tlf288 02-03-2003 06:05 AM

Stefan: I was wondering if you are going to implement this feature anytime soon. If you are I will wait to do this project I am ready to start on that with these new functions would make it a lot easier.


All times are GMT +2. The time now is 10:35 AM.

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