Hotspot click not working...

Started by monkey0506, Wed 03/11/2004 03:38:36

Previous topic - Next topic

monkey0506

In my global script I have this function:

Code: ags
function SetGlobalMode(int which){
  //if cursor isn't "give" mode of use
  if (invmode!=1) SetGlobalInt(100, which);
  //if cursor is "give" mode of use
  else if (invmode==1) SetGlobalInt(100, give);
  }


invmode is used to determine between use and give as they are the same cursor. give is #define(d) in the script header as 12. I then call this function in repeatedly_execute:

Code: ags
function repeatedly_execute(){// put anything you want to happen every game cycle here
  if (timer>0) timer--;
  if (timer==0){
    if (IsGUIOn(TEXTSPEED)==1) GUIOff(TEXTSPEED);
    if (IsGUIOn(VOLUME)==1) GUIOff(VOLUME);
    timer=-1;
    }
  mode=GetCursorMode();
  if (IsGUIOn(LOAD)==0) GUIOff(LOADLABEL);
  GetTextBoxText(SAVETEXTBOX, 1, textboxtext);
  if (IsGUIOn(SAVETEXTBOX)==0) SetTextBoxText(SAVETEXTBOX, 1, "");
  if (IsGUIOn(LOAD)==0) SetLabelText(LOAD, 2, "Choose a game to LOAD");
  while ((mode==walk) && (GetInvAt(mouse.x, mouse.y)!=-1)) SetCursorMode(lookat);
  UpdateLabelBar();
  KeyControls();
  Extension();
  HighlightDefaultMode();
  if (IsGUIOn(QUIT)==1) SetGUIClickable(MENU, 0);
  else if (IsGUIOn(QUIT)==0) SetGUIClickable(MENU, 1);
  InventoryArrows();
  if ((IsGUIOn(SAVE)==0) && (IsGUIOn(LOAD)==0)){
    GUIOff(LISTOVERLAY);
    ListBoxSetSelected(SAVE, 0, -1);
    ListBoxGetTopItem=0;
    }
  SetGlobalMode(mode);
  }


mode is set to the value of GetCursorMode(). Then, per SetGlobalMode(int which), GlobalInt 100 should equal the cursor mode, unless the mode is give, in which case it should be 12. I then check it in my room 1, hotspot 2 script... actually, I deleted that part of checking the Global int. Instead, I just have in Any Click on Hotspot (Run script):

Code: ags
Display("something");


No matter what mouse button I click, it never displays any message when I click on the hotspot. I have to go to bed...

monkey0506

I"m really sorry for doing this (*bump*), but this is one of the last things I need to figure out for my GUI... The problem is (just to re-verify):

Whenever I click on my hotspot #2 (of 2) in room #1 (of 1), there is no reaction. As I previously stated, I have in the "Any click on Hotspot" division of the Interaction menu for hotspot #2 "Run Script" and the script reads:

Display("something");

No matter what cursor mode I use, there is no reaction on any click of this hotspot. If I need to I'll upload a copy of what I have so far... (but only as a last resort). Thanks for any help.

Scummbuddy

hmm, maybe you will have to upload it. the way you put it, it sounds like you've done it right, but maybe fresh eyes will have another affect.

but first... try recreating the whole thing in a new room, and see if it will display. try and follow the exact steps, or redo the whole thing, and see.
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

monkey0506

ARG! Thanks for trying Scummbuddy, but alas, it failed. I created a new room, set the player to start in this room (as I haven't yet imported sprites for this character) and put the "Display("something");" line in the hotspot #1 interaction. I've searched the manual, and still come up with nothing. I've searched my scripts, and the word hotspot shows up nowhere in any of my scripts, so I don't think I somehow disabled my hotspots. I'm going crazy trying to figure this out. I know that you can't use the "Walk" cursor mode, and I have tried all other 8 standard cursor modes:

1:   Look at
2:   Use/Give
3:   Talk to
5:   Pick up
8:   Open
9:   Close
10: Push
11: Pull

None of them work. It really is a last resort for me to upload this while it's still under construction like this, and I don't have time to mess with it right now, so I'll upload it in about a week... My little sister's birthday is Thursday, but we're celebrating it tomorrow (Wednesday) because Saturday my cousin is getting married and my mom, my older sister, and I are flying out to California Thursday and coming back Monday, so tomorrow I have to celebrate my sisters b-day and then I'll be in California for 5 days, so that's why I said about a week. I just hope one of you geniouses (no jest intended) can figure out how to fix my problem without having to get your hands on my work. Otherwise I'll make a few changes (add sprites for the player character, make a few rooms, add some inventory items, etc.) and then upload it. Well, good night... Michael Rittenhouse

strazer

Can you please post your on_mouse_click function?

monkey0506

Hmm... I hadn't thought about posting that, though at one point I did completely comment out the code in the function to try and get it to work...

Code: ags
function on_mouse_click(int button) // called when a mouse button is clicked. button is either LEFT or RIGHT
Ã,  {
Ã,  if (IsGUIOn(LOAD)==1) SetLabelText(LOAD, 2, "Choose a game to LOAD");
Ã,  else if (IsGUIOn(SAVETEXTBOX)==1) SetTextBoxText(SAVETEXTBOX, 0, "");
Ã,  else if (IsGUIOn(QUIT)==1) GUIOff(QUIT);
/*Ã,  if (IsGamePaused()==1) // Game is paused, so do nothing (ie. don't allow mouse click)
Ã,  Ã,  {
Ã,  Ã,  }*/
Ã,  else if (button==LEFT){//left-click
Ã,  Ã,  if ((StrContains(GSext, ext_unhandled)!=-1)Ã,  && (exthandle!=mode)) Unhandled(mode);
Ã,  Ã,  else if (StrContains(GSext, ext_unhandled)!=-1) Unhandled(exthandle);
Ã,  Ã,  if ((GetLocationType(mouse.x, mouse.y)==0) && (GetGUIAt(mouse.x, mouse.y)==-1) && (GetInvAt(mouse.x, mouse.y)==-1)){
Ã,  Ã,  Ã,  SetLabelColor(MAIN, 0, 13);
Ã,  Ã,  Ã,  Wait(3);
Ã,  Ã,  Ã,  SetLabelColor(MAIN, 0, 31055);
Ã,  Ã,  Ã,  }
Ã,  Ã,  if (mode==walk) MoveCharacter(GetPlayerCharacter(), mouse.x, mouse.y);
Ã,  Ã,  else if (mode!=walk){
Ã,  Ã,  Ã,  if ((GetLocationType(mouse.x, mouse.y)==0) && (GetInvAt(mouse.x, mouse.y)<=0) && (GetGUIAt(mouse.x, mouse.y)!=0)) SetCursorMode(walk);
Ã,  Ã,  Ã,  }
Ã,  Ã,  }
Ã,  else if (button==RIGHT){//right-click
Ã,  Ã,  if (StrContains(GSext, ext_unhandled)!=-1) Unhandled(exthandle);
Ã,  Ã,  }
Ã,  else if (button==LEFTINV){//left-click over inventory
Ã,  Ã,  if (mode==use) SetActiveInventory(GetInvAt(mouse.x, mouse.y));
Ã,  Ã,  else if (mode==usegiveinv){
Ã,  Ã,  Ã,  if (extint==player.activeinv){}
Ã,  Ã,  Ã,  else if (extint!=player.activeinv){
Ã,  Ã,  Ã,  Ã,  SetCursorMode(walk);
Ã,  Ã,  Ã,  Ã,  UpdateLabelBar();
Ã,  Ã,  Ã,  Ã,  Display("That doesn't seem to work.");
Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  }
Ã,  Ã,  }
Ã,  else {//right-click over inventory
Ã,  Ã,  if (StrContains(GSext, ext_unhandled)!=-1) Unhandled(exthandle);
Ã,  Ã,  }
Ã,  }

strazer

Aren't you missing the ProcessClick in there? AFAIK, that's what calls the interaction functions. You move your character manually, so walking works obviously.

Try putting the ProcessClick function back in there. The default is
ProcessClick(mouse.x, mouse.y, GetCursorMode());

monkey0506

#7
Oh... That explains a lot... Now I feel horrible... That was pretty simple... In case you couldn't tell, it works now...

EDIT: Ok, now I have another question... For right-clicks I have this script:

Code: ags
  else if (button==RIGHT){//right-click
    if (StrContains(GSext, ext_char)!=-1){//if a right-click mode has been defined
      if (StrContains(GSext, ext_unhandled)!=-1) Unhandled(exthandle);//if it is unhandled
      else{//if it is handled
        SetCursorMode(exthandle);
        ProcessClick(mouse.x, mouse.y, mode);
        }
      }
    }


The problem is when I test the game, the first time I right-click, it only sets the cursor mode, then I have to right-click(or actually a left-click would produce the function) to get it to process the click. I tried adding a "Wait(1);" line before the ProcessClick line to ensure that it updated the cursor mode before processing the click, and it produced the same results. BTW, thanks stazer for your help on this (previous) problem! (also to Scummbuddy  :P)

strazer

QuoteProcessClick(mouse.x, mouse.y, mode);

Where does "mode" come from?

Try
  ProcessClick(mouse.x, mouse.y, GetCursorMode());
or
  ProcessClick(mouse.x, mouse.y, exthandle);

monkey0506

#9
THANK YOU!!! Ok, this is my code now:

In on_mouse_click:
Code: ags
Ã,  else if (button==RIGHT){//right-click
Ã,  Ã,  if (StrContains(GSext, ext_char)!=-1){
Ã,  Ã,  Ã,  if (StrContains(GSext, ext_unhandled)!=-1) Unhandled(exthandle);
Ã,  Ã,  Ã,  else{
Ã,  Ã,  Ã,  Ã,  SetGlobalMode(exthandle);
Ã,  Ã,  Ã,  Ã,  ProcessClick(mouse.x, mouse.y, exthandle);
Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  }
Ã,  Ã,  }


In Hotspot Interaction Menu Any Click On Hotspot Run Script:
Code: ags
if (GetGlobalInt(globalmode)==pickup){
Ã,  UpdateLabelBar(pickup);
Ã,  SetLabelColor(MAIN, 0, 13);
Ã,  Display("I don't want to pick that up...");
Ã,  SetCursorMode(walk);
Ã,  SetLabelColor(MAIN, 0, 31055);
Ã,  }
else Unhandled(mode);


I added a parameter to my "UpdateLabelBar" function so that I can update the label bar with the correct text prior to running the interaction without having to wait a loop for the label to update. Now all I have left:

1. Insure that the inventory works 100% correctly
2. Correct and import character sprites
3. Make new character to create dialog
4. Complete talking font
5. Script dialog gui
6. Script maps gui
7. Import inventory items (optional as they can't be deleted)

1. Easy
2. Easy
3. Easy
4. Time consuming (Easy)
5. Easy
6. Not sure, but expect to be Easy
7. Easy

So, the GUI I've been working on since August (and perhaps even earlier) is finally nearing completion. Once it is complete I will release a pre-demo to show off the GUI. Please all expect to be amazed.

SMF spam blocked by CleanTalk