Toggling A State

From OpenUru
Jump to: navigation, search

There is a easy way to make sure things that have been changed or altered in your Age by one player, stay that way if they link out and back in, or if another player shows up after the action has been done.

Let's use a door as a simple example.

You have a door that slides open when the player clicks on a button. You've made the door to where it stays open unless the player clicks on the button again (either because you are using 2 different responders, one for opening and one for closing, or your responder is a 2 state responder).

Unless you have a SDL state for that door, and unless it's been "toggled", when the player links out and then comes back later, they will find the door closed. Worse, the player opened the door and is in the room exploring. His friend, Player 2 links in, and says, "Hey! Where are you?" and get's told that his friend is through the open door, only Player 2 doesn't see a door open. For them, the door is closed.

We fix this by having a SDL file, with states for the objects. Let's look at Neolbah's SDL file:


    VERSION 20 # multiplayer adjustments
# Elevator Door Puzzle

    VAR INT    neolButtonsPushed[1] DEFAULT=0
    VAR BOOL    neolDoorUnlocked[1]    DEFAULT=0
# Animation States

    VAR BOOL    neofdoor1Unlock[1]    DEFAULT=0
    VAR BOOL    neofdoor2Unlocked[1]    DEFAULT=0

# KCP Camera Push

	VAR BOOL	CDPboolOperated[1] DEFAULT=0
# Elevator State Mechanics
    VAR BOOL    neolElevatorToggle[1] DEFAULT=0

For now, pay attention to where it says "VAR BOOL neofdoor1Unlock[1] DEFAULT=0"

Now let us look at the components I have assigned to that door in Max:


Notice how I have a Python file component attached to it. I then said to use "" as the python file.

You'll see in the roll outs for it, it has a button for the "Activator" and a text box for the "Age SDL Var Name". The "Activator" can be your clickable button, or even a sensor region. The "Age SDL Var Name" will be the name of your SDL variable that you put in the Age's SDL file. In my case it's neofdoor1Unlock.

What happens is, Player 1 clicks on the button to open the door, not only does the responder to open the door happen, but the SDL variable in the SDL file will be toggled from 0 to 1.

Now, you may have noticed, I had a 2nd Python file component attached to the door too. Here it is:


You'll see that I assigned the Global Python file called "" to it.

In the roll outs, you'll see that Age SDL Var Name again. I put the same name as the one for the door in my SDL file. You will also see 2 buttons: Run if bool true, and Run if bool false. These are the responders that you want the game to run depending upon the state of the SDL variable.

If you have 2 different responders, one to open and one to close, then you'd put the correct responder where it goes (the door toggled the SDL variable to 1 or True when the door was opened, so we want the Close responder to run when true.).

If you have a 2 state responder, this will still work, put the same responder on both buttons.

If Player 2 were to link in after his buddy opened the door, he'll see it open already. If he goes and clicks on it, the SDL variable will get toggled again and will change it back to a 0 or False.

In the check mark boxes, you need to put a check where it says F-Forward On Init. You don't need one in the other boxes, unless you are paging your Age files. If you are doing that, you should put a check mark where it says "Init SDL On First Update"

Paging is where you have different prp files that do not load up until the player links there. The City on MOUL:a does this, as the different areas of the city are on different pages.

That is pretty much all there is to it. There are other things you can do to get other results.

Return To: 3DS Max Plugin Tutorials

Copyright (C) 2011 Andy Legate.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included in the section entitled "GNU Free Documentation License".