PyPRP can easily assign sounds to regions, but wouldn't it be nice if you could trigger other events with a region? Below is the code to hook up a Python script to a region. With Python code we have a wide range of possibilities at our disposal. Anything that can be done with Python can be tied to a region this way.
Only the basic principle is given here. There are no examples but I will probably refer to this small tutorial in other posts.
The Alcscript:
- Code: Select all
<region>:
logic:
modifiers:
- tag: Enter_Rgn
flags:
- multitrigger
activators:
- type: objectinvolume
conditions:
- type: volumesensor
satisfied: true
direction: enter
actions:
- type: pythonfile
ref: $Region
- tag: Exit_Rgn
flags:
- multitrigger
activators:
- type: objectinvolume
conditions:
- type: volumesensor
satisfied: true
direction: exit
actions:
- type: pythonfile
ref: $Region
actions:
- type: pythonfile
tag: Region
pythonfile:
file: <pythonfile>
parameters:
- type: activator
ref: logicmod:$Enter_Rgn
- type: activator
ref: logicmod:$Exit_Rgn
The basic Python code:
- Code: Select all
from Plasma import *
from PlasmaTypes import *
actEnter = ptAttribActivator(1, 'Enter region activator')
actExit = ptAttribActivator(2, 'Exit region activator')
class <pythonfile>(ptModifier,):
def OnNotify(self, state, id, events):
if (not PtWasLocallyNotified(self.key)):
return
if ((id == actEnter.id) and state):
#start enter event here
elif ((id == actExit.id) and state):
#start exit event here