Graal Forums

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

Emera 08-29-2011 12:03 PM

MouseDown NPC
 
Is there a way to detect if the mouse has been clicked on a certain NPC in the level rather than just detecting if the mouse has been clicked?

Gunderak 08-29-2011 12:10 PM

Theres this.
PHP Code:

function onActionLeftMouse() {
//Do Stuff.


And also this
PHP Code:

function onMousedown(var) {
  if(var == 
"left"){
   if (
mousex in |this.x+.5,this.x+2.5| && mousey in |this.y,this.y+3|) {
   
//Do Stuff.
   
}
 }



Emera 08-29-2011 12:13 PM

Thank you! Was racking my brains so hard. Can't even do the simple stuff sometimes D:

callimuc 08-29-2011 07:58 PM

You can also use this (probably prefered in a timeout):
if (leftmousebutton) {

cbk1994 08-29-2011 11:06 PM

Quote:

Originally Posted by callimuc (Post 1666053)
You can also use this (probably prefered in a timeout):
if (leftmousebutton) {

Don't do this unless you absolutely have to use a timeout for some other reason.

Emera 08-30-2011 10:53 AM

Just so I can understand this and use it myself in future...
PHP Code:

if (mousex in |this.x+.5,this.x+2.5| && mousey in |this.y,this.y+3|) { 

This is detecting if the mouse in inside the specified coordinates yes?

Twinny 08-30-2011 11:30 AM

Quote:

Originally Posted by Emera (Post 1666215)
Just so I can understand this and use it myself in future...
PHP Code:

if (mousex in |this.x+.5,this.x+2.5| && mousey in |this.y,this.y+3|) { 

This is detecting if the mouse in inside the specified coordinates yes?

Yes, it is.

|start, end| defines a range between the two given values.

So,

PHP Code:

function onCreated() {
  
temp.test 3;
  if (
temp.test in |1,5|) {
    
printf("%i is in the range"temp.test);
  }


Since 3 is between 1 and 5, the condition statement will evaluate to true.

Gunderak 08-30-2011 01:09 PM

may i ask how you actually get them lines? i usually get them off character map, is there some kind of alt + numpad key combination?

Crow 08-30-2011 01:13 PM

Quote:

Originally Posted by Gunderak (Post 1666232)
may i ask how you actually get them lines? i usually get them off character map, is there some kind of alt + numpad key combination?

It's called a pipe. Seems to be directly above the return key on English layouts.

http://ascii-table.com/img/keyboard-103P.png

Gunderak 08-30-2011 01:21 PM

My keyboard doesnt have that one it O.O even pressing shift + that does nothing..
time for a new keyboard?
Lol i still have one of them old keyboards that are whote/crewmy coloured plastic and the keys are really loud. its deffinetly time for a new one.
thanks crow.

callimuc 08-30-2011 06:06 PM

Does it even shop up on your key board?

fowlplay4 08-30-2011 06:16 PM

The pipe key can also be located next to the backspace key, and can appear to be two vertical lines instead of one solid line. It's also on the same key as the backslash \.

http://support.free-conversant.com/4...e/pipeKey2.jpg

I find it hard to believe your keyboard doesn't have it.

Emera 08-30-2011 06:21 PM

It is located to the lower left of my keyboard, next the the shift key and is like a pipe but with a space in the middle.

Gunderak 09-02-2011 04:26 PM

AHHH mine has it as the broken line.
i didnt know that key does that line.
when i was looking i was only looking for a straight line.
thanks fowlplay :D

ff7chocoboknight 09-02-2011 04:40 PM

You can use curly brackets for in, also.

Mark Sir Link 09-03-2011 12:38 AM

Quote:

Originally Posted by ff7chocoboknight (Post 1666737)
You can use curly brackets for in, also.

you'd need to construct the entire array if you were to do that.

http://en.wikipedia.org/wiki/List_comprehensions

at least I assume Graal is using some sort of implementation of List Comprehension where

|30, 40| is returning the set of all numbers where x is an item in the set of real numbers, for which x is greater or equal to 30 and less than or equal to 40

Crow 09-03-2011 12:48 AM

Quote:

Originally Posted by ff7chocoboknight (Post 1666737)
You can use curly brackets for in, also.

Curly Brace!

ff7chocoboknight 09-03-2011 02:00 AM

Quote:

Originally Posted by Mark Sir Link (Post 1666803)
you'd need to construct the entire array if you were to do that.

http://en.wikipedia.org/wiki/List_comprehensions

at least I assume Graal is using some sort of implementation of List Comprehension where

|30, 40| is returning the set of all numbers where x is an item in the set of real numbers, for which x is greater or equal to 30 and less than or equal to 40

if (a >= b && a <= c) would be the same as in |b,c| I assume.

Also, I didn't mean that the brackets act the same as |a,b|. I didn't go into any detain; sorry if there was any confusion.

Quote:

Originally Posted by crow (Post 1666804)
curly brace!

:p

fowlplay4 09-03-2011 02:32 AM

I noticed this in a script the other day:

10 in |0,10> echos 0
10 in |0,10| echos 1
0 in <0,10| echos 0
1 in <0,10> echos 1

So you're not limited to using | between two values but can use < and > to do just less than or greater than.

ff7chocoboknight 09-03-2011 02:52 AM

Yeah I was playing with them, too.

<6,9> includes just values between them, so 7 and 8.
|6,9> is 6, 7, and 8.
<6,9| is 7, 8, and 9.
|6,9| is 6, 7, 8, and 9.

I don't see why you'd ever need to mix them though.


All times are GMT +2. The time now is 06:51 AM.

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