Jump to content

counter++ help


TonyBowlin
 Share

You are about to reply to a thread that has been inactive for 2113 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

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 by TonyBowlin
Link to comment
Share on other sites

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

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 by ellestones
  • Thanks 1
Link to comment
Share on other sites

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

You are about to reply to a thread that has been inactive for 2113 days.

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
 Share

×
×
  • Create New...