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 09-02-2013, 09:06 AM
Trakan Trakan is offline
It's all about cats!
Trakan's Avatar
Join Date: Sep 2010
Location: France
Posts: 64
Trakan is an unknown quantity at this point
leftmousebutton problem

So i'm doing a kind of panel, basically i want to show it when you click on the panel image:


But when i click, (everywhere else, don't matter if its on the image or not), it shows correctly.

How can i make it show only if i click on the image?

Class:
PHP Code:
// Scripted by *Trakan

function onActionServerSide(null) {
  
serverr.available_quests += 1;
}
//#CLIENTSIDE
  
if (leftmousebutton) {
QuestMenu_Window1.show();
}
function 
onCreated() {
  
onTimeout();


  new 
GuiWindowCtrl("QuestMenu_Window1") {
    
clientrelative true;
    
clientextent "570,374";
    
canmaximize false;
    
profile GuiBlueWindowProfile;
    
useOwnProfile true;
    
canmove true;
    
canresize false;
    
closequery false;
    
destroyonhide false;
    
text "Available Quests";
    
screenheight/2;
    
50;
    
profile.bitmap "gh_gui-general.png";
    
profile.fillColor = {58,63,37};

    new 
GuiTextCtrl("QuestMenu_Text1") {
      
profile GuiBlueTextProfile;
      
height 25;
      
horizsizing "center";
      
text "Available Quests (" serverr.available_quests "/" serverr.maxquests ")";
      
width 140;
      
225;
      
5;
    }
    new 
GuiBitmapButtonCtrl("QuestMenu_Button1") {
      
text "   JOIN";
         
width 48;
         
heigh 24;
      
462;
      
40;
   
normalbitmap "gh_gui-button.png";
   
mouseoverbitmap "gh_gui-button.png";
   
pressedbitmap "gh_gui-button.png";
    }

        new 
GuiBitmapButtonCtrl("QuestMenu_Button2") {
      
text "  INFO+";
         
width 48;
         
heigh 24;
      
515;
      
40;
   
normalbitmap "gh_gui-button.png";
   
mouseoverbitmap "gh_gui-button.png";
   
pressedbitmap "gh_gui-button.png";
    }
    new 
GuiTextCtrl("QuestMenu_Text2") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Type: Recolte";
      
width 80;
      
367;
      
46;
    }
    new 
GuiTextCtrl("QuestMenu_Text3") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "RANK: ";
      
width 74;
      
268;
      
46;
    }
    new 
GuiTextCtrl("QuestMenu_Text4") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Quest: " serverr.quest1_questname;
      
width 206;
      
35;
      
46;
    }
    new 
GuiBitmapCtrl("QuestMenu_Bitmap1") {
      
profile GuiDefaultProfile;
      
bitmap "gh_icon_health-potion.png";
      
fullbitmap false;
      
height 62;
      
7;
      
43;
    }
}
}
function 
QuestMenu_Button1.onAction() {
 if (
serverr.available_quests != serverr.maxquests) {
triggerserver("gui"this.namenull);
}

}

function 
onTimeout()
  {
if (
serverr.quest1_available == true) {
QuestMenu_Button1.hide();
QuestMenu_Button2.hide();
QuestMenu_Text2.hide();
QuestMenu_Text3.hide();
QuestMenu_Text4.hide();
QuestMenu_Bitmap1.hide();
} else if (
serverr.quest1_available == false) {
QuestMenu_Button1.show();
QuestMenu_Button2.show();
QuestMenu_Text2.show();
QuestMenu_Text3.show();
QuestMenu_Text4.show();
QuestMenu_Bitmap1.show();
}

  
QuestMenu_Text1.text "Available Quests (" serverr.available_quests "/" serverr.maxquests " )";
  
setTimer(0.1);


Last edited by Trakan; 09-02-2013 at 09:27 AM..
Reply With Quote
  #2  
Old 09-02-2013, 08:36 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
First of all, please style your code before posting it. Secondly, put that check into a function. Third, leftmousebutton is a boolean indicating whether the left mouse button is pressed or not. It doesn't have anything to do with whether the mouse is over top of your object or not. For that check mousex and mousey. Something like:

PHP Code:
if (leftmousebutton && mousex in |this.xthis.this.width| && mousey in |this.ythis.this.height|) {
  
// open

You'll need to put that into a timeout. Note that the preferred way to do it would use onMouseDown instead so you don't need a timeout.
__________________
Reply With Quote
  #3  
Old 09-02-2013, 10:23 PM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu has a spectacular aura aboutTorankusu has a spectacular aura about
Quote:
Originally Posted by cbk1994 View Post
First of all, please style your code before posting it. Secondly, put that check into a function. Third, leftmousebutton is a boolean indicating whether the left mouse button is pressed or not. It doesn't have anything to do with whether the mouse is over top of your object or not. For that check mousex and mousey. Something like:

PHP Code:
if (leftmousebutton && mousex in |this.xthis.this.width| && mousey in |this.ythis.this.height|) {
  
// open

You'll need to put that into a timeout. Note that the preferred way to do it would use onMouseDown instead so you don't need a timeout.

Thanks for confirming this. I thought it was weird he wasn't checking if the sign itself was clicked, but didn't want to give him bad advice.
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #4  
Old 09-02-2013, 10:55 PM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
You need to use a function to catch if the left mouse button is pushed. Usually GraalControl.onMouseDown()
I modified the script some, the forums still don't allow me to post PHP sometimes, so I've just attached it in a txt file.
Attached Files
File Type: txt script.txt (3.9 KB, 161 views)
__________________
Deep into the Darkness peering...
Reply With Quote
  #5  
Old 09-03-2013, 01:12 AM
BlueMelon BlueMelon is offline
asdfg
BlueMelon's Avatar
Join Date: Sep 2008
Posts: 1,481
BlueMelon is a splendid one to beholdBlueMelon is a splendid one to beholdBlueMelon is a splendid one to beholdBlueMelon is a splendid one to behold
Quote:
Originally Posted by Trakan View Post
But when i click, (everywhere else, don't matter if its on the image or not), it shows correctly.
By looking at your script I assume it's in a weapon?
Have you considered catching the mouse event when the player clicks the NPC rather then catching it at every click and comparing x/y's in a range?

You can then trigger an action to open the GUI
__________________
http://i.imgur.com/OOJbW.jpg
Reply With Quote
  #6  
Old 09-03-2013, 12:39 PM
Trakan Trakan is offline
It's all about cats!
Trakan's Avatar
Join Date: Sep 2010
Location: France
Posts: 64
Trakan is an unknown quantity at this point
Ok everyone, everything is working so far .
Thanks alot! And sorry, i'm starting scripting

Last edited by Trakan; 09-03-2013 at 12:54 PM..
Reply With Quote
  #7  
Old 09-04-2013, 09:05 AM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
Feel free to pm me anytime if you have any questions. =]
__________________
Deep into the Darkness peering...
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 11:21 PM.


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