This example shows how to conditionally load different versions of your age from different pages. This can be useful for day-night toggles, dry-rainy ages or seasonal ages. The method works more or less like a conditional object, except that it comprises the major part of an age.
In order to remain true to the Minkata scenario a clickable object is used as trigger for the page swap. There is also an optional Minkata type fake link effect.
You will have to edit several files outside of Blender. At least I don't think the current plugin supports customizing the fni and age files (but someone please correct me if I am wrong). Programs you can use for this: UruFun or PlasmaShop.
Step 1: Blender
In Blender you have to create 3 pages. The two pages that you want to toggle and a third page that contains shared objects.
The shared page must contain your link-in point(s) and the clickable trigger object including its clickable region. You may also have to add your horizontal collision plane(s) to the shared page if you experience falling, although in my demo age that did not seem to be necessary.
Your age must also have an AgeSDLHook.
Step 2: The age file
Edit the *.age file that PyPRP creates as follows. Add ,1 to the end of the line that contains your conditional pages. This tells the game not to load those pages by default when the age loads. So if for example you have the pages PageZero and PageOne which you want to toggle you change this:
- Code: Select all
Page=PageZero,0
Page=PageOne,1
Into this:
- Code: Select all
Page=PageZero,0,1
Page=PageOne,1,1
The shared page must remain unaltered.
Step 3: The SDL file
Create a *.sdl file for your age:
- Code: Select all
#==============================================================
# 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 YourAge
STATEDESC YourAge
{
VERSION 1
VAR BOOL SwapPage[1] DEFAULT=0
}
Adapt "YourAge" to the name of your age. If you want you can also rename the variable "SwapPage".
Step 4: The Python code
The code is designed as a template. You only have to adjust the global constants and variables at the top of the file.
- AgeSDLHook
This Python file must have the same name as your age. It is automatically called upon link-in. In the source zipfile it is Swap.py. Variables to adjust are:
SDLName = 'SwapPage' #The name of your SDL variable (see step 3)
sPages = ('PageZero', 'PageOne') #The names of the two toggle pages
sFog = ([0, 1000, 1], [0, 1000, 1]) #The fog density settings of the two toggle pages (in this case similar). Overrides the fni file settings.
sColors = ([0.5, 0.5, 0.5], [0.0, 0.0, 0.0]) #The fogcolors of the two toggle pages. Overrides the fni file settings. - PythonFileMod
This is the Python file that your clickable object calls. In the source zipfile it is SwapButton.py. Variables to adjust are:
clickObj = 'Button' #The name of your clickable object
SDLName = 'SwapPage' #The name of your SDL variable (see step 3)
sPages = ('PageZero', 'PageOne') #The names of the two toggle pages
sFog = ([0, 1000, 1], [0, 1000, 1]) #The fog density settings of the two toggle pages (in this case similar). Overrides the fni file settings.
sColors = ([0.5, 0.5, 0.5], [0.0, 0.0, 0.0]) #The fogcolors of the two toggle pages. Overrides the fni file settings.
linkEffects = 1 #enable/disable effects (0=disabled, 1=enabled)
#tweak the link effects below if needed
kButtonSeconds = 0.1
kFadeOutSeconds = 1.5
kAudioSeconds = 3.0
kIdleSeconds = 6.0
kFadeInSeconds = 1.5
See attachment (swap_source.zip) for the full Python code.