Sumomo Cheri Posted May 19, 2015 Share Posted May 19, 2015 ok so i wanted to improve my bubble " this bubble everyone probably has but i wanted to take it up a notch and make it work much like a tail script but with chances of popping i got the [ " POP" ] action to work with a 1 out of 3 chance for each time its picked to pop or not but ever option after POP is not working and i cant seem to put a finger on why . list list_one = ["POP","Push","Rub","Glomp","Giggidy"]; string owner; integer lock = FALSE; integer listn; integer rand; integer chan; default { attach(key n) { llResetScript(); } on_rez(integer n) { llResetScript(); } state_entry() { llRequestPermissions(llGetOwner(),PERMISSION_ATTACH); chan = 100 + (integer)llFrand(20000); owner = llKey2Name(llGetOwner()); llListen(chan,"","",""); } touch_start(integer total_number) { key dk = llDetectedKey(0); if(dk == llGetOwner()) { llDialog(dk,"Change Bubble option,",["lock","unlock"],chan); } else if(lock == FALSE){ llDialog(dk,"What u want to do with "+owner+"'s Bubble",list_one,chan); } else { llInstantMessage(dk,"This Bubble is locked >.>"); } } listen(integer c, string n, key i, string m) { if(m == "lock") { lock = TRUE; llOwnerSay("Locked"); } if(m == "unlock") { lock = FALSE; llOwnerSay("Unlocked"); } if(m == "POP") { float FloatValue; integer IntValue; string StringValue; FloatValue = llFrand(3); IntValue = llRound(FloatValue); StringValue = (string)IntValue; { if(IntValue == 2) // { llTriggerSound("84cb8b4f-29b4-4062-ba7c-d36598a96314",1); llDetachFromAvatar( ); llSay(0," "+n +" Managed to Pop your Bubble Q.Q "); } else { llSay(0," "+n + " did not manage to pop their Bubble "); } if(m == "Push") { llSay(0," "+n +" pushes your bubble out of their way!"); } if(m == "Rub") { llTriggerSound("a9da4612-5d4b-662a-050a-c821c394991f",1); llSay(0," "+n +" walks up and rubs your Bubble causing it to squeek."); } if(m == "Glomp") { FloatValue = llFrand(3); IntValue = llRound(FloatValue); StringValue = (string)IntValue; { if(IntValue == 2) // { llTriggerSound("84cb8b4f-29b4-4062-ba7c-d36598a96314",1); llDetachFromAvatar( ); llSay(0," "+n +" rushes in with a flying Glomp attack hug popping your Bubble and pinning you to the ground >///< "); } else { llTriggerSound("4f9ad2c7-9e23-8257-c017-a44dd7e95153",1); llSay(0," "+n + " fails to get up enough speed to Glomp you and bounces off your Bubble and face plants onto the ground."); } if(m == "Giggidy") { FloatValue = llFrand(3); IntValue = llRound(FloatValue); StringValue = (string)IntValue; { if(IntValue == 2) // { llTriggerSound("84cb8b4f-29b4-4062-ba7c-d36598a96314",1); llDetachFromAvatar( ); llSay(0," "+n +" whips out their **bleep** and starts humping your Bubble causing it to pop and begins probbing your in sides with their **bleep** GIGGIDY ! "); } else { llTriggerSound("6c33db4b-7a59-9974-d07a-1f114c87bbd4",1); llSay(0," "+n + " **bleep** was to small to penetrate your Bubble and slides off to the ground where all can see their tiny **bleep** in full view ."); } } } } } } } } } Link to comment Share on other sites More sharing options...
Sumomo Cheri Posted May 19, 2015 Author Share Posted May 19, 2015 its like it stops reading the rest of the if(m=="") after the else in POP and i dont know why Link to comment Share on other sites More sharing options...
irihapeti Posted May 19, 2015 Share Posted May 19, 2015 you just a little bit lost in the brackets forest at the moment when use indentation to format then your code flow looks like this listen ...{ if(m == "lock") { ... } if(m == "unlock") { ... } if(m == "POP") { ... { if(IntValue == 2) { ... } else { ... } if(m == "Push") { ... } if(m == "Rub") { ... } if(m == "Glomp") { ... { if(IntValue == 2) { ... } else { ... } if(m == "Giggidy") { ... { if(IntValue == 2) { ... } else { ... } } } } } } }} indentation of your code can help you to identify where problems can arise + all of the if (m == ...) should be on the same indentation (column) eta: what Rolig said (: Link to comment Share on other sites More sharing options...
Rolig Loon Posted May 19, 2015 Share Posted May 19, 2015 @ Irihapeti -- Yeah, but you said it better, so I removed mine. :smileytongue: Link to comment Share on other sites More sharing options...
irihapeti Posted May 19, 2015 Share Posted May 19, 2015 nuuu! (: Link to comment Share on other sites More sharing options...
Sumomo Cheri Posted May 19, 2015 Author Share Posted May 19, 2015 list list_one = ["POP","Push","Rub","Glomp","Inflate"]; string owner; integer lock = FALSE; integer listn; integer rand; integer chan; default { attach(key n) { llResetScript(); } on_rez(integer n) { llResetScript(); } state_entry() { llRequestPermissions(llGetOwner(),PERMISSION_ATTACH); chan = 100 + (integer)llFrand(20000); owner = llKey2Name(llGetOwner()); llListen(chan,"","",""); } touch_start(integer total_number) { key dk = llDetectedKey(0); if(dk == llGetOwner()) { llDialog(dk,"Change Bubble option,",["lock","unlock"],chan); } else if(lock == FALSE){ llDialog(dk,"What u want to do with "+owner+"'s Bubble",list_one,chan); } else { llInstantMessage(dk,"This Bubble is locked >.>"); } } listen(integer c, string n, key i, string m) { if(m == "lock") { lock = TRUE; llOwnerSay("Locked"); } if(m == "unlock") { lock = FALSE; llOwnerSay("Unlocked"); } if(m == "POP") { float FloatValue; integer IntValue; string StringValue; FloatValue = llFrand(3); IntValue = llRound(FloatValue); StringValue = (string)IntValue; { if(IntValue == 2) { llTriggerSound("84cb8b4f-29b4-4062-ba7c-d36598a96314",1); llDetachFromAvatar( ); llSay(0," "+n +" Managed to Pop your Bubble Q.Q "); } else { llSay(0," "+n + " did not manage to pop their Bubble "); } if(m == "Push") { llSay(0," "+n +" pushes your bubble out of their way!"); } if(m == "Rub") { llTriggerSound("a9da4612-5d4b-662a-050a-c821c394991f",1); llSay(0," "+n +" walks up and rubs your Bubble causing it to squeek."); } if(m == "Glomp") { FloatValue = llFrand(3); IntValue = llRound(FloatValue); StringValue = (string)IntValue; { if(IntValue == 2) { llTriggerSound("84cb8b4f-29b4-4062-ba7c-d36598a96314",1); llDetachFromAvatar( ); llSay(0," "+n +" rushes in with a flying Glomp attack hug popping your Bubble and pinning you to the ground >///< "); } else { llTriggerSound("4f9ad2c7-9e23-8257-c017-a44dd7e95153",1); llSay(0," "+n + " fails to get up enough speed to Glomp you and bounces off your Bubble and face plants onto the ground."); } if(m == "Inflate") { FloatValue = llFrand(3); IntValue = llRound(FloatValue); StringValue = (string)IntValue; { if(IntValue == 2) { llTriggerSound("84cb8b4f-29b4-4062-ba7c-d36598a96314",1); llDetachFromAvatar( ); llSay(0," "+n +" sticks their mouth to your Bubble and starts to blow more air into your Bubble until it Pops "); } else { llTriggerSound("6c33db4b-7a59-9974-d07a-1f114c87bbd4",1); llSay(0," "+n + " Blows deep breaths into your Bubble but soon becomes light headed and blacks out"); } } } } } } } } } ok still same issue the only one that seems to work is the POP after the all the rest of the options do nothing no message no actions but saves as if it works Link to comment Share on other sites More sharing options...
Rolig Loon Posted May 19, 2015 Share Posted May 19, 2015 Yes, of course it will compile. The compiler only cares whether you have made syntax errors. It doesn't care that you have made logical errors. As irihapeti said, all of your "m ==" tests have to be at the same level of indentation, not nested inside each other. If the first m == POP evaluates as TRUE, there's no possible way for the others that are inside its scope can also be true. Link to comment Share on other sites More sharing options...
Xiija Posted May 19, 2015 Share Posted May 19, 2015 try this and compare to your code ... ( changed a few things) this will still only work with owner, you have to change the code if(dk == llGetOwner() ) to give the locking option to only the owner, and all others to use only if unlocked ... list list_one = ["POP","Push","Rub","Glomp","Inflate"];string owner;integer lock = FALSE;integer listn;integer rand;integer chan; // moved to global float FloatValue; integer IntValue; string StringValue; default{ attach(key n) { llResetScript(); } on_rez(integer n) { llResetScript(); } state_entry() { llRequestPermissions(llGetOwner(),PERMISSION_ATTACH); chan = 100 + (integer)llFrand(20000); owner = llKey2Name(llGetOwner()); llListen(chan,"","",""); } touch_start(integer total_number) { key dk = llDetectedKey(0); if(dk == llGetOwner()) { if(lock) llDialog(dk,"Change Bubble option,",["lock","unlock"],chan); else llDialog(dk,"What u want to do with "+owner+"'s Bubble",list_one,chan); } else { llInstantMessage(dk,"This Bubble is locked >.>"); } } listen(integer c, string n, key i, string m){ if(m == "lock") { lock = TRUE; llOwnerSay("Locked"); } if(m == "unlock") { lock = FALSE; llOwnerSay("Unlocked"); } if(m == "POP") { FloatValue = llFrand(3); IntValue = llRound(FloatValue); StringValue = (string)IntValue; // { if(IntValue == 2) { llTriggerSound("84cb8b4f-29b4-4062-ba7c-d36598a96314",1); llDetachFromAvatar( ); llSay(0," "+n +" Managed to Pop your Bubble Q.Q "); } else { llSay(0," "+n + " did not manage to pop their Bubble "); } } // end pop here if(m == "Push") { llSay(0," "+n +" pushes your bubble out of their way!"); } if(m == "Rub") { llTriggerSound("a9da4612-5d4b-662a-050a-c821c394991f",1); llSay(0," "+n +" walks up and rubs your Bubble causing it to squeek."); } if(m == "Glomp") { FloatValue = llFrand(3); IntValue = llRound(FloatValue); StringValue = (string)IntValue; // { if(IntValue == 2) { llTriggerSound("84cb8b4f-29b4-4062-ba7c-d36598a96314",1); llDetachFromAvatar( ); llSay(0," "+n +" rushes in with a flying Glomp attack hug popping your Bubble and pinning you to the ground >///< "); } else { llTriggerSound("4f9ad2c7-9e23-8257-c017-a44dd7e95153",1); llSay(0," "+n + " fails to get up enough speed to Glomp you and bounces off your Bubble and face plants onto the ground."); } } // end glomp here if(m == "Inflate") { FloatValue = llFrand(3); IntValue = llRound(FloatValue); StringValue = (string)IntValue; // { if(IntValue == 2) { llTriggerSound("84cb8b4f-29b4-4062-ba7c-d36598a96314",1); llDetachFromAvatar( ); llSay(0," "+n +" sticks their mouth to your Bubble and starts to blow more air into your Bubble until it Pops "); } else { llTriggerSound("6c33db4b-7a59-9974-d07a-1f114c87bbd4",1); llSay(0," "+n + " Blows deep breaths into your Bubble but soon becomes light headed and blacks out"); } } // end inflate here }} Link to comment Share on other sites More sharing options...
Dora Gustafson Posted May 19, 2015 Share Posted May 19, 2015 Right This is the actual structure: if(m == "POP") { .... if(IntValue == 2) { ... } else { ... } if(m == "Push") { ... } if(m == "Rub") { ... } if(m == "Glomp") { ... } if(m == "Inflate") { ... } } It shows that m equal to POP will exclude the rest of the tests for m to become true.A stringent formatting can reveal that right away :smileysurprised::smileyvery-happy: Link to comment Share on other sites More sharing options...
Sumomo Cheri Posted May 19, 2015 Author Share Posted May 19, 2015 that seemed to fix it but now the lock is locked and only i can get the menu but not the one to unlock where as before all i can do is lock or unlock and others got the menu of what to do to the bubble now its like reversed and locked others out. Link to comment Share on other sites More sharing options...
Xiija Posted May 19, 2015 Share Posted May 19, 2015 this will give the owner the lock option ... and display lock status in the dialog? list list_one = ["POP","Push","Rub","Glomp","Inflate"];list list_two = ["POP","Push","Rub","Glomp","Inflate"," ","lock","unlock"];string owner;integer lock = FALSE;integer listn;integer rand;integer chan; // moved to global float FloatValue; integer IntValue; string StringValue; string bubbleState = "Unlocked";default{ attach(key n) { llResetScript(); } on_rez(integer n) { llResetScript(); } state_entry() { llRequestPermissions(llGetOwner(),PERMISSION_ATTACH); chan = 100 + (integer)llFrand(20000); owner = llKey2Name(llGetOwner()); llListen(chan,"","",""); } touch_start(integer total_number) { key dk = llDetectedKey(0); if(dk == llGetOwner()) { llDialog(dk,"Owner Menu\n \nBubble is " + bubbleState,list_two,chan); } else { if(lock) llInstantMessage(dk,"This Bubble is locked >.>"); else llDialog(dk,"What u want to do with "+owner+"'s Bubble",list_one,chan); } } listen(integer c, string n, key i, string m){ if(m == "lock") { bubbleState = "Locked"; lock = TRUE; llOwnerSay("Locked"); } if(m == "unlock") { bubbleState = "Unlocked"; lock = FALSE; llOwnerSay("Unlocked"); } if(m == "POP") { FloatValue = llFrand(3); IntValue = llRound(FloatValue); StringValue = (string)IntValue; // { if(IntValue == 2) { llTriggerSound("84cb8b4f-29b4-4062-ba7c-d36598a96314",1); llDetachFromAvatar( ); llSay(0," "+n +" Managed to Pop your Bubble Q.Q "); } else { llSay(0," "+n + " did not manage to pop their Bubble "); } } // end pop here if(m == "Push") { llSay(0," "+n +" pushes your bubble out of their way!"); } if(m == "Rub") { llTriggerSound("a9da4612-5d4b-662a-050a-c821c394991f",1); llSay(0," "+n +" walks up and rubs your Bubble causing it to squeek."); } if(m == "Glomp") { FloatValue = llFrand(3); IntValue = llRound(FloatValue); StringValue = (string)IntValue; // { if(IntValue == 2) { llTriggerSound("84cb8b4f-29b4-4062-ba7c-d36598a96314",1); llDetachFromAvatar( ); llSay(0," "+n +" rushes in with a flying Glomp attack hug popping your Bubble and pinning you to the ground >///< "); } else { llTriggerSound("4f9ad2c7-9e23-8257-c017-a44dd7e95153",1); llSay(0," "+n + " fails to get up enough speed to Glomp you and bounces off your Bubble and face plants onto the ground."); } } // end glomp here if(m == "Inflate") { FloatValue = llFrand(3); IntValue = llRound(FloatValue); StringValue = (string)IntValue; // { if(IntValue == 2) { llTriggerSound("84cb8b4f-29b4-4062-ba7c-d36598a96314",1); llDetachFromAvatar( ); llSay(0," "+n +" sticks their mouth to your Bubble and starts to blow more air into your Bubble until it Pops "); } else { llTriggerSound("6c33db4b-7a59-9974-d07a-1f114c87bbd4",1); llSay(0," "+n + " Blows deep breaths into your Bubble but soon becomes light headed and blacks out"); } } // end inflate here }} Link to comment Share on other sites More sharing options...
Sumomo Cheri Posted May 19, 2015 Author Share Posted May 19, 2015 looked a bit closer and saw where the if (lock) was out of place and the else if lock = was missing fixed and now it seems to work just fine all the way through Thank you Link to comment Share on other sites More sharing options...
irihapeti Posted May 19, 2015 Share Posted May 19, 2015 i just add on something here for anyone new to programming who might read this + is the touch_start (as Xiija noted) where is a program flow problem touch_start(integer total_number){ key dk = llDetectedKey(0); if(dk == llGetOwner()) { if(lock) llDialog(dk,"Change Bubble option,",["lock","unlock"],chan); else llDialog(dk,"What u want to do with "+owner+"'s Bubble",list_one,chan); } else { llInstantMessage(dk,"This Bubble is locked >.>"); }} what the above code says is: if the person who touches is the owner then{ if the bubble is locked then { allow the owner to unlock it } else otherwise the bubble is unlocked, so { allow the owner to choose something to do with the bubble }}else otherwise is not the owner who touched the bubble, so{ tell the person who did touch that the bubble is locked} + when new to programming then it can sometimes help to program in English like I did above. and then when have your flow worked out then translate it to code. Example of what is wanted (programmed in English) if owner touches the bubble then{ if the bubble is locked then { allow the owner to unlock it } else otherwise the bubble is unlocked so { allow the owner to lock it }}else otherwise is not the owner who touched so{ if the bubble is unlocked then { allow the person who touched to choose something to do with the bubble } else the bubble is locked so just tell the person this. and dont allow them to choose anything { say that the bubble is locked }} + ps English is the most powerful, expressive and versatile programming language ever invented. If English is not your native language then the most pev is your own native language. German, French, Mandarin, etc from there can translate it to any other form. LSL, C, Spanish, BASIC, Russian, etc and in time then when become fluent in a language then can write direct in that. Italian, LSL, Java, Swahili, Pascal, etc eta: tpyo 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