[SOLVED] Verb coin template: using hotspots without verb coin.

Started by Adrian, Thu 21/02/2013 18:36:25

Previous topic - Next topic

Adrian

Hi everyone,

I'm setting up a new game using the verb coin template with three buttons: interact, look and talk. The template itself works very well and does just what it is supposed to do. But I was wondering how to set up a function for a single click on a hotspot without using the verb coin.

For example: You have a hotspot for a door. Choosing the interact button from the verb coin makes the player enter that door and change rooms. But I'd like the player to be able to do so by just clicking once at the hotspot without opening the verb coin. It would be great if I could run a function there for many reasons.

Using hHotspot_AnyClick from the events panel works for clicking on the hotspot but makes the function run also after using the three verb coin buttons. So that doesn't really work. Does anyone have an idea how I could get there?

Thank you.
Adrian

Haggis

If you view the hotspot's properties does it have one called 'act'? Should be boolean - true / false.

Setting that to true should result in a single click hotspot (at least that's how I've implemented it in my verbcoin game).

Update - this may help further: http://www.adventuregamestudio.co.uk/forums/index.php?topic=35550.msg466207#msg466207

Demicrusaius

You could use the "When the Mouse is over the hotspot" option for the hotspot and add something that automatically changes the mouse mode when over it.
You could use savecursuruntilitleaves(); to remember the mode it was at before you moused over the hotspot and have it automatically change back when leaving.
It is better to light one small candle than to curse the darkness.

Adrian

Hello Haggis, hello Demicrusaius,

thanks for your replies.

Yes, I've noticed the 'act' property. The problem with that is when I set it to true the verb coin gets desabled for that certain hotspot. Short click on hotspot works then but I cannot open the verb coin any more. I whish to do both on hotspots: handle them with the verb coin commands and with a single short click additionally.

I'm not sure if the overhotspot and savecursor method is the best way for this issue. To have a global function in the on_mouse_click event that checks for a short click on hotspots using timers and than eventually passes on to the verb coin script would be better, I guess. But I'm not good enough to figure this out by myself.

Thank you anyway.

Haggis

Ah - so you want hotspots that support both long click (verb coin) and short click (interact).

I guess you could add a new property to hotspots to specify if they support the short and long click.

Then in the verbcoin module code - add a new check --if shortclick = true and the hotspot supports short click interaction-- then run the hotspot's interaction function - I think you'd put it in here:

Code: AGS
        if (Mouse.IsButtonDown(eMouseLeft) == 0){ //this executes if the button is released
            /*SHORT CLICK*/ 
              if (mouse.Mode != eModeUseinv){	//not holding an item
                if (gui[inv_id].Visible==true){ //if inventory open
                  if (item != null){ //If cursor over item then set player holding item
                    player.ActiveInventory = item;
                    action_name = player.ActiveInventory.Name;
                  }          
                }
                else if(/*IF OVER HOTSPOT && HOTSPOT SUPPORTS SHORT CLICK INTERACTION*/){
                  //RUN THE HOTSPOT INTERACTION
                }
                else{ //RUN WALK TO
                  if (process == false){
                    ProcessClick(mousex,mousey, eModeWalkto);  //move to that spot 
                  }
                }
              }
              else if (GetLocationType(mousex+(offsetstartx-GetViewportX()), mousey+(offsetstarty-GetViewportY())) != eLocationNothing) ProcessClick(mousex,mousey, eModeUseinv); //inventory interact		
              else ProcessClick(mousex,mousey, eModeWalkto);  //move to that spot 
            clicked=0; 	//click done
            timer=0;		//timer reset
          }
        }



I'm no coder though so I'm not going to claim this is the best way to do it but that's where I would start.

EDIT - I assume you're using Electroshokker's verb coin module

Adrian

Thank you, Haggis. This seems to be a good approach to me. Yes, I'm using Electroshokker's module here.

I put your code in the appropriate position and used the variable 'htspt' which is created in the verb coins repeatedly_execute: Hotspot*htspt=Hotspot.GetAtScreenXY(mouse.x, mouse.y).

Unfortunately I cannot find the variable 'offsetstartx' anywhere in the script. Could you explain how to declare it? Because I get an undefined symbol error there.

Here's my code so far:

Code: AGS

 if (Mouse.IsButtonDown(eMouseLeft) == 0){ //this executes if the button is released
     /*SHORT CLICK*/
       if (mouse.Mode != eModeUseinv){   //not holding an item
         if (gui[inv_id].Visible==true){ //if inventory open
           if (item != null){ //If cursor over item then set player holding item
             player.ActiveInventory = item;
             action_name = player.ActiveInventory.Name;
           }          
         }
         else if(GetLocationType(mouse.x,mouse.y) == eLocationHotspot){
           if (htspt.GetProperty("Shortclick")){
             Display("Short click");//RUN THE HOTSPOT INTERACTION
           }
         }
         else{ //RUN WALK TO
           if (process == false){
             ProcessClick(mousex,mousey, eModeWalkto);  //move to that spot
           }
         }
       }
       else if (GetLocationType(mousex+(offsetstartx-GetViewportX()), mousey+(offsetstarty-GetViewportY())) != eLocationNothing) ProcessClick(mousex,mousey, eModeUseinv); //inventory interact         
       else ProcessClick(mousex,mousey, eModeWalkto);  //move to that spot
     clicked=0;  //click done
     timer=0;            //timer reset
   }
 }


Thanks for helping!

Haggis

Apologies, that's a bit of code contamination. It's part of Ali's smooth scroll module (http://www.adventuregamestudio.co.uk/forums/index.php?topic=33142.0) which I would highly recommend but could be tricky to integrate into a game in mid development.

I think all you need to do is replace this:
Code: AGS
       else if (GetLocationType(mousex+(offsetstartx-GetViewportX()), mousey+(offsetstarty-GetViewportY())) != eLocationNothing) ProcessClick(mousex,mousey, eModeUseinv); //inventory interact         
       else ProcessClick(mousex,mousey, eModeWalkto);  //move to that spot


with this:
Code: AGS
          else{			
            ProcessClick(mousex,mousey, eModeUseinv); //inventory interact
          }

monkey0506

Funny thought, but the ahem other verb coin module actually allows you to handle single-clicks simply by setting the property Verbcoin.DefaultMode. In this situation you could store the existing default mode in a temporary when entering the hotspot, change it, and then restore it from the temporary when leaving the hotspot. All without having to get your hands dirty by editing the module code.

My hat's off to anyone willing to pour through the disgusting filth that is the source of the distributed template to try and make customizations though.

Adrian

No need to apologize, Haggis. You really helped me out here. Now I got what I wanted and the script fires the usermode1 function after a short click on the hotspot. So I can set up a usermode1 function for every hotspot when needed.

Code: AGS

 if (Mouse.IsButtonDown(eMouseLeft) == 0){ //this executes if the button is released
     /*SHORT CLICK*/
       if (mouse.Mode != eModeUseinv){   //not holding an item
         if (gui[inv_id].Visible==true){ //if inventory open
           if (item != null){ //If cursor over item then set player holding item
             player.ActiveInventory = item;
             action_name = player.ActiveInventory.Name;
           }          
         }
         else if(GetLocationType(mouse.x,mouse.y) == eLocationHotspot){
           if (htspt.GetProperty("Shortclick")){
             ProcessClick(mouse.x, mouse.y, eModeUsermode1);  //RUN THE HOTSPOT INTERACTION
           }
         }
         else{  //RUN WALK TO
           if (process == false){
             ProcessClick(mousex,mousey, eModeWalkto);  //move to that spot
           }
         }
       }
         else{                
           ProcessClick(mousex,mousey, eModeUseinv); //inventory interact
         }
     clicked=0;  //click done
     timer=0;    //timer reset
   }
 }


monkey, I was thinking about using your module but already had made too many changes in the new game, replaced grafics etc. so I didn't want to start over again. But it was definitely an option!  :smiley:

Thank you again for your help and support!!

Haggis

Excellent news, look forward to seeing how it is implemented in the final game!

Monkey is right, Electroshokker's template is excellent as a standard verb coin interface and can be customised if you dedicate time and effort to understanding the code behind it but it would be nice to have an option that is more flexible... such as Monkey's template/module. My own experience was that because the Electroshokker module came bundled with AGS I just went with that. By the time I understood more about modules I had undertaken too much development to switch. Now I'm more comfortable with AGS I'll definitely look at Monkey's module for any future games. I mean, Electroshokker himself gave it his approval, which I would certainly call making a mark on this community ;)

Hope that doesn't come across as critical of Electroshokker's module. I think it's great and I probably learnt quite a bit about AGS picking it apart for my own needs. It's now solidly engrained in my game and I'm very happy with it :D

Adrian


SMF spam blocked by CleanTalk