Jump to content

Scripting Food Dispensers


Ceilidh Noel
 Share

You are about to reply to a thread that has been inactive for 845 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

hi everyone!

i have a couple of questions and i hope this is the right place to ask them, but i think it is scripting-related.  i have some scripting knowledge, and i know i could hire a scripter, but i want to try to make it myself so i learn and get better at scripting.

#1. i'd like to make some drink dispensers that would show a glass being filled up. like a lemonade machine where the glass drops down, you can see and hear it being filled and then the finished glass auto-attaches to them.

#2.  i would like to have food or drinks that disappear as the person is eating/drinking it. i've seen this before with various products, but i can't figure out how it's accomplished.

#3. which script would i need that allows someone to hold a tray of food that can then be touched by another av to auto-attach food/drinks to that person? i'd like to use these for severs at parties to hold trays where the food can be clicked and auto-attached.

i know it's a lot, but if anyone could point me in the right direction of the processes behind the aforementioned things, i'd really appreciate it. i don't necessarily want someone to make the scripts for me, because i'll never learn that way... just more so how these things are accomplished so i have a direction to go in. but, if anyone knows of any existing LSL scripts that can do these things then i'd appreciate those, too. lol i don't need to reinvent the wheel.

thanks!

-ceilidh

 

Link to comment
Share on other sites

That's how we all learned, by taking on a challenge that's a bit over our heads and struggling until we succeed.  There are several ways to handle your first two questions, but I think the easy way is to design the glass with a second glass buried between its inside and outside surfaces.  Color that second one so that it looks like lemonade or whatever.  Then script the object to change the vertical (Z) dimension of the colored glass so that it's close to zero when you want the glass empty and is larger when the glass is supposed to be filled (or partially filled).  You'll have to write the script to listen to signals from the lemonade machine and an attachment on the user to tell it when to change that dimension.  Mildly tricky, but not daunting.

The third question is not hard at all.  Just make your tray with all of the food items on it, but make all of them transparent by default. Then script the tray to make specific items non-transparent when someone clicks the tray and gets a menu option.  Take a look at llDialog in the LSL wiki for how to do the menu part or consult any of the dozens of scripts in the LSL Library forum that have clever approaches for scripting menus.  I suggest putting a timer in your script to make the food items transparent again after a while (and when the tray is re-attached).

Edited by Rolig Loon
typos. as always.
  • Like 1
Link to comment
Share on other sites

  • 1&2, There are various ways of making an object 'change' as something happens to it, but the two that are generally easiest (and least lag inducing*) are changing textures and prim parameters. for the glass of liquid, I'd go with Rolig's suggestion of having the liquid be some sort of cylindrical prim, I would change its PRIM_SLICE parameter rather than its scale though, as that would make it easier to have a tapered glass. For something like say, a doughnut that you eat, the 'most impressive' way to do it would be to have the mesh model specifically built with materials laid out so you can turn parts of it invisible revealing the sections with a bite taken out of them.
  • 3. temp attaching an object is mildly involved. The way I would do it is this:
    • patron touches a thing on the serving tray, and the tray's script saves their key to a global variable, then rezzes an invisible copy of the food item from its inventory.
    • in the object_rez event of the tray, send a message to the rezzed food object what the key of the person to attach to is.
      • Note: You need to make sure the script in the inventory of the object is already running and has the listener open.
      • or alternatively, send an 'I'm awake' message from the rezzed item back to the tray to ensure the listener is open to receive the 'who to attach to' message.
    • when the rezzed food item hears the message (listen event) it should request permisisons, or request experience permissions of the person to attach to
    • if experience permissions succeed then llAttachToAvatarTemp to the avatar, if it fails, request regular permissions,
    • if regular permissions fail, llDie()
    • in the on_attach event turn the object visible.
  • Like 2
Link to comment
Share on other sites

1 hour ago, Quistess Alpha said:

I would change its PRIM_SLICE parameter rather than its scale though, as that would make it easier to have a tapered glass.

Yes, I agree.  That would be a more sensible design, and no harder to script than changing the vertical scale.

I misread the third challenge, assuming that the tray's owner is supposed to be adding things to the tray one at a time, or that some caterer is going to be touching the tray to add them. Your answer correctly sees the challenge from the other end.  A server carries the full tray and people touch items to claim then and then eat/drink.  The heart of the method you are suggesting is in the last two example scripts at https://wiki.secondlife.com/wiki/LlAttachToAvatarTemp#Examples.  The trick in both of them is that in order to activate a drinking/eating animation when the new owner gets the food item, you have to request permissions twice.  That's mildly clumsy for users unless you script the whole thing in an Experience, but the basic approach to scripting remains the same whether you have an Experience or not.

Edited by Rolig Loon
typos. as always.
  • Like 2
Link to comment
Share on other sites

this is great! thank you both for pointing me in the right direction!

i'm finally at the point where i'm learning how to use blender (thanks to the builder's brewery classes i've been taking!) and  i feel comfy enough to tackle these projects from a scripting perspective. your tips will be invaluable to me, so i really appreciate it.

for the server tray, ideally i'd like the food on the tray to be removed from the tray as someone takes a glass or hors d'ouvre from it. i have a plate of sample cookies i sit out at my cafe where people can take a cookie and it leaves the tray, but i wasn't sure how to do this when another av is actually holding the tray.

i have a few auto-attaching dispensers now and instead of rezzing the item, i just added it to myself and tested it with some friends to see if the food attached to them and it worked! now  i just need to figure out how to have whatever they select also disappear from the tray.

once again, thank you both for this insight, it'll help me a lot. i just have to learn how to use blender so i can create the objects i need for questions #1 and #2, but at least now i know how these tasks can be accomplished. your help is much appreciated!

 

Edited by Ceilidh Noel
  • Like 1
Link to comment
Share on other sites

10 hours ago, Ceilidh Noel said:

i just need to figure out how to have whatever they select also disappear from the tray.

the easiest way would just be to make them invisible; if it were me, I'd have the attached food item say something like "I'm food item #2" (but in a way that's easier to parse) then when the tray hears it, turn that link#* invisible. (Actually I'd have a list which translates food# to link#, I.E llList2Integer(gFoodLinks,N) == <the link number for the Nth food item>)

  • Like 1
Link to comment
Share on other sites

29 minutes ago, Quistess Alpha said:

the easiest way would just be to make them invisible; if it were me, I'd have the attached food item say something like "I'm food item #2" (but in a way that's easier to parse) then when the tray hears it, turn that link#* invisible. (Actually I'd have a list which translates food# to link#, I.E llList2Integer(gFoodLinks,N) == <the link number for the Nth food item>)

 

okay.. that sounds like a solution. and i understand how it would work.

i'm slowly but surely getting the hang of this.

thank you!!

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 845 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...