TonyBowlin Posted September 3, 2018 Share Posted September 3, 2018 (edited) Why does this not work? can I not do a comparison this way with an increment counter? The goal is to count 1 to 10 on each face and with each count on a selected face, a llOwnerSay of that value for the face clicked will report back. default { state_entry() { llListen(6508,"", NULL_KEY, ""); llSetTimerEvent(0.0); value = 0; } touch_start(integer num_detected) { integer face = llDetectedTouchFace(0); if (face == 7) { value++; llSetText("_"+(string)value,<1,1,1>,1); llPlaySound("8cb0cb67-728b-b621-d307-a798159791e4",0.2); if(gas == value + 3); { llOwnerSay("value is 4"); } if(gas == value +9 ); { llOwnerSay("value is 10"); } } if (face == 6) { valuetwo++; Edited September 3, 2018 by TonyBowlin Link to comment Share on other sites More sharing options...
ellestones Posted September 3, 2018 Share Posted September 3, 2018 stepping thru begin value == 0; 1st touch. value++; value == 1; value + 3 == 4; 'gas' has to be == 4 for the 'if' to fire; value + 9 == 10; 'gas' has to be == 10 for the 'if' fire; 2nd touch. value++; value == 2; value + 3 == 5; when 'gas' == 5 the 'if' fires and says 'value is 4' ?? value + 9 == 11; when 'gas' == 11 the 'if' fires and says 'value is 10' ?? Link to comment Share on other sites More sharing options...
TonyBowlin Posted September 3, 2018 Author Share Posted September 3, 2018 Oh sorry, Gas is the same thing as value forgot to rename it. =\ Link to comment Share on other sites More sharing options...
ellestones Posted September 3, 2018 Share Posted September 3, 2018 (edited) ok if you are wanting to do stuff on each touch in the range 1..10 then maybe integer touches = 0; touch(..) { touches++; if (touches == 3) { // compare to gas } else if (touches == 10) { // compare to gas // then reset and start over touches = 0; } } edit add meaning that each face has its own touches variable integer touches7 = 0; touch(..) { integer face = llDetectedTouchFace(0); if (face == 7) { touches7++; if (touches7 == 3) { // compare to gas } else if (touches7 == 10) { // compare to gas // then reset and start over touches7 = 0; } } } Edited September 3, 2018 by ellestones 1 Link to comment Share on other sites More sharing options...
Xiija Posted September 3, 2018 Share Posted September 3, 2018 You could use a list mebbe? Example code: list touches; integer face; default { state_entry() { integer numOfSides = llGetNumberOfSides(); integer x; for( ; x < numOfSides ; ++x) { touches += x; touches += (integer)0; } llOwnerSay("list is: \n" + llDumpList2String( touches, " , ") ); } touch_start(integer total_number) { face = llDetectedTouchFace(0); integer index; if( ~( index = llListFindList( touches, [face]) ) ) { integer check = llList2Integer( touches, index + 1); ++check; if( check > 10){ check = 1; } touches = llListReplaceList(touches, [(integer)check], index + 1, index + 1); llOwnerSay("list is: \n" + llDumpList2String( touches, " , ") ); } } } Link to comment Share on other sites More sharing options...
Innula Zenovka Posted September 4, 2018 Share Posted September 4, 2018 On 9/3/2018 at 11:39 AM, TonyBowlin said: Oh sorry, Gas is the same thing as value forgot to rename it. =\ In that case, conditions like if(gas == value + 3); can never be true, which may be why things aren't behaving as expected. 1 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