Page 1 of 1

Triggering Python with a Region

PostPosted: Thu Aug 28, 2008 11:25 pm
by GPNMilano
Hey, I know its possible to trigger a python script by entering a region, rather than use a clickable. (Or so I've been told it is) I was just curious as to what the tags are in alcscript for the region itself, as its not picking, is there another setting for a non picking region that activates python?

Re: Triggering Python with a Region

PostPosted: Fri Aug 29, 2008 4:38 am
by Robert The Rebuilder
Here's the AlcScript for the regions in Ahra Pahts that trigger the paging mechanism:

Code: Select all
Portal41To44:
    physical:
        physlogic: detect
    logic:
        modifiers:
          - tag: mod
            flags:
              - multitrigger
            activators:
              - type: objectinvolume
                triggers:
                  - enter
            conditions:
              - type: volumesensor
                satisfied: true
                direction: enter
            actions:
              - type: pythonfile
                ref: $click
        actions:
          - type: pythonfile
            tag: click
            pythonfile:
                file: PahtsPortal
                parameters:
                  - type: activator
                    ref: $mod
                  - type: string
                    value: Portal41To44

Re: Triggering Python with a Region

PostPosted: Fri Aug 29, 2008 6:54 am
by GPNMilano
Thanks Robert, The Volume Sensor tag and conditions was what I was looking for. But I couldn't find it on the alcscript page.

Re: Triggering Python with a Region

PostPosted: Fri Aug 29, 2008 7:10 am
by D'Lanor
And if you need both the enter and exit trigger: viewtopic.php?f=18&t=1550

At home I also have the scripts for a nifty activatorlist (I am currently at work). ;)

Edit: Hmm, I spotted a difference with my script. I wonder if "enter" needs to be specified twice here: under objectinvolume and under volumesensor.

I think I have used scripts with and without those extra lines under objectinvolume and they all seem to work. :?

Re: Triggering Python with a Region

PostPosted: Fri Aug 29, 2008 9:17 am
by GPNMilano
You know, I never thought to ask this, and perhaps I should. With the Python hook file for an age, the hook line is supposed to work like this:

Code: Select all
def __init__(self):
        ptResponder.__init__(self)
        self.id =
        self.version = 1


I always use the same self.id number, is that a problem? Or should each one be unique to an age?

Re: Triggering Python with a Region

PostPosted: Fri Aug 29, 2008 9:53 am
by D'Lanor
I never use the self.id and never had problems. A plasma object id is assigned automatically.

Here is a version I have used recently which has an activatorlist. Not for any reason in particular, just to try something different. :D It does come in handy when you need to call some of Cyan's global Python files.

AlcScript
Code: Select all
Door:
    logic:
        modifiers:
          - name: Enter_Door_Rgn
            cursor: nochange
            flags:
              - multitrigger
            activators:
              - type: objectinvolume
                remote: <door region>
                triggers:
                  - enter
            conditions:
              - type: volumesensor
                satisfied: true
                direction: enter
            actions:
              - type: pythonfile
                ref: :Pyth_Door
          - name: Exit_Door_Rgn
            cursor: nochange
            flags:
              - multitrigger
            activators:
              - type: objectinvolume
                remote: <door region>
                triggers:
                  - exit
            conditions:
              - type: volumesensor
                satisfied: true
                direction: exit
            actions:
              - type: pythonfile
                ref: :Pyth_Door
        actions:
          - type: pythonfile
            name: Pyth_Door
            pythonfile:
                file: <python file>
                parameters:
                  - type: activatorlist
                    refs: ['logicmod:Enter_Door_Rgn', 'logicmod:Exit_Door_Rgn']

The list items must have quotes. Since the script is not under the region object itself I defined the region as a remote. And I had to set the cursor to nochange otherwise it gives the door a hotspot.

Python code
Code: Select all
from Plasma import *
from PlasmaTypes import *
actDoorRegion = ptAttribActivator(1, 'Door region activator')

class <python file>(ptModifier,):

    def __init__(self):
        ptModifier.__init__(self)
        self.named = self.__class__.__name__



    def OnNotify(self, state, id, events):
        if (not state):
            return
        if (id == actDoorRegion.id):
            for event in events:
                if (event[0] == kCollisionEvent):
                    if event[1]:
                        PtDebugPrint('%s: OnNotify: id = %d: Someone entered the region' % (self.named, id))
                    else:
                        PtDebugPrint('%s: OnNotify: id = %d: Someone left the region' % (self.named, id))
                    break

Re: Triggering Python with a Region

PostPosted: Fri Aug 29, 2008 10:36 am
by GPNMilano
D'Lanor, Okay, now here's a question. Exclude Regions are used to warp an avatar from one point to another open being in a region they're not supposed to be. (Like getting warped out from underneath a recently killed Bahro who's falling from the sky). Are exclude regions operational in pyprp yet. Since we're getting close to multiplayer age creation for things like doors, and other objects that are triggered by clickables or regions won't we need to have exclude regions set on these objects to warp any haphazard explorer who decides to, I don't know, play around in the inside of a machine as another explorer sets out to turn the thing on and bake whatever is inside of it till its fried to a crisp?

Re: Triggering Python with a Region

PostPosted: Fri Aug 29, 2008 12:13 pm
by D'Lanor
From what I can see the exregionmod has not been implemented.