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.
Hypercube Offline
Member

Posts: 124
Threads: 20
Joined: Sep 2015
Reputation: 1
#1
Using omnitool.

So I have the code setup and everything for opening elevator doors being the finaldoor. And it works hooray! But I have another omnipanel inside the elevator that's supposed to close the doors in order to end the map. But how would I do that exactly? I asked this in another thread (CathTool / Omnitool scripting error), but I don't really seem to get it to work. Would I have to put in a SlideDoor_SetClosed for it to work? I'm not really super smart on scripting this so I just want to understand it better.
11-24-2015, 11:46 PM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#2
RE: Using omnitool.

Why not just look at how the door closes in script in the appropriate map it shows up in? What script was used there?

Discord: Romulator#0001
[Image: 3f6f01a904.png]
11-25-2015, 12:26 AM
Find
Hypercube Offline
Member

Posts: 124
Threads: 20
Joined: Sep 2015
Reputation: 1
#3
RE: Using omnitool.

(11-25-2015, 12:26 AM)Romulator Wrote: Why not just look at how the door closes in script in the appropriate map it shows up in? What script was used there?

Well I don't really know where to find that in, maybe I'm just asking a silly question on this thread but usually you use your omnitool on a panel to open something and then afterwards you don't find another one that closes it. Am I supposed to know?

(I already looked through most script files that had lots of functions that had to do with the omnitool)
(This post was last modified: 11-25-2015, 12:52 AM by Hypercube.)
11-25-2015, 12:48 AM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#4
RE: Using omnitool.

Well, the Omnitool is essentially a trigger for scripts to occur - similar to how a Player walks through an area in order for scripts to actually begin.

The area I'm thinking of would be theta_labs (I believe), since there is an elevator in that map. Look at the code they used for when you press a button in the elevator to close the doors. The Omnitool can do the same thing when it is used on a panel - since the "trigger" can be the Omnitool's animation as opposed to a button press.

Sorry that I'm not being much help about saying "what code is actually needed", but a good skill about learning is to see how it has been done before. It's most likely a Swingdoor, since SwingDoors are the doors which open and close. You can always try using code that you think may work, and if it doesn't, experiment with other similar codes in order to get your desired result.

Discord: Romulator#0001
[Image: 3f6f01a904.png]
11-25-2015, 01:26 AM
Find
Hypercube Offline
Member

Posts: 124
Threads: 20
Joined: Sep 2015
Reputation: 1
#5
RE: Using omnitool.

(11-25-2015, 01:26 AM)Romulator Wrote: Well, the Omnitool is essentially a trigger for scripts to occur - similar to how a Player walks through an area in order for scripts to actually begin.

The area I'm thinking of would be theta_labs (I believe), since there is an elevator in that map. Look at the code they used for when you press a button in the elevator to close the doors. The Omnitool can do the same thing when it is used on a panel - since the "trigger" can be the Omnitool's animation as opposed to a button press.

Sorry that I'm not being much help about saying "what code is actually needed", but a good skill about learning is to see how it has been done before. It's most likely a Swingdoor, since SwingDoors are the doors which open and close. You can always try using code that you think may work, and if it doesn't, experiment with other similar codes in order to get your desired result.

I was just thinking, that instead, I could have the omnitool plug into a terminal in order to unlock an elevator button and have another on the inside. That to me would make for a better puzzle, but I know it'd take a lot longer to script.

EDIT: Heheh, just solved the problem... The scripting for the functions were correct, I was just using them in the same exact parameters but in a different event. Obviously I had to put the functions under the same in the same event as I did the last, but I think that was about my main issue with it. I had to mess around with different parts though to figure out how to trigger the event.

My only problem with the second omnipanel is that the return false; doesn't count for it or something, because I can use it again (not having any effect on the doors) when it says return false when both functions are in the same body. I don't know exactly how to say the code is written so here it is:

bool omnitool_CanBeUsed(const tString &in asTool, const tString &in asEntity)
{
if(asEntity == "omnipanel_finaldoor" && mbFinalDoorOpened == false) return true;

if(asEntity == "omnipanel_elevator" && mbFinalDoorOpened == true) return true;

return false;
}

bool omnitool_OnUse(const tString &in asTool, const tString &in asEntity)
{

if(asEntity == "omnipanel_finaldoor")
{
cLux_AddDebugMessage("Use omnitool");
CathTool_UseOnPanel("omnitool","omnipanel_finaldoor");
mbFinalDoorOpened = true;
}

if(asEntity == "omnipanel_elevator")
{
cLux_AddDebugMessage("Use omnitool again");
CathTool_UseOnPanel("omnitool","omnipanel_elevator");
SlideDoor_SetClosed("finaldoor",true);
}
return false;
}
(This post was last modified: 11-25-2015, 03:07 AM by Hypercube.)
11-25-2015, 02:18 AM
Find
Hypercube Offline
Member

Posts: 124
Threads: 20
Joined: Sep 2015
Reputation: 1
#6
RE: Using omnitool.

Okay nevermind... So I feel dumb now because first I'm like, help me! Then I'm like, oh it's okay, then I'm confused, now I'm fine. The only real part I was missing was to put mbFinalDoorOpened = false; into the last part:

if(asEntity == "omnipanel_elevator")
{
cLux_AddDebugMessage("Use omnitool again");
CathTool_UseOnPanel("omnitool","omnipanel_elevator");
mbFinalDoorOpened = false;
SlideDoor_SetClosed("finaldoor",true);
}

I guess that answers my question. I thought of something else though where there's two elevator doors, and I think that's what FG did at theta labs so that you can see into the elevator, but when you close the doors you can't see out and then it's the end of my level. But that door kept opening then closing just like the first one, but I had to get rid of a few connections and rename the doors and everything until I realized what was wrong with it.
(This post was last modified: 11-26-2015, 05:38 AM by Hypercube.)
11-26-2015, 02:19 AM
Find
Hypercube Offline
Member

Posts: 124
Threads: 20
Joined: Sep 2015
Reputation: 1
#7
RE: Using omnitool.

Oh well, I think that's it though. Just add a ton of lighting effects to make my map look nice, add some decals, possibly change it to the puzzle where you use a terminal to unlock the doors instead. I originally intended this to be for testing, but I may actually release it on the workshop. Maybe instead of several threads asking different questions about this stuff, someone could make one thread that talks about the omnitool and how it works in general.
(This post was last modified: 11-26-2015, 06:20 AM by Hypercube.)
11-26-2015, 04:40 AM
Find
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
Hypercube Offline
Member

Posts: 124
Threads: 20
Joined: Sep 2015
Reputation: 1
#9
RE: Using omnitool.

Thanks, that helps a lot. It would make more sense to do that, so I will probably change it just because. Or I could keep it, but I also was thinking of having the same puzzle Upsilon had, where you take out a tool chip and put it into the omnitool so you can access the door.
Well, I understand how that works now, but I definetely need to work on terminals.
11-26-2015, 08:18 PM
Find




Users browsing this thread: 1 Guest(s)