Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   mouseX ad mouseY help (https://forums.graalonline.com/forums/showthread.php?t=36618)

Spark910 08-25-2002 08:33 PM

mouseX and mouseY help
 
If i had a 16x16Pixle image (1 Graal tile square) NPC that size too loacated at X=32 and Y=32 how would I make it so that if it was ANYWHERE on the NPC it would:

message test;

I want it to cover the whole NPC which I dont know how to do anyone know how to make it see if the mouse is ANYWHERE on the NPC thats 16x16pixles?

Thanks in advanced to those who may help, If i dont get a chance to thank you later.

Dragona2002 08-25-2002 09:21 PM

if (mousex==32&&mousey==32) {
message test;
}else {
message ;
}

Spark910 08-25-2002 10:37 PM

That didnt work!? =( :(

Spark910 08-25-2002 10:45 PM

hah! Look i did it by my self (Thats good for me!)

NPC Code:

// NPC made by Spark911
if (playerenters) {
timeout=.05;
}
if (timeout) {
if (mousex=>32&&mousex=<33&&mousey=>32&&mousey=<33) {
message test;
timeout=.05;
}

else {
message ;
}
timeout=.05;
}


emortylone 08-25-2002 11:14 PM

Since people want to speak ill'y of peoples coding styles, THIS was horrible x.X
NPC Code:

if (created){
timeout=0.25;
}

if (timeout)
{ for (i=0;i<playerscount;i++)
{ if (abs(mousex-x)=<1 && abs(mousey-y)=<1)
{message test;}
else message ;
}
timeout=0.25;
}


Original code by Shifter XP. And unlike yours, which will ONLY do it if it is at that certain X and Y, mine will do it regardless of where really. 0.05 timeout... he he, I really don't use it anymore. 0.1 laggs a bit w/ an NPC Server, but 0.25 still does it enough times a second where it makes no differece :)
---Shifter

CheeToS2 08-25-2002 11:37 PM

.. you could have used testnpc too
something like:
NPC Code:

if (created||timeout){
if (testnpc(mousex,mousey)<=0){
with (npcs[testnpc(mousex,mousey)]){
message test;
}
}
timeout=.05;
}


or you could use == instead if you want it to relate to the npc with that index

Spark910 08-25-2002 11:45 PM

Quote:

Originally posted by emortylone
Since people want to speak ill'y of peoples coding styles, THIS was horrible x.X
NPC Code:

if (created){
timeout=0.25;
}

if (timeout)
{ for (i=0;i<playerscount;i++)
{ if (abs(mousex-x)=<1 && abs(mousey-y)=<1)
{message test;}
else message ;
}
timeout=0.25;
}


Original code by Shifter XP. And unlike yours, which will ONLY do it if it is at that certain X and Y, mine will do it regardless of where really. 0.05 timeout... he he, I really don't use it anymore. 0.1 laggs a bit w/ an NPC Server, but 0.25 still does it enough times a second where it makes no differece :)
---Shifter

:megaeek:

Im only learning, I dont understand ''For'' nor do I undestand ''i=0'' nor do I understand ''abs''! =(

Dragona2002 08-26-2002 03:04 AM

mathematical i cant do that 2 X.x
i hate that
i also cant use test things and that sux :(
can some1 explain us our just meh ? :)

emortylone 08-26-2002 08:25 AM

omg! Here is a QUICK explanation of the for command
for consists of THREE parts:
i=0; is generally the first. i is a variable, it can be about any letter. 0 is set to the starting point. you could do i=100 and 100 would be the starting point.
2nd Part) i<allplayerscount; is a generally used one. it says that it will continue if i<allplayerscount
3rd Part) i ++ it means that if the 2nd part is still true, it makes i go up one. I is basically a variable. so here is an example:
NPC Code:

for (i=1;i<playerscount;i++)
{ players[i].x=30;
players[i].y=30;
}


it starts at i=1 (0 is the current player, so it does it for EVERYONE but the current player)
then it will add 1 to i until i equals the playerscount (playerscount = players in THAT level, allplayers is the entire server)
so then it would set every player except the one who started the reaction, to 30 30.
---Shifter

emortylone 08-26-2002 09:27 AM

LOL, Kai, true, for is not a COMMAND. It is a technicality =P But regardless, I know how to use it XD
---Shifter

screen_name 08-27-2002 08:48 AM

RAWR, don't make it so complex X.x

NPC Code:

if (created || timeout) {
message ;
if (mousex in |32,3.9999| && mousey in |32,32.9999|) {
message test;
}
timeout = .05;
}


emortylone 08-27-2002 10:59 PM

x.X You don't get it at ALL do you screen_name? That is a HORIBLE way to do it x.X You are again, SPECIFYING the location of it, the way I did it was:
1) In NO way complex, simple for command x.X if you think that is complex, you'd have a heartache seeing some of my scripts =P
2) If you have your mouse in location to the NPC, rather than in location of the level, which works MUCH better, and you can move the NPC around w/o recoding.
Kai: Yes, I know how to use it ;) Technicalities matter little, if you can use it properly and not get errors is what counts :)
I have a feeling Kai would agree more w/ my explanation of how to do this
---Shifter

screen_name 08-28-2002 02:10 AM

Quote:

Originally posted by emortylone
x.X You don't get it at ALL do you screen_name? That is a HORIBLE way to do it x.X You are again, SPECIFYING the location of it, the way I did it was:
1) In NO way complex, simple for command x.X if you think that is complex, you'd have a heartache seeing some of my scripts =P
2) If you have your mouse in location to the NPC, rather than in location of the level, which works MUCH better, and you can move the NPC around w/o recoding.
Kai: Yes, I know how to use it ;) Technicalities matter little, if you can use it properly and not get errors is what counts :)
I have a feeling Kai would agree more w/ my explanation of how to do this
---Shifter

I do believe spark said that it was at 32,32

in either case, just change the first 32's in my script to x and the second set of 32's to y

Spark910 08-28-2002 02:32 AM

I understand screen_names more then ''abs'' but sort of understand ''abs'' so thanks to all of you. And no need to argue about it please, I only needed help not World war 3

HoudiniMan 08-29-2002 11:00 AM

abs() = absolute value of whats in the ()
they never really answered you so i did :D
I learnt that from mah calculator coding o.O


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

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