Pahts does it exactly the same way. It seems there is no need to change the camera there.
If you want to make this a global file the timing parameters should not be hardcoded. Especially since the required delay seems to be variable. The parameters should be passed to Python by the prp file like this:
- Alcscript Show Spoiler
- Code: Select all
<object name>:
logic:
actions:
- type: pythonfile
tag: gospawn
pythonfile:
file: xFakeLink
parameters:
- type: activator
ref: logicmod:<activator name>
- type: sceneobject
ref: scnobj:<destination object>
#fade out
- type: float
value: 1.5
#delay
- type: float
value: 0.5
#fade in
- type: float
value: 1.5
- type: sceneobject
ref: scnobj:<first person camera>
- type: sceneobject
ref: scnobj:<destination camera>
- type: responder
ref: <sound responder>
And xFakeLink.py could be:
- Python Show Spoiler
- Code: Select all
from Plasma import *
from PlasmaTypes import *
actRegion = ptAttribActivator(1, 'Region activator')
objSpawnPoint = ptAttribSceneobject(2, 'Spawn point object')
fltFadeOut = ptAttribFloat(3, 'Fade out time', 1.5)
fltDelay = ptAttribFloat(4, 'Delay time', 0.1)
fltFadeIn = ptAttribFloat(5, 'Fade in time', 1.5)
camFirstPerson = ptAttribSceneobject(6, 'First person camera (optional)')
camDestination = ptAttribSceneobject(7, 'Destination camera (optional)')
respLinkSound = ptAttribResponder(8, 'Fade in link sound (optional)')
class xFakeLink(ptModifier):
def __init__(self):
ptModifier.__init__(self)
self.version = 1
minor = 0
print ('__init__%s v. %d.%d' % (self.__class__.__name__, self.version, minor))
def OnNotify(self, state, id, events):
if ((id == actRegion.id) and state):
if (not PtWasLocallyNotified(self.key)):
return
PtFakeLinkAvatarToObject(PtGetLocalAvatar().getKey(), objSpawnPoint.value.getKey())
PtFadeOut(fltFadeOut.value, 1)
PtAtTimeCallback(self.key, fltFadeOut.value, 1)
def OnTimer(self, id):
if (id == 1):
if (type(camFirstPerson.value) != type(None)): # To make it optional
virtCam = ptCamera()
virtCam.save(camFirstPerson.sceneobject.getKey())
PtAtTimeCallback(self.key, fltDelay.value, 2)
elif (id == 2):
if (type(camDestination.value) != type(None)): # To make it optional
virtCam = ptCamera()
virtCam.save(camDestination.sceneobject.getKey())
PtFadeIn(fltFadeIn.value, 0)
if len(respLinkSound.value): # To make it optional
respLinkSound.run(self.key)
# paste glue section here
All the added parameters are optional. Only the first 2 parameters (activator and destination object) are required. If age creators do not use the time parameters Python will use the defaults. If they skip the cameras or the sound responder that is fine too. Skipping a parameter in Alcscript can be done with: - type: skip
I have not tested this so don't put it in the Offline KI just yet.
I don't know if dendwaler wants to test this. If he is already happy with his current fake link this may just be a little too much.
