Page 1 of 2

Logic scripting and one shot animations

PostPosted: Mon Jan 07, 2008 2:24 pm
by Trylon
So, I have another small piece of info for you.
I just got use of predefined animations working in pyprp.


But let me start by giving a current status update:
- Drawablespans rewrite - complete
- Physical rewrite - complete
- resmanager rewrite - virtually complete
- logical scripting support - pretty well done
- camera regions - broken atm
- swim regions - broken atm

One of the pieces in that list is "logical scripting support" - basically it's an advanced way of creating sets of logic objects for uru, and link them to a python script, or other actions. That's the one that also does the animations.

Until now, such support has always been minimal - examples of it are the basic support for clickable regions - that didn;t allow for much flexibility when interfacing with already existing classes, and the footstep sound that was a very rough implementation of the system.

Of course, the logic scripting must be done in alcscript.
A few working examples of the code:

Code to make a footstep region like cyan does:
Code: Select all
RgnFootstepSfxMetal:
    logic:
      modifiers:
       - tag: Enter
         flags:
          - multitrigger
         activators:
          - type: objectinvolume
            triggers:
         conditions:
          - type: volumesensor
            direction: enter
         actions:
          - type: responder
            ref: /
      
         - tag: Exit
         flags:
          - multitrigger
         activators:
          - type: objectinvolume
            triggers:
         conditions:
          - type: volumesensor
            direction: exit
         actions:
          - type: responder
            ref: /
         
      actions:
       - type: responder
         responder:
            states:
             - cmds:
                - type: armatureeffectmsg
                  params:
                     surface: stone
                     append: false
                  waiton: -1
               nextstate: 0
               waittocmd: 0
            curstate: 0
            flags:
             - detect_trigger

The more knowledgable readers may notice that this code actually builds up a respondermodifier and messages according to given specifications.

Code to link an object to simple SDL:
Code: Select all
Gate:
   logic:
      actions:
       - type: pythonfile
         pythonfile:
            file: xAgeSDLBoolShowHide
            parameters:
             - type: string
               value: GateVis
             - type: bool
               value: True

As you can see, you can customize the python arguments that are used

A region that starts a oneshot animation when you enter it (with the objects own origin as the seekpoint):
Code: Select all
OneShotTest:
   logic:
      modifiers:
       - tag: Detect
         flags:
          - multitrigger
         activators:
          - type: objectinvolume
            triggers:
             - enter
         conditions:
          - type: volumesensor
            direction: enter
         actions:
          - type: oneshot
            ref: /
      actions:
       - type: oneshot
         oneshot:
            animation: PushButton

Yes - this means that doing the buttonpress and other animations is finally possible :)

Code for a clickregion:
Code: Select all
GateButton:
    logic:
        modifiers:
          - cursor: poised
            flags:
              - localelement
            activators:
              - type: objectinvolume
                remote: GateBtnRegion
                triggers:
                  - any
            conditions:
              - type: activator
                activators:
                  - type: picking
              - type: objectinbox
                satisfied: true
            actions:
              - type: pythonfile
                ref: /
              - type: oneshot
                ref: :OneShotButtonPush

        actions:
          - type: pythonfile
            pythonfile:
                file: FuncChk01Clickables
                parameters:
                  - type: activator
                    ref: logicmod:/
                  - type: string
                    value: GateButton
                  - type: behavior
                    ref: oneshotmod:OneShotButtonPush

A bit more complex, as it also refers to the oneshot mod defined below, though references

Code for a simple one shot mod - the object on which it is defined is the seekpoint:
Code: Select all
OneShotClickBtn:
   logic:
      actions:
       - type: oneshot
         name: OneShotButtonPush
         oneshot:
            animation: DoorButtonTouch
            seektime: 1.0


I don't have time to explain it in detail at the moment, but perhaps it helps to wet the appetite of some of the more knowledgable writers :)

Re: Logic scripting and one shot animations

PostPosted: Mon Jan 07, 2008 2:43 pm
by Marcello
Big /cheer!!!

Re: Logic scripting and one shot animations

PostPosted: Mon Jan 07, 2008 2:50 pm
by Chacal
Awesome.
This is several steps towards the capability for a library of easy-to-use common objects (buttons, doors, books, etc).

Re: Logic scripting and one shot animations

PostPosted: Mon Jan 07, 2008 2:58 pm
by Nadnerb
Awesome! :D

Question: can a responder 'action' include an SDL change message, or do we have do run a python script to do that?

Re: Logic scripting and one shot animations

PostPosted: Mon Jan 07, 2008 3:00 pm
by Trylon
Not at the moment, but I'm sure there is a message for that somewhere that we can implement for that :)
Adding a new message to the responder code is really easy, so the number of usable messages should grow as we understand more..

EDIT:
Yes, there appears to be a message for that, but we don't understand its format yet.

Re: Logic scripting and one shot animations

PostPosted: Mon Jan 07, 2008 3:57 pm
by Aloys
Alcscript look all kind of great because it allows for many new things, but I have an itching feeling that the learning curve will be kind of steep at first :)
Even if someone (Robert?) writes a convertion script for existing Ages, we'll have to learn it. You'll have fun writing the needed tutorials.. :p

Re: Logic scripting and one shot animations

PostPosted: Mon Jan 07, 2008 4:26 pm
by Trylon
Yes, I agree that thed scripts aboved look pretty complex.
But please understand that these scripts are the "power user" versions.

Honestly, having to put up an entire script just to set one footstep region is quite a bit of overkill.
I'm planning a set of so called "quickscripts" to make setting commonly used scripts simple.

Basically they would be simple settings, that are internally entered into a template for scripts like the ones I showed above.
It could look as simple as this:
Code: Select all
<object name<
    quickscripts:
      - type: footstepregion
        surface: metal

Or it could even be a logic property.

And that information would internally be fed into a template resembling the first script in my above post.
The scripting system actually makes it easier to provide such templates, and bugfixing tham than the very static system we used before.

Re: Logic scripting and one shot animations

PostPosted: Mon Jan 07, 2008 4:48 pm
by Aloys
this is good news I was starting to worry.. ;)
However if I understand everything correctly we'll need a script for each object, do you envision a simple way to apply a script to several objects? For instance right now it's easy and fast to copy/paste properties for objects.. Say I have twenty footsteps regions in an Age that all use the same footstep sounds, would I have to create by hand a script for each one?

Re: Logic scripting and one shot animations

PostPosted: Mon Jan 07, 2008 7:25 pm
by Paradox
Just so that this exists in some form so that someone will stumble upon it when writing the tutorial:

The position of the seek point is exactly 2 blender units away from the "clickable" (door, journey cloth, etc.). The clickable should be approximately 4 units above the level of the seek point. The seek point should be level with the ground/surface upon which the avatar stands.


To be honest... I'm not quite sure what would happen if you had a seek point above the ground... but that's one of those crazy things that I'm going to have to try at some point :D

Re: Logic scripting and one shot animations

PostPosted: Mon Jan 07, 2008 9:49 pm
by Grogyan
One step closer to animations, one step closer to a unified library of objects, sounds, animations and scripts