Translations of this page:

Displaying hint icons over active hotspots

If you want to implement functionality similar to active object highlighting in Tunguska, add the following piece of code to game.script:

var ShowingHintIcons = false; 
//////////////////////////////////////////////////////////////////////////////// 
function ShowHintIcons() 
{ 
       // Small fix by metamorphium. Feel free to ignore 
      if (Scene.GetLayer("hints") == null) ShowingHintIcons = false; 
      //End Fix 
 
    // make sure we're only displaying the icons once 
    if(!ShowingHintIcons) 
    { 
        ShowingHintIcons = true; 
 
        // create a new top-level layer 
        var HintLayer = Scene.AddLayer("hints"); 
 
        // traverse through all scene entities 
        var MainLayer = Scene.MainLayer; 
        var i; 
        for(i = 0; i < MainLayer.NumNodes; i = i + 1) 
        { 
            var Node = MainLayer.GetNode(i); 
            AddHintIcon(HintLayer, Node); 
        } 
 
        // traverse through all free entities/actors 
        for(i = 0; i < Scene.NumFreeNodes; i = i + 1) 
        { 
            Node = Scene.GetFreeNode(i); 
            AddHintIcon(HintLayer, Node); 
        } 
 
        // rotate the icons for a moment 
        for(var t = 0; t <= 360; t = t + 15) 
        { 
            for(i = 0; i < HintLayer.NumNodes; i = i + 1) 
            { 
                var Icon = HintLayer.GetNode(i); 
                Icon.Rotate = t; 
            }         
            Sleep(50); 
        } 
 
        // delete the entire layer 
        Scene.DeleteLayer(HintLayer); 
 
        ShowingHintIcons = false; 
    } 
} 
 
//////////////////////////////////////////////////////////////////////////////// 
function AddHintIcon(Layer, Node) 
{ 
    // we're only interested in interactive visible entities 
    if(Node.Type!="entity" || !Node.Interactive || !Node.Active) return; 
 
    // create the hint icon 
    // you could improve this, e.g. to display different icons depending on the 'Node' capabilities 
    var Icon = Layer.AddEntity("icon"); 
    Icon.SetSprite("sprites\system\cur_wait.sprite");  // Replace this with a sprite that should mark the hotspots 
    Icon.X = Node.X; 
    Icon.Y = Node.Y - (Node.Height / 2); 
    Icon.Active = true; 
    Icon.Interactive = false; 
    Icon.Scalable = false; 
    Icon.Rotatable = true;     
}

Now the only thing you need to do is to call this code somewhere. For example, if you want to display the hint icons when the player presses the spacebar, edit game.script, find the on “Keypress” handler, and add something like:

if(Keyboard.KeyCode==VK_SPACE) ShowHintIcons();

This script is based on the original code written by Mac.

 
resource/displaying_hint_icons_over_active_hotspots.txt · Last modified: 2011/05/08 23:12 by Mnemonic
Recent changes RSS feed Creative Commons License Driven by DokuWiki