Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-07-2007, 02:24 AM
PrinceOfKenshin PrinceOfKenshin is offline
That guy with a beard
PrinceOfKenshin's Avatar
Join Date: May 2004
Location: Ontario, Canada
Posts: 819
PrinceOfKenshin has a spectacular aura aboutPrinceOfKenshin has a spectacular aura about
function onMousedown problem

Ok so i have two npcs in a level and they both have

PHP Code:
function onMousedown(mode)
{
  if (
mode == "double")
{
 
triggeraction(0,0,"serverside","System/Main","genderset","male");
}

The only difference between the two is instead of "male" it's "female" in the other npc.

My problem is when i click on the male i get set as the female. And i don't want to have to keep it the way i have it now where you right click for male and left click for female.
__________________


Quote:
Game Master (Server): Greetings PrinceOfKenshin, there are new posts on the forums that demand your urgent attention! God speed, the fate of the world is in your hands. If you fail, middle earth will forever be in the darkness and your children will be enslaved by McKain.
Reply With Quote
  #2  
Old 09-07-2007, 03:03 AM
Googi Googi is offline
A Serious Epidemic
Googi's Avatar
Join Date: Oct 2001
Location: Canada
Posts: 18,866
Googi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud of
Send a message via AIM to Googi
Quote:
Originally Posted by PrinceOfKenshin View Post
My problem is when i click on the male i get set as the female.
Sounds like it could be a problem with the script or part of the script that's being triggered.
__________________
Reply With Quote
  #3  
Old 09-07-2007, 03:23 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Can't trigger weapons from level NPC's.
Reply With Quote
  #4  
Old 09-07-2007, 03:26 AM
PrinceOfKenshin PrinceOfKenshin is offline
That guy with a beard
PrinceOfKenshin's Avatar
Join Date: May 2004
Location: Ontario, Canada
Posts: 819
PrinceOfKenshin has a spectacular aura aboutPrinceOfKenshin has a spectacular aura about
Quote:
Originally Posted by DustyPorViva View Post
Can't trigger weapons from level NPC's.
Soo i should make a class?
__________________


Quote:
Game Master (Server): Greetings PrinceOfKenshin, there are new posts on the forums that demand your urgent attention! God speed, the fate of the world is in your hands. If you fail, middle earth will forever be in the darkness and your children will be enslaved by McKain.
Reply With Quote
  #5  
Old 09-07-2007, 03:33 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Quote:
Originally Posted by DustyPorViva View Post
Can't trigger weapons from level NPC's.
Yes you can.

Quote:
Originally Posted by PrinceOfKenshin View Post
Soo i should make a class?
CLASSES ARE NOT OBJECTS!

I think your problem is that you don't have any x,y conditions. Maybe you are thinking of onActionMouseDown() or whatever? I only think that works serverside or so though, forgot (haven't been doing level npc scripting much in the past 6 months).
__________________
Do it with a DON!
Reply With Quote
  #6  
Old 09-07-2007, 03:34 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
They can't either, as far as I know.
I honestly have no idea how to tackle this. Maybe some of the more savvy clientside/serverside scripters will have some advice.

EDIT: I've never been able to triggerserver/clientside from an NPC, at least from putnpc's, maybe you can with NPC's in levels. *shrug*
Reply With Quote
  #7  
Old 09-07-2007, 03:34 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
onActionMouseDown() will work on any level object that has a shape. You'll need setshape on both sides to get it to work clientside and serverside.

Edit: onMouseDown() is detecting of the mouse button is pressed at all, you'll need to check where the mouse actually is yourself. Would probably be better to set a shape and use the action event instead.

Edit2: Btw, I believe its actually onActionLeftMouse() and onActionRightMouse()

PHP Code:
// This is an NPC in a level.
function onCreated() {
  
setShape(13232);
}
function 
onActionLeftMouse() {
  echo(
"You have clicked on the serverside.");
}
//#CLIENTSIDE
function onCreated() {
  
setShape(13232);
}
function 
onActionLeftMouse() {
  echo(
"You have clicked on the clientside.");

Theres also:
PHP Code:
//#CLIENTSIDE
function onMouseDown(mode) {
  if (
mousex in |xx+2| && mousey in |yy+2|) {
    if (
mode == "left") {
      
// You left clicked it
    
}
    else if (
mode == "right") {
      
// you right clicked it.
    
}
  }

You would also want to check if the GraalControl is the GUI thats focused.
__________________
Reply With Quote
  #8  
Old 09-07-2007, 03:41 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
function onActionleftmouse() {}
Reply With Quote
  #9  
Old 09-07-2007, 03:45 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by DustyPorViva View Post
function onActionleftmouse() {}
Indeed, this is basically what Graal is doing automatically for you:
PHP Code:
//#CLIENTSIDE
function onMouseDown(mode) {
  if (
mode == "left") {
    
triggerAction(mousexmousey"LeftMouse"null);
  }
  else if (
mode == "right") {
    
triggerAction(mousexmousey"RightMouse"null); 
  }

__________________
Reply With Quote
  #10  
Old 09-07-2007, 04:50 AM
Googi Googi is offline
A Serious Epidemic
Googi's Avatar
Join Date: Oct 2001
Location: Canada
Posts: 18,866
Googi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud of
Send a message via AIM to Googi
Quote:
Originally Posted by PrinceOfKenshin View Post
Soo i should make a class?
No. First, try disabling or deleting the female-setting NPC to see whether or not the problem is that both are executing. Also, post the code that's being triggered.
__________________
Reply With Quote
  #11  
Old 09-07-2007, 05:16 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Googi View Post
No. First, try disabling or deleting the female-setting NPC to see whether or not the problem is that both are executing. Also, post the code that's being triggered.
His problem is that hes executing code when onMouseDown() is triggered without actually checking where the mouse is clicking, so both NPCs run when the mouse is clicked anywhere rather than checking if the mouse clicked on them.

onMouseDown() is called on all objects on the clientside whenever the mouse button is clicked regardless of where.
__________________
Reply With Quote
  #12  
Old 09-07-2007, 05:30 AM
Googi Googi is offline
A Serious Epidemic
Googi's Avatar
Join Date: Oct 2001
Location: Canada
Posts: 18,866
Googi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud of
Send a message via AIM to Googi
Quote:
Originally Posted by Inverness View Post
onMouseDown() is called on all objects on the clientside whenever the mouse button is clicked regardless of where.
I've never seen a script with mousex/mousey conditions following the onMouseDown event, so I assumed this wasn't the case, but indeed it is.
__________________
Reply With Quote
  #13  
Old 09-07-2007, 05:30 AM
PrinceOfKenshin PrinceOfKenshin is offline
That guy with a beard
PrinceOfKenshin's Avatar
Join Date: May 2004
Location: Ontario, Canada
Posts: 819
PrinceOfKenshin has a spectacular aura aboutPrinceOfKenshin has a spectacular aura about
Hmm i feel a feature request coming.
__________________


Quote:
Game Master (Server): Greetings PrinceOfKenshin, there are new posts on the forums that demand your urgent attention! God speed, the fate of the world is in your hands. If you fail, middle earth will forever be in the darkness and your children will be enslaved by McKain.
Reply With Quote
  #14  
Old 09-07-2007, 05:32 AM
Googi Googi is offline
A Serious Epidemic
Googi's Avatar
Join Date: Oct 2001
Location: Canada
Posts: 18,866
Googi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud of
Send a message via AIM to Googi
Quote:
Originally Posted by PrinceOfKenshin View Post
Hmm i feel a feature request coming.
Huh? Why?
__________________
Reply With Quote
  #15  
Old 09-07-2007, 06:26 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
You can either do what Inverness posted, or simply use the function I posted.
Reply With Quote
  #16  
Old 09-07-2007, 07:04 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
You should be using onActionLeftMouse() or onActionRightMouse() for level npcs, remember to define the shape.
__________________
Reply With Quote
  #17  
Old 09-07-2007, 09:32 PM
Kyranki Kyranki is offline
Freelance Coder
Join Date: Aug 2007
Location: At the end of the rainbow, in the pot of gold.
Posts: 202
Kyranki is on a distinguished road
Send a message via AIM to Kyranki Send a message via MSN to Kyranki
PHP Code:
function GraalControl.onMouseDown(modifierxyclickcount) {

Are the proper number of params.
__________________
Stan.
Reply With Quote
  #18  
Old 09-07-2007, 09:41 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Quote:
Originally Posted by Kyranki View Post
PHP Code:
function GraalControl.onMouseDown(modifierxyclickcount) {

Are the proper number of params.
No, That's for onMouseDown. We are talking about triggering a "click" on a npc here.
__________________
Do it with a DON!
Reply With Quote
  #19  
Old 09-07-2007, 10:12 PM
Kyranki Kyranki is offline
Freelance Coder
Join Date: Aug 2007
Location: At the end of the rainbow, in the pot of gold.
Posts: 202
Kyranki is on a distinguished road
Send a message via AIM to Kyranki Send a message via MSN to Kyranki
Quote:
Originally Posted by zokemon View Post
No, That's for onMouseDown. We are talking about triggering a "click" on a npc here.
Ahhh. Wasn't really paying attention to much here. xD
__________________
Stan.
Reply With Quote
  #20  
Old 09-07-2007, 10:37 PM
PrinceOfKenshin PrinceOfKenshin is offline
That guy with a beard
PrinceOfKenshin's Avatar
Join Date: May 2004
Location: Ontario, Canada
Posts: 819
PrinceOfKenshin has a spectacular aura aboutPrinceOfKenshin has a spectacular aura about
Alright thank you my problem is fixed

EDIT: Umm how can i make a bigger range for the person to click?

would i do?
PHP Code:
if (mousex in |xx+2| && mousey in |y,y+2| && mousex in |,x,x+2| && mousey in |y,y+2|){ 
__________________


Quote:
Game Master (Server): Greetings PrinceOfKenshin, there are new posts on the forums that demand your urgent attention! God speed, the fate of the world is in your hands. If you fail, middle earth will forever be in the darkness and your children will be enslaved by McKain.
Reply With Quote
  #21  
Old 09-07-2007, 10:54 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
|0, 5| would mean 0 or 5 or anything between those.
|x, x+5| would mean anything from the NPC's x coordinate to 5 tiles to the right of the x coordinate.

And like I said before, if you're clicking on NPCs in levels you should use setShape() and onActionLeftMouse()
__________________
Reply With Quote
  #22  
Old 09-07-2007, 11:39 PM
PrinceOfKenshin PrinceOfKenshin is offline
That guy with a beard
PrinceOfKenshin's Avatar
Join Date: May 2004
Location: Ontario, Canada
Posts: 819
PrinceOfKenshin has a spectacular aura aboutPrinceOfKenshin has a spectacular aura about
Gotcha makes since, yea i changed to onActionDoublemouse()
__________________


Quote:
Game Master (Server): Greetings PrinceOfKenshin, there are new posts on the forums that demand your urgent attention! God speed, the fate of the world is in your hands. If you fail, middle earth will forever be in the darkness and your children will be enslaved by McKain.
Reply With Quote
Reply


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 07:16 PM.


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