3D Rad - Free 3D game maker - Forum

This forum is now archived!

This forum is locked, and is a read-only version. A new community-ran forum can be found at classdev.net

News:

The 3DRad community can be found at classdev.net.

Pages: [1]

Author Topic: speedometer script help  (Read 129 times)

« on: May 24, 2014, 01:51:17 PM »
I need help I made a skinmesh that ranges from 0-9 and it is going to be used for a cars cockpit speedometer but I Can't figure out what I have to put into my script to get the frames to loop back to 0 instead of staying at 9.
so can I have some help with this I basically want to get it to act like the valueprint object.
Code: [Select]
void Main()
{
   OUT_22 = IN_0*1;
   OUT_44 = IN_0*0.1;
   OUT_66 = IN_0*0.01;
}
I be trippin!
« Reply #1 on: May 24, 2014, 09:05:50 PM »
Quote
I made a skinmesh that ranges from 0-9
do you mean you are using an anim mesh with 10 frames (0-9)?


--Mike
« Reply #2 on: May 25, 2014, 08:39:55 AM »
Quote
I made a skinmesh that ranges from 0-9
do you mean you are using an anim mesh with 10 frames (0-9)?



--Mike
yes.
I be trippin!
« Reply #3 on: May 25, 2014, 08:52:20 AM »
i see two digits in the speedometer readout... how many skinmeshes are being used to display that... 2 or 1?

--Mike
« Reply #4 on: May 25, 2014, 10:12:40 AM »
i see two digits in the speedometer readout... how many skinmeshes are being used to display that... 2 or 1?

--Mike
3 skinmesh's the the one on the left reads the 100's,the middle reads the 10's,and the right one reads the 1's.
I be trippin!
« Reply #5 on: May 25, 2014, 03:41:30 PM »

Quote
3 skinmesh's the the one on the left reads the 100's,the middle reads the 10's,and the right one reads the 1's.

good... that's pretty much how it's supposed to be...

here's some code... it's pretty straight forward... it works...

Code: [Select]
int    numOnes = 0, numTens = 0, numHundreds = 0, value = 0;
bool   keyPressed=false;
int    delay=0;

void Main()
{

   //               logic for a slight delay unless key kept down
   if(iTypedChar(false)==0){
     keyPressed=false;
     delay=0;
   } else {
     delay++;
   }

   //               plus key  increases value if less than 999
   if(iKeyDown(iKeyCode("DIK_EQUALS"))&& (keyPressed==false || delay>44)){
     if(value < 999)value++;
     keyPressed=true;
   }

   //               minus  key  decreases value if greater than 0
   if(iKeyDown(iKeyCode("DIK_MINUS")) && (keyPressed==false || delay>44)){   //&& keyPressed==false
     if(value > 0)value--;
     keyPressed=true;
   }

   //               calculate  hundreds index
   numHundreds = value / 100; 
   if(numHundreds < 0)numHundreds = 0;

   //               calculate  tens index
   numTens = (value - (numHundreds * 100)) /10;
   if(numTens < 0)numTens = 0;

   //               calculate  ones index
   numOnes = (value - (numHundreds * 100)) -(numTens * 10) ;
   if(numOnes < 0)numOnes = 0;


   //              set skinmesh animations based on indexes
   OUT_0   =  numOnes;
   OUT_22 = numTens;
   OUT_44 = numHundreds;
   
}





--Mike
« Reply #6 on: May 25, 2014, 04:10:01 PM »

Quote
3 skinmesh's the the one on the left reads the 100's,the middle reads the 10's,and the right one reads the 1's.

good... that's pretty much how it's supposed to be...

here's some code... it's pretty straight forward... it works...

Code: [Select]
int    numOnes = 0, numTens = 0, numHundreds = 0, value = 0;
bool   keyPressed=false;
int    delay=0;

void Main()
{

   //               logic for a slight delay unless key kept down
   if(iTypedChar(false)==0){
     keyPressed=false;
     delay=0;
   } else {
     delay++;
   }

   //               plus key  increases value if less than 999
   if(iKeyDown(iKeyCode("DIK_EQUALS"))&& (keyPressed==false || delay>44)){
     if(value < 999)value++;
     keyPressed=true;
   }

   //               minus  key  decreases value if greater than 0
   if(iKeyDown(iKeyCode("DIK_MINUS")) && (keyPressed==false || delay>44)){   //&& keyPressed==false
     if(value > 0)value--;
     keyPressed=true;
   }

   //               calculate  hundreds index
   numHundreds = value / 100; 
   if(numHundreds < 0)numHundreds = 0;

   //               calculate  tens index
   numTens = (value - (numHundreds * 100)) /10;
   if(numTens < 0)numTens = 0;

   //               calculate  ones index
   numOnes = (value - (numHundreds * 100)) -(numTens * 10) ;
   if(numOnes < 0)numOnes = 0;


   //              set skinmesh animations based on indexes
   OUT_0   =  numOnes;
   OUT_22 = numTens;
   OUT_44 = numHundreds;
   
}





--Mike
but I don't need it to be activated by a botton I need the value to increase with the cars speed.
I be trippin!
« Reply #7 on: May 25, 2014, 04:15:17 PM »
nevermind I edited the script so it will act the way I want.
thanks mike! :)
Code: [Select]
int    numOnes = 0, numTens = 0, numHundreds = 0, value = 0;
bool   keyPressed=false;
int    delay=0;

void Main()
{
   //               logic for a slight delay unless key kept down
   if(iTypedChar(false)==0){
     keyPressed=false;
     delay=0;
   } else {
     delay++;
   }
     value = IN_0*1.5;
   //               calculate  hundreds index
   numHundreds = value / 100; 
   if(numHundreds < 0)numHundreds = 0;

   //               calculate  tens index
   numTens = (value - (numHundreds * 100)) /10;
   if(numTens < 0)numTens = 0;

   //               calculate  ones index
   numOnes = (value - (numHundreds * 100)) -(numTens * 10) ;
   if(numOnes < 0)numOnes = 0;


   //              set skinmesh animations based on indexes
   OUT_22   =  numOnes;
   OUT_44 = numTens;
   OUT_66 = numHundreds;
   
}
« Last Edit: May 25, 2014, 04:23:45 PM by dogtorque »
I be trippin!
« Reply #8 on: May 25, 2014, 04:17:31 PM »
there ya go boobie... i know you weren't thinkin' that i was gonna do your thinking for ya...

it's the logic that's important here... you gotta understand the logic...  the anim frames are triggered by the index... to get the index depends on what digit you need...


--Mike
Pages: [1]