Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Author Topic: Custom hotspots system  (Read 9640 times)

0 Members and 1 Guest are viewing this topic.

The Man

  • Occasional poster
  • **
  • Karma: 1
  • Offline Offline
  • Posts: 67
    • View Profile
Custom hotspots system
« on: October 15, 2014, 03:08:41 PM »

For once I feel like I could contribute somehow to this great community we all belong to.
These past days I tried to implement the hotspot system which is available here as a free resource:

http://res.dead-code.org/doku.php/resource:displaying_hint_icons_over_active_hotspots

Although this system works very well it wasn't exactly what I was trying to achieve for two reasons:
1- The hint icons are positioned according to the X and Y attributes of the nodes of the scene.
2- The code automatically set an icon for EVERY node of the scene. What if I want the icons to appear only on the most important nodes?

IMPORTANT: probably there are thousand of ways to solve these issues, but I managed to do it my way, which isn't certainly the best one. The following guide is for those who really don't know what to do and can't find anybody who help them. I also have to point out that with this system you will have to program every hint icon individually. Here's the step-by-step guide:

1- Insert this line into base.inc:
Code: [Select]
global hotspot;
2- Insert this piece of code inside game.script:
Code: [Select]
function mostrahotspots()
{

 
    // make sure we're only displaying the icons once
    if(!hotspot)
    {

hotspot = true;

Sleep(200);

hotspot = false;
 
    }
}

3- Open up a scene with Scene-editor and create a new layer called "hotspots". DON'T make it a close-up layer, otherwise it will stop the game while it is active;

4- Inside this new layer create every hint icon you want to show in the scene. Give them names you will easily remember. (F.E. if you have a node in your scene that is called "table", just name its corresponding hint icon "tablehotspot";

5- Once you have all the icons you need, disable this layer so that the player will not see it.

6- Open up the Scene-init script and insert this piece of code AFTER the stuff which initializes the scene:

Code: [Select]
var hotspots=Scene.GetLayer("hotspots");
while(true)
{
  if(hotspot==true)
  {
    hotspots.Active=true;
Sleep(2000);
hotspots.Active=false;
  }
  else
  {
   hotspots.Active=false;
  }
Sleep(200);
}

7- Open again game.script and add this piece of code inside your "on Keypress":

Code: [Select]
if(Keyboard.KeyCode==VK_SPACE) mostrahotspots();
8- And the trick is done. Now when you press the spacebar (inside a scene you have set up) the layer "hotspots" will be shown with all the icons it contains.

ADVANTAGES
- You can control the exact position of your hint icons;
- You can decide which node will have a hint icon (avoiding every object on the scene to have one).

DISADVANTAGES
- It is not fully automated. You have to set up every scene and every hint icon;
- When you deactivate a node, you will also have to remember to deactivate its corresponding hint icon. Otherwise the icon will be shown even if the node is no more active.

I tested the code on various scenes and it looks like it works as it should! I hope this can be useful for somebody!
Logged

keybone

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 112
    • View Profile
    • Lucine
Re: Custom hotspots system
« Reply #1 on: November 20, 2014, 10:37:47 AM »

tk for this tool! O0
Logged
Lucine Company http://www.lucine.it/
Tales of Lucine: The Realm of Hobdark http://www.lucine.it/TalesOfLucine

diegoquarantine

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 50
    • View Profile
    • Buenos Aires Quarantine Studio
Re: Custom hotspots system
« Reply #2 on: November 27, 2014, 10:27:52 PM »

I was looking a way to do this and I was thinking of something just like this! Thanks!!
 

Page created in 0.041 seconds with 18 queries.