Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-29-2011, 12:03 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
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?
__________________
Reply With Quote
  #2  
Old 08-29-2011, 12:10 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
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.
   
}
 }

__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #3  
Old 08-29-2011, 12:13 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Thank you! Was racking my brains so hard. Can't even do the simple stuff sometimes D:
__________________
Reply With Quote
  #4  
Old 08-29-2011, 07:58 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
You can also use this (probably prefered in a timeout):
if (leftmousebutton) {
__________________
MEEP!
Reply With Quote
  #5  
Old 08-29-2011, 11:06 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by callimuc View Post
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.
__________________
Reply With Quote
  #6  
Old 08-30-2011, 10:53 AM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
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?
__________________
Reply With Quote
  #7  
Old 08-30-2011, 11:30 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by Emera View Post
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.
Reply With Quote
  #8  
Old 08-30-2011, 01:09 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
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?
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #9  
Old 08-30-2011, 01:13 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by Gunderak View Post
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.

Reply With Quote
  #10  
Old 08-30-2011, 01:21 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
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.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #11  
Old 08-30-2011, 06:06 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Does it even shop up on your key board?
__________________
MEEP!
Reply With Quote
  #12  
Old 08-30-2011, 06:16 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
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 \.



I find it hard to believe your keyboard doesn't have it.
__________________
Quote:
Reply With Quote
  #13  
Old 08-30-2011, 06:21 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
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.
__________________
Reply With Quote
  #14  
Old 09-02-2011, 04:26 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
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
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #15  
Old 09-02-2011, 04:40 PM
ff7chocoboknight ff7chocoboknight is offline
Skyzer Zolderon
ff7chocoboknight's Avatar
Join Date: Dec 2006
Location: New Hampshire, United States
Posts: 725
ff7chocoboknight is a name known to allff7chocoboknight is a name known to allff7chocoboknight is a name known to allff7chocoboknight is a name known to all
Send a message via AIM to ff7chocoboknight Send a message via MSN to ff7chocoboknight
You can use curly brackets for in, also.
__________________
Reply With Quote
  #16  
Old 09-03-2011, 12:38 AM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
Quote:
Originally Posted by ff7chocoboknight View Post
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

Last edited by Mark Sir Link; 09-03-2011 at 12:52 AM..
Reply With Quote
  #17  
Old 09-03-2011, 12:48 AM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by ff7chocoboknight View Post
You can use curly brackets for in, also.
Curly Brace!
Reply With Quote
  #18  
Old 09-03-2011, 02:00 AM
ff7chocoboknight ff7chocoboknight is offline
Skyzer Zolderon
ff7chocoboknight's Avatar
Join Date: Dec 2006
Location: New Hampshire, United States
Posts: 725
ff7chocoboknight is a name known to allff7chocoboknight is a name known to allff7chocoboknight is a name known to allff7chocoboknight is a name known to all
Send a message via AIM to ff7chocoboknight Send a message via MSN to ff7chocoboknight
Quote:
Originally Posted by Mark Sir Link View Post
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 View Post
curly brace!
__________________
Reply With Quote
  #19  
Old 09-03-2011, 02:32 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
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.
__________________
Quote:
Reply With Quote
  #20  
Old 09-03-2011, 02:52 AM
ff7chocoboknight ff7chocoboknight is offline
Skyzer Zolderon
ff7chocoboknight's Avatar
Join Date: Dec 2006
Location: New Hampshire, United States
Posts: 725
ff7chocoboknight is a name known to allff7chocoboknight is a name known to allff7chocoboknight is a name known to allff7chocoboknight is a name known to all
Send a message via AIM to ff7chocoboknight Send a message via MSN to ff7chocoboknight
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.
__________________
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 12:25 PM.


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