After all that clothes-making I got hungry.
Well, not really. But I had a thing I wanted to figure out. How to make food that gets consumed.
Wherein I make the animations
First, I needed an animation. Back to Qavimator.
This time, I left the left arm, the pelvis, and the legs entirely untouched. Doing this, SL lets the previous animation control those parts of the body - so if the avatar is standing, it remains standing. Sitting, it remains sitting. Dancing, it remains dancing.
I set the right arm up to 90 degrees or so, as the first frame of the animation. By doing this, SL is cued to bring the arm up as part of the ease-in process. I also leaned the body forward just slightly, from the abdomen.The animation itself brings the arm up to the mouth, and leans the body forward slightly to the arm. As with the curtsey, every movement starts from the far end - the abdomen for the leaning forward, the shoulder for the arm. The upper body rotates very slightly as well. Then the animation leans back most of the way, and lowers the arm back to 90 degrees: back to the start position.
I uploaded the animation, setting the in and out percentages to 100%, with a high-ish ease in and no ease out. This means that when the animation is triggered, SL has a fair bit of time to bring the arm and body to the start position of the animation, and SL will leave the avatar in the animation position at the end of it - rather than having the avatar drop the arm back down. If the Av is holding a drink, that'd look really crazy!
I also made another animation: just a single frame. Gave it no ease in, and a slow ease out. The single frame is the start/end position of the eating/drinking animation. This is my 'resume previous animation' animation.
A script is born
So how to use this animation? Here's where scripting comes in. My initial plan was to have the script belong in a parent object, which would spawn a child, attach the child to the avatar's right hand, set the animation to run a few times, then destroy the child.
But it turns out that that plan won't work. Instead, I have a parent object (teapot, bread loaf, beer keg) which hands out a child object (teacup, slice of bread, mug of beer). The child object gets put in the avatar's inventory, and the parent asks the avatar to 'wear' the child. I wish it didn't have to be that way, but that's probably part of anti-griefing.
So the child object, when it's attached, starts the eating/drinking/smoking/whatever animation. (The animation works for anything that involved bringing the hand to the mouth.) My first run did it four times, thirty seconds apart.
Then I tried to have the child object destroy itself. But llDie won't work on anything that's attached, and once an object is in an inventory, its script stops. Instead, I have it put itself in a 'dead' state, where it will llDie if its rezzed, and llDetach if its detached.
I tried to have it change its name, too. I was working with bread, so I tried to get it to rename to 'bread crust'. But something which is attached won't change its name, and once it detaches - once again - the script can't run. ARGH!
It's not all a loss. I made objects - simple stuff for script testing, plywood spheres and half-spheres - and tested the script over and over while working on it, till I got it right. Then I did a funky-cool thing. I worked out how to script the object to reshape itself. At the first bite, it lost a quarter of itself. And kept losing a quarter of itself each bite. Yay!
I make a loaf of bread
Now for the building and texturing part of this: I figured out that a sphere, deformed with a dimple, textured with Brushed Brass, speckled with stucco, and tinted brown, looks a lot like a roll of brown bread. Only, if you look at it up close, it has lines across it. But from a short distance .. yay!
Further playing with library textures has revealed several library textures which look like the outside, or the inside, of a brown or white bread roll - even up close. And the dimpled sphere continues to look bread-roll-ish.
Though I want to play with sculpties now, get a better 'bread' thing. And I need to work out how to use script the change in sculpties, from 'unbitten' to 'one bite' to 'two bites', and so on.
The script is improved
A friend (Rose Mackie) heard me talking about my bread roll, and begged me to make a version of it for her. So I sat down and polished the script. I took out the 'change the shape' part, because she wanted to use it for drinks, and cutting quarters out of a cup makes no sense.
Then I made it configurable, with a notecard. The name of the child object, the text the parent object says as it hands stuff out, the text the child object says when the sequence starts, the text the child object says when the sequence finishes.
Learning to read and parse the notecard took me a lot longer than I expected it would. But it's okay, it's stuff I'll use a lot.This version was still four animations, thirty seconds apart. And it was during writing this that I developed the 'arm-releasing' animation.Rose was thrilled with the animation and the script, and I sold her the copies for her teasets.
I am insane
The next evening, however, I was unhappy with the script. I wanted to include randomness: having the avatar take sips that aren't precisely 30 seconds apart. I wanted to make it more configurable - everything which can logically be configured should be able to be.
And then when I was playing, I found that despite hours of testing the script the previous day, SL sometimes told me I didn't have permission to attach - during the detaching stage.
So I spent almost an entire day on the script.
It now checks to see if it has the permissions it needs, requests the permissions, and checks again. If it doesn't have permissions, it whinges and goes into its 'dead' state.
It now takes 'sips' or 'bites' or 'drags' or whatever, at random intervals.
It will now reset itself if it is rezzed in the wrong state (except for the dead state).
It now reads a hell of a lot more configuration options, including maximum and minimum times for the random intervals, the number of 'sips' to be taken, the name of the child object, the name of the object the child will become when it's finished*, which animations to use, the messages to give the user at each stage, and the message to give the user if permissions aren't granted.
* not that I've beaten the problem that I can't rename it. But if that bug is ever resolved, the script should magically start doing it!
Finally, I wrote a more detailed set of instructions and an example configuration for the script.
I have figured out that some terrain textures make great bread textures. Working on those now.
* Figure out a bread texture I'm really happy with.
* Figure out a way to let users configure 'untouched', 'partly eaten' and 'finished' objects for the script, without dumping multiple objects into the eating-avatar's inventory, without making users write shape-changing code, and without me writing shape-changing code individually for each user.
* Make a shape-changing version for myself.
* Make a sculptie-friendly shape-changing version.
Just how do you identify an alt online?
4 months ago