Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Do while and collision

Nickola Martynov
Registered User
Join date: 1 Aug 2007
Posts: 60
06-29-2008 16:17
Hello everyone,

I'm new to working with physical objects and I've spent the weekend writing a script to make a party balloon bob up and down. It works great - right up until an avatar collides with the balloon. I wrote a collision event to put the balloon back in it's initial position and rotation, but the script doesn't call that event for some reason that I can't fathom.

After an av runs into the balloon, it bounces around wildly for a while (I have them contained in my workshop) but continues to bob as commanded by the loop ignoring the collision all together.

The setup of the script is like this:

global variables:
pos
rot


balloon()
do
SetHoverHeight command with llFrand calculation to make it bob - this works fine
while

default

state_entry
sets physics to true
puts balloon at initial hover height
sets buoyancy

//I tried putting in llCollisionFilter("", NULL_KEY, FALSE) in the state_entry event, but that didn't make a difference.

touch event
takes current position and rotation - it will tell me these coordinates in chat
calls balloon()

collision event
commands llSetPos and llSetRot to return the balloon to the coordinates taken in the touch event
calls balloon()

A command to chat "I've been hit" in the collision event doesn't happen, though if I walk into the object before it's been touched, chat tells me that the event was called, but the pos and rot variables are empty so the object still floats around.

Is there something I need to add to the loop to have it recognize a collision?

Thanks for any help you can provide.
Nexii Malthus
[Cubitar]Mothership
Join date: 24 Apr 2006
Posts: 400
06-29-2008 17:04
The problem is that is stuck in the loop, it can never get execution time to process the event queue for the collision event.

I'd advise to run a timer-based loop, and also because a never ending while loop is the abomination of pure evil and lag.
_____________________

Geometric Library, for all your 3D maths needs.
https://wiki.secondlife.com/wiki/Geometric

Creator of the Vertical Life Client
Nickola Martynov
Registered User
Join date: 1 Aug 2007
Posts: 60
06-29-2008 17:32
Thanks Nexii.

An event queue....who knew? :-)

I moved the bobbing sequence into a timer event and the touch event sets the timer. It's now calling the collision event after I run into it. It's chatting the message at me -- over and over as it bounces around -- but it's not returning the balloon to it's original coordinates and the bobbing quits all together.

<sighs>
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
06-29-2008 17:34
From: Nexii Malthus
a never ending while loop is the abomination of pure evil and lag.


non related to the op but

when i started scripting for the sony psp, the very first thing they do is stick in a non ending loop (while TRUE do) and i kept getting red flags flashing in my mind, how can this be okay? is this not just asking for the third layer of hell to explode in my face? do these people even know what that loop does???

and after a while i know, its pure freakin evil on any system