Page 2 of 2

Re: Developement: Quick Question, Quick Answer

Posted: Thu Jul 07, 2011 8:16 pm
by 1337
hehe ;)

Re: Developement: Quick Question, Quick Answer

Posted: Fri Jul 29, 2011 9:27 pm
by The Jo
XML-Question: How can I catch the event, when a pawn died? The following attempt doesn't work.

Code: Select all

     <EventTrigger name="PawnDied1" >
        <events>
            <trigger> 
                <Pawn health=30 position="0,0,0" direction="0,-1,0" collisionType=dynamic mass=100000>
                    <attached>
                        <Model position="0,0,0" mesh="crate.mesh" scale3D="3,3,3" />
                    </attached>
                    <collisionShapes>
                        <BoxCollisionShape position="0,0,0" halfExtents="15,15,15" />
                    </collisionShapes>
                </Pawn>
            </trigger>
        </events>
    </EventTrigger>
I tried to adapt the code from theTimeMachine.oxw (here the timemachine effect is stopped when you successfully kill a bot), but missed something, since no text is displayed when I destroy the pawn created above.

Code: Select all

    <SimpleNotification message="Display some text.">
        <events>
            <trigger>
                <EventListener event=PawnDied1 />
            </trigger>
        </events>
    </SimpleNotification>
I have to admit that I don't undestand the example in the wiki.

Code: Select all

        <EventTrigger invert="true">
            <events>
                <trigger>
                    <TriggerBase ... />
                    <EventListener ... />
                </trigger>
            </events>
        </EventTrigger>
What is meant by <TriggerBase ... />? Why is an additional <EventListener ... /> needed?

Re: Developement: Quick Question, Quick Answer

Posted: Fri Jul 29, 2011 10:38 pm
by x3n
Hum, it't quite a while since I worked with events...

There's a test level "events.oxw" which shows some basic event stuff with comments. I hope that explains the general ideas behind the event system.
The Jo wrote:I have to admit that I don't undestand the example in the wiki.

What is meant by <TriggerBase ... />? Why is an additional <EventListener ... /> needed?
Ah wow, don't worry if you don't understand it, I didn't even know we have a wiki entry for this :shock:
Well I guess TriggerBase is just a generic name for any trigger. DistanceTrigger, EventTrigger, etc.
EventListener is not needed, the example shows that the same event can be triggered by two sources independently, the trigger and an event listener. You can use only a trigger or only a listener... or both... or 2 triggers and 5 listeners :)


Now to your other question, I don't know why this doesn't work, it looks ok. However you don't need EventTrigger and EventListener in this simple case, simply passing the event from the Pawn to SimpleMessage should be enough:

Code: Select all

    <SimpleNotification message="Display some text.">
        <events>
            <trigger>
                <Pawn health=30 position="0,0,0" direction="0,-1,0" collisionType=dynamic mass=100000>
                  ...
                </Pawn>
            </trigger>
        </events>
    </SimpleNotification>
But I'm not exactly sure how SimpleNotification works... maybe you have to include the notification framework?
See the timemachine level for details, there's this line:

Code: Select all

    <?lua include("includes/notifications.oxi") ?>

Re: Developement: Quick Question, Quick Answer

Posted: Thu Apr 12, 2012 10:39 pm
by The Jo
Is it easily possible to detach a worldentity from its parent and attach it to another parent?

Context:
I would like to perform this transition when a TetrisBrick (which consists of many TetrisStones which are attached to the TetrisBrick) touches the ground or any other obstacle.
The stones which had been attached to the brick should now be attached to the TetrisCenterpoint which would allow me to reuse some of the old code.

So far I tried to perform this via WorldEnity::detach() and the WorldEnity::attach() function.
detach() throws "cannot detach an object that is not a child"
Is it necessary first to detach all objects attached to a TetrisStone (a model, some cameras and problably more) in order to perform this transition manually via detach() or is there any practical solution?

Re: Developement: Quick Question, Quick Answer

Posted: Fri Apr 13, 2012 8:19 pm
by x3n
hey jo

try this:

Code: Select all

WorldEntity.h:
void detachFromParent()
void attachToParent(WorldEntity* parent)