Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using omnitool.
Abion47 Offline
Senior Member

Posts: 369
Threads: 22
Joined: Oct 2015
Reputation: 46
#8
RE: Using omnitool.

When you're working with the Omnitool on panels, there are a couple of ways to go about it.

First is the way you've done it, which is to subscribe to the omnitool's OnUse callback, then use the asEntity parameter to see which panel you are interacting with. (This approach also uses Trigger areas to prompt the omnitool to be equipped.)

bool opendoor_OnCollide(const tString &in asParent, const tString &in asChild, int alState)
{
    if (alState == 1)
    {
        Player_EquipTool("omnitool");
    }
    if (alState == -1)
    {
        Player_UnequipTool();
    }
    
    return true;
}
        
bool closedoor_OnCollide(const tString &in asParent, const tString &in asChild, int alState)
{
    if (alState == 1)
    {
        Player_EquipTool("omnitool");
    }
    if (alState == -1)
    {
        Player_UnequipTool();
    }
    
    return true;
}

bool omnitool_OnUse(const tString &in asTool, const tString &in asEntity)
{
    CathTool_UseOnPanel(asTool, asEntity);
    
    if (asEntity == "omnitool_panel_1")
    {
        SlideDoor_SetClosed("slidedoor", false);
    }
    else if (asEntity == "omnitool_panel_2")
    {
        SlideDoor_SetClosed("slidedoor", true);
    }
    
    return false;
}

The second way (which I believe is the preferred way for script-organizational reasons) is to use the panel's PlayerLookAt and PlayerInteract callbacks.

void omnitool_panel_1_OnPlayerLookAt(const tString &in asEntity, int alState)
{
    if (alState == 1)
    {
        Player_EquipTool("omnitool");
    }
    if (alState == -1)
    {
        Player_UnequipTool();
    }
}

void omnitool_panel_1_OnPlayerInteract(const tString &in asEntity)
{
    CathTool_UseOnPanel("omnitool", "omnitool_panel_1");
    SlideDoor_SetClosed("slidedoor", false);
}

void omnitool_panel_2_OnPlayerLookAt(const tString &in asEntity, int alState)
{
    if (alState == 1)
    {
        Player_EquipTool("omnitool");
    }
    if (alState == -1)
    {
        Player_UnequipTool();
    }
}

void omnitool_panel_2_OnPlayerInteract(const tString &in asEntity)
{
    CathTool_UseOnPanel("omnitool", "omnitool_panel_2");
    SlideDoor_SetClosed("slidedoor", true);
}

The only time you really need to use boolean flags is if you have other effects you want to trigger outside the actual trigger function, or if for example you want other buttons to be disabled/enabled that the player can get to at various times. Otherwise, it's unnecessary. (Though to be fair their existence isn't going to hurt anything either.)
11-26-2015, 04:38 PM
Find


Messages In This Thread
Using omnitool. - by Hypercube - 11-24-2015, 11:46 PM
RE: Using omnitool. - by Romulator - 11-25-2015, 12:26 AM
RE: Using omnitool. - by Hypercube - 11-25-2015, 12:48 AM
RE: Using omnitool. - by Romulator - 11-25-2015, 01:26 AM
RE: Using omnitool. - by Hypercube - 11-25-2015, 02:18 AM
RE: Using omnitool. - by Hypercube - 11-26-2015, 02:19 AM
RE: Using omnitool. - by Hypercube - 11-26-2015, 04:40 AM
RE: Using omnitool. - by Abion47 - 11-26-2015, 04:38 PM
RE: Using omnitool. - by Hypercube - 11-26-2015, 08:18 PM



Users browsing this thread: 1 Guest(s)