Developement: Quick Question, Quick Answer

Topics about the general development of Orxonox.

Moderator: PPS-Leaders

User avatar
1337
Baron Vladimir Harkonnen
Posts: 521
Joined: Wed Oct 10, 2007 7:59 am

Re: Developement: Quick Question, Quick Answer

Post by 1337 » Thu Jul 07, 2011 8:16 pm

hehe ;)
http://www.xkcd.com/
A webcomic of romance, sarcasm, math, and language.

The Jo
General DuGalle
Posts: 121
Joined: Mon Mar 01, 2010 7:43 pm

Re: Developement: Quick Question, Quick Answer

Post by The Jo » Fri Jul 29, 2011 9:27 pm

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?
Fail. Fail again. Fail better.

User avatar
x3n
Baron Vladimir Harkonnen
Posts: 810
Joined: Mon Oct 30, 2006 5:40 pm
Contact:

Re: Developement: Quick Question, Quick Answer

Post by x3n » Fri Jul 29, 2011 10:38 pm

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") ?>
Fabian 'x3n' Landau, Orxonox developer

The Jo
General DuGalle
Posts: 121
Joined: Mon Mar 01, 2010 7:43 pm

Re: Developement: Quick Question, Quick Answer

Post by The Jo » Thu Apr 12, 2012 10:39 pm

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?
Fail. Fail again. Fail better.

User avatar
x3n
Baron Vladimir Harkonnen
Posts: 810
Joined: Mon Oct 30, 2006 5:40 pm
Contact:

Re: Developement: Quick Question, Quick Answer

Post by x3n » Fri Apr 13, 2012 8:19 pm

hey jo

try this:

Code: Select all

WorldEntity.h:
void detachFromParent()
void attachToParent(WorldEntity* parent)
Fabian 'x3n' Landau, Orxonox developer

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest