Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

model hud

Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
05-08-2009 21:06
so i made this model hud, it's pretty basic, not something i plan on selling, just for personal use. all works well except one thing, when pressing the "back" button, it doesn't loop back to the end when it gets to 0, instead it continues to count down. when it gets to the end when pressing the "next" button it loops around the beginning like it should. can someone spot my error? and other advice on the script is welcome, it's just something i threw together.

CODE

string current;
integer i = 0;
integer num;
floattext(string animname)
{
integer pos = i + 1;
string text = "Now Playing " + current + "\n" + (string)pos + " of " + (string)num;
llSetText(text,<1.0,1.0,1.0>,1.0);
}

default
{
attach(key id)
{
if(id)
{
llRequestPermissions(id,PERMISSION_TRIGGER_ANIMATION);
state animate;
}
}
}

state animate
{
state_entry()
{
num = llGetInventoryNumber(INVENTORY_ANIMATION);
current = llGetInventoryName(INVENTORY_ANIMATION,i);
llStartAnimation(current);
floattext(current);
}

touch_start(integer n)
{
integer linknum = llDetectedLinkNumber(0);
string name = llToLower(llGetLinkName(linknum));
if(name == "pose")
{
llRezObject("Pose Ball",llGetPos() + <1.0,0.0,0.0>*llGetRot(),ZERO_VECTOR,ZERO_ROTATION,0);
}
else if(name != "pose")
{
if(name == "next"){i = (i + 1)%num;}
else if(name == "back"){i = (i - 1)%num;}
else if(name == "begin"){i = 0;}
llStopAnimation(current);
llOwnerSay((string)i);
current = llGetInventoryName(INVENTORY_ANIMATION,i);
floattext(current);
llStartAnimation(current);
}
}

changed(integer change)
{
if(change & CHANGED_INVENTORY)
{
num = llGetInventoryNumber(INVENTORY_ANIMATION);
}
}
}
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Viktoria Dovgal
Join date: 29 Jul 2007
Posts: 3,593
05-08-2009 21:52
else if(name == "back";){if (--i < 0) i = num - 1;}

... or whatever variation floats your boat.
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
05-08-2009 22:15
i got it, i changed this line

else if(name == "back";){i = (i - 1)%num;}

into

else if(name == "back";){i = (i - 1+num)%num;}

not sure why it works, but it does lol
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
05-08-2009 22:18
i got it, i changed this line

else if(name == "back";){i = (i - 1)%num;}

into

else if(name == "back";){i = (i - 1+num)%num;}

not sure why it works, but it does lol

and obviously this line

llOwnerSay((string)i);

is only to see what index it's actually trying to use
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369