Rhemah Posted August 12, 2015 Share Posted August 12, 2015 i want to create like five different OwnerSay, can someone give me an idea?integer sayit = TRUE; default { touch_start(integer total_number) { if(llDetectedKey(0) == llGetOwner()) { if(sayit) { llOwnerSay("First!"); sayit = FALSE; } else if(!sayit) { llOwnerSay("Second!"); } } } }// i want to like create more llOwnerSay("Third!"); to Fifth if possible Link to comment Share on other sites More sharing options...
Sassy Romano Posted August 12, 2015 Share Posted August 12, 2015 Rhemah wrote: i want to create like five different OwnerSay, can someone give me an idea? integer sayit = TRUE;default{ touch_start(integer total_number) { if(llDetectedKey(0) == llGetOwner()) { if(sayit) { llOwnerSay("First!"); sayit = FALSE; } else if(!sayit) { llOwnerSay("Second!"); } } }} // i want to like create more llOwnerSay("Third!"); to Fifth if possible Well, since you have declared an integer, use it as an integer instead of a boolean. TRUE/FALSE are two states but that integer can contain lots of numbers so just use 1, 2, 3, 4, 5 and test for 1,2,3,4,5 instead of TRUE or FALSE. 1 Link to comment Share on other sites More sharing options...
Rhemah Posted August 12, 2015 Author Share Posted August 12, 2015 still learning thank you! :matte-motes-kiss: Link to comment Share on other sites More sharing options...
Nova Convair Posted August 12, 2015 Share Posted August 12, 2015 The classic solution is an if else chain: integer saywhat;default { touch_start(integer num) { if (llDetectedKey(0) == llGetOwner()) { ++saywhat; if (saywhat==1) { llOwnerSay("first"); } else if (saywhat==2) { llOwnerSay("second"); } else if (saywhat==3) { llOwnerSay("third"); } else { llOwnerSay("last"); } } }} count up saywhat on every touch and run through the chain to find an answer. Can become quite lengthy. Sometimes you can replace that by another solution like this: integer saywhat;default { touch_start(integer num) { if (llDetectedKey(0) == llGetOwner()) { list answers = ["first","second","third","last"]; integer length = llGetListLength(answers); ++saywhat; if (saywhat > length) saywhat=length; llOwnerSay(llList2String(answers,saywhat-1)); } }} Here you only add elements to the list if you need more answers. If that is useful depends on the single case. I often use list pickers instead of if else chains if that makes sense. Link to comment Share on other sites More sharing options...
Innula Zenovka Posted August 12, 2015 Share Posted August 12, 2015 Another way of doing the list-picker is integer counter;integer max;list answers = ["first","second","third","last"];default{ state_entry() { max = llGetListLength(answers); } touch_start(integer total_number) { llOwnerSay(llList2String(answers,counter%max)); ++counter; }} Link to comment Share on other sites More sharing options...
Recommended Posts
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