Difference between revisions of "Using SDL States"

(intactenabler quickscript added)
Line 43: Line 43:
  
 
== Conditional Objects ==
 
== Conditional Objects ==
 +
 +
''Uses global Python script:'' xAgeSDLBoolShowHide
 +
  
 
This is a special type of SDL which automatically shows or hides an object as your age loads. If the SDL state changes the visibility of the object will immediately conform to it. And the best thing is that you don't have to program anything but the SDL change.
 
This is a special type of SDL which automatically shows or hides an object as your age loads. If the SDL state changes the visibility of the object will immediately conform to it. And the best thing is that you don't have to program anything but the SDL change.
Line 80: Line 83:
  
 
== Random Conditional Objects ==
 
== Random Conditional Objects ==
 +
 +
''Uses global Python script:'' xRandomBoolChange
 +
  
 
Remember that random Yeesha page in the Neighborhoods? Or the elusive Bahro stone by the Ferry Terminal? Here is how to make random objects like those.
 
Remember that random Yeesha page in the Neighborhoods? Or the elusive Bahro stone by the Ferry Terminal? Here is how to make random objects like those.
Line 117: Line 123:
  
 
That is all. There is no need to program any Python script since Cyan has already done that for us.
 
That is all. There is no need to program any Python script since Cyan has already done that for us.
 +
 +
 +
== Disabling the hotspot of a clickable ==
 +
 +
''Uses global Python script:'' xAgeSDLIntActEnabler
 +
 +
 +
A quickscript which can be used for clickable objects that should only become clickable once certain conditions are met. For example: The player must pull lever A first in order to power up button B. Or another example: Make a control panel unclickable if someone is already using it.
 +
 +
''Note:'' Requires PyPRP 1.5.0 or higher.
 +
 +
=== Alcscript ===
 +
 +
<pre>
 +
MyObject:
 +
    quickscript:
 +
        sdl:
 +
            type: intactenabler
 +
</pre>
 +
 +
Replace MyObject with the name of your object.
 +
 +
=== SDL variable ===
 +
 +
The Alcscript will automatically create a reference to an SDL variable <object name>Func.
 +
 +
<pre>
 +
STATEDESC MyAge
 +
{
 +
  VERSION 1
 +
 +
    VAR BOOL    MyObjectFunc[1]      DEFAULT=0  DEFAULTOPTION=VAULT
 +
}
 +
</pre>
 +
 +
Again replace MyObject with the name of your object. Setting the SDL Value to 1 makes the object clickable.

Revision as of 15:56, 4 July 2008

Boolean SDL state

If it is simply a state you want to save then you do not have to add anything in Blender. It is just Python and SDL. The SDL file for an on/off state would look something like this.

STATEDESC MyAge
{
    VERSION 1 
    VAR BOOL    MyState[1]   DEFAULT=0
}

DEFAULT=0 will set the variable to 0 when the age is visited for the first time. Note: "MyAge" should be changed to match the name of your age. Also, the SDL file should be named MyAge.sdl and placed in the SDL folder; use PlasmaShop to create and edit SDL files.

Reading an SDL with Python:

           ageSDL = PtGetAgeSDL()
           getSDL = ageSDL['MyState'][0]

Changing an SDL with Python:

           ageSDL = PtGetAgeSDL()
           ageSDL['MyState'] = (1,)


To allow your Python object (or plModifier) to be notified upon any changes in the SDL, you'll need to first initialize the SDL variable within the OnServerInitComplete() method:

           sdl = PtGetAgeSDL()
           sdl.setFlags('MyState', 1, 1)
           sdl.sendToClients('MyState')
           sdl.setNotify(self.key, 'MyState', 0.0)

Then the plModifier's OnSDLNotify() method will be triggered when the variable changes. Here's some sample code to detect a change:

   def OnSDLNotify(self, VARname, SDLname, playerID, tag):
       if (SDLname != "MyAge"):
           print 'SDLname =',SDLname,', not MyAge'
           pass
       elif (VARname == "MyState"):
           ageSDL = PtGetAgeSDL()
           getSDL = ageSDL[VARname][0]


Conditional Objects

Uses global Python script: xAgeSDLBoolShowHide


This is a special type of SDL which automatically shows or hides an object as your age loads. If the SDL state changes the visibility of the object will immediately conform to it. And the best thing is that you don't have to program anything but the SDL change.

AlcScript

MyObject: 
    quickscript: 
        sdl: 
            type: boolshowhide

SDL variable

The Alcscript will automatically create a reference to an SDL variable <object name>Vis. So for the above example your SDL file would look like this.

#==============================================================
# READ:	When modifying an SDL record, do *not* modify the
#	existing record. You must copy and paste a new version
#	below the current one and make your changes there.
#==============================================================

#
# State Description Language for MyAge

STATEDESC MyAge
{
    VERSION 1
	
    VAR BOOL    MyObjectVis[1]    DEFAULT=1 DEFAULTOPTION=VAULT

}


Random Conditional Objects

Uses global Python script: xRandomBoolChange


Remember that random Yeesha page in the Neighborhoods? Or the elusive Bahro stone by the Ferry Terminal? Here is how to make random objects like those.

Note: You need PyPRP 1.4.0 or higher to use this.

Alcscript

MyObject:
    quickscript:
        sdl:
            type: randombool
            region: MyRegion

Replace MyObject with the name of your object and replace MyRegion with the name of your region.

Why do we need a region for this? In a multiplayer environment the object could show up right under the nose of another player. A strategically placed region prevents that. As long as there is a player in the region the visibility state of the object will not change.

SDL variables

STATEDESC MyAge
{
   VERSION 1

# Random object
    VAR BOOL    MyObjectVis[1]       DEFAULT=1  DEFAULTOPTION=VAULT
    VAR BOOL    MyObjectEnabled[1]   DEFAULT=1  DEFAULTOPTION=VAULT
    VAR BYTE    MyObjectChance[1]    DEFAULT=50 DEFAULTOPTION=VAULT
    VAR BOOL    MyObjectProximity[1] DEFAULT=0  DEFAULTOPTION=VAULT
}

Again replace MyObject with the name of your object. You can set the chance variable to any number between 0 and 100.

That is all. There is no need to program any Python script since Cyan has already done that for us.


Disabling the hotspot of a clickable

Uses global Python script: xAgeSDLIntActEnabler


A quickscript which can be used for clickable objects that should only become clickable once certain conditions are met. For example: The player must pull lever A first in order to power up button B. Or another example: Make a control panel unclickable if someone is already using it.

Note: Requires PyPRP 1.5.0 or higher.

Alcscript

MyObject:
    quickscript:
        sdl:
            type: intactenabler

Replace MyObject with the name of your object.

SDL variable

The Alcscript will automatically create a reference to an SDL variable <object name>Func.

STATEDESC MyAge
{
   VERSION 1

    VAR BOOL    MyObjectFunc[1]       DEFAULT=0  DEFAULTOPTION=VAULT
}

Again replace MyObject with the name of your object. Setting the SDL Value to 1 makes the object clickable.