Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Need help with adding a menu

Bridget Leavitt
Registered User
Join date: 17 Dec 2006
Posts: 12
07-12-2008 19:00
Hiya!

I want to make a "heart bomb" that when you throw it, it rezez a smaller heart that is set up on a timer to "explode" and rezzes out other tiny prim hearts.
I have all that set and working OK.

But now I'm' stumped and Id like to add a menu so by clicking the heart you hold in your hand, the menu will give you options for setting the timer from 5sec - 10sec - 20sec for the rezzed heart that "explodes".
Where and how do i add a Menu for this?

Thanks for any help!

~ B


--------------------------
The Heart exploder/rezzer -
------------------------


default
{

state_entry() {
llSetTimerEvent(10.0);
}
timer() {
llMakeExplosion(20, 9.0, 2, 15.0, 1.0, "Red smoke", ZERO_VECTOR);
llPlaySound("I love you",5.0);
llRezObject("small heart", llGetPos() + <-5.0,0.0,0.0>, <0.0,0.0,0.0>, <0.0,0.0,0.0,0.0>, 0);
llRezObject("small heart", llGetPos() + <0.0,3.0,0.0>, <0.0,0.0,0.0>, <0.0,-7.0,0.0,0.0>, 0);
llDie();



}
}






---------------------------
And the throw script I'm using
---------------------------


integer have_permissions = FALSE;
fire()
{
rotation rot = llGetRot();
vector vel = llRot2Fwd(rot);
vector pos = llGetPos();
pos = pos + vel;
pos.z += 0.75;
vel = vel * 15;
llStartAnimation("throw_r";);
llSleep(1);
llRezObject("Big Heart", pos, vel, rot, 0);
llSetTimerEvent(5);
}
default
{
state_entry()
{
key owner = llGetOwner();
llListen(8,"",owner,"r";);
if (!have_permissions)
{
llRequestPermissions(llGetOwner(),PERMISSION_TRIGGER_ANIMATION| PERMISSION_TAKE_CONTROLS);
}
}
listen(integer channel, string name, key id, string message)
{
llResetScript();
}
on_rez(integer param)
{
}
run_time_permissions(integer permissions)
{
if (permissions == PERMISSION_TRIGGER_ANIMATION| PERMISSION_TAKE_CONTROLS)
{
llTakeControls(CONTROL_ML_LBUTTON, TRUE, FALSE);
have_permissions = TRUE;
}
}
attach(key attachedAgent)
{
if (attachedAgent != NULL_KEY)
{
llRequestPermissions(llGetOwner(),PERMISSION_TRIGGER_ANIMATION| PERMISSION_TAKE_CONTROLS);
}
else
{
if (have_permissions)
{
llStopAnimation("hold_R_rifle";);
llStopAnimation("aim_R_rifle";);
llStopAnimation("hold_R_handgun";);
llStopAnimation("aim_R_handgun";);
llReleaseControls();
llSetRot(<180,0,0,8>;);
have_permissions = FALSE;
}
}
}
control(key name, integer levels, integer edges)
{
if ( ((edges & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON) &&;((levels & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON) )
{
fire();
}
}
touch_end(integer num)
{
if (have_permissions)
{
;
}
else
{
llWhisper(0, "wear me";);
}
}
timer()
{
llShout(5,"heart";);
}
}
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
07-12-2008 22:20
im not going to script it out for you, you seem adept enough and this will be some learning

1 "how do i make a menu?"
add a touch_start event to your throw script, call llDialog() its pretty forward

llDialog(key id, string message, list buttons, integer chat_channel)

or

llDialog(owner,"please choose a grenade timer in seconds", ["5","10","20"] , -8)

(tip:use a negitive chat channel, then only objects and dialog can use the chat channel)

use your otherwise unused listen event to get the message, type cast the response from a string to a integer and save it as a global variable (ie) explode_time = (integer) message;

2 "how do i pass that to the new object?"

in your fire function you have

llRezObject("Big Heart", pos, vel, rot, 0);

ever wonder what that last integer is for you set to 0? thats right you can pass a number to the new object tru that, so change it to

llRezObject("Big Heart", pos, vel, rot, explode_time);

on the other end you add an on rez event ... ever wonder what "integer blah" means, its the integer you set at the end of llRezObject();

on_rez(integer param)
{
llSetTimerEvent(param);
}

and BAM your good to go :)

good luck !
Bridget Leavitt
Registered User
Join date: 17 Dec 2006
Posts: 12
07-13-2008 14:40
Thanks Osgeld!

My scripting skills are still in pre school 101 and
I learn by LOTS of trial and error.
So I MAY have a feeling I'll be asking more Q's.. =\ =D


Thanks again for the instruction, I'll give this a try a bit later and see how successful i am!! XOXOX


~ B
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
07-13-2008 16:13
good luck, let us know how it works out !