Important! Please read the announcement at http://myst.dustbird.net/uru-account.htm
Also! Please read the retirement announcement at http://myst.dustbird.net/uru-retirement.htm

Difference between revisions of "Toggling A State"

From UamWiki
(Created page with '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 aft…')
 
 
Line 42: Line 42:
 
Now let us look at the components I have assigned to that door in Max:
 
Now let us look at the components I have assigned to that door in Max:
  
[[File:Boottog1.jpg]]
+
[[File:Booltog1.jpg]]
  
 
Notice how I have a Python file component attached to it. I then said to use "xAgeSDLBoolToggle.py" as the python file.
 
Notice how I have a Python file component attached to it. I then said to use "xAgeSDLBoolToggle.py" as the python file.

Latest revision as of 20:19, 5 May 2011

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:

STATEDESC Neolbah

{
    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
	VAR INT		CDPOperatorID[1] DEFAULT=-1
    
# 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:

Booltog1.jpg

Notice how I have a Python file component attached to it. I then said to use "xAgeSDLBoolToggle.py" 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:

Booltog2.jpg

You'll see that I assigned the Global Python file called "xAgeSDLBoolRespond.py" 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: Andy's Max Tutorials