Digital dispay with announcer

Post your example zscripts/ACS scripts/etc here.

Digital dispay with announcer

Postby lulle » Mon May 09, 2022 6:53 am

Displays a number between 0 and 99.

Left: -1
Right: +1
Center: Countdown 9->0 with audio
playerstart. random number

You can use it to display kill counts, playtime or build a clock.

Code: Select allExpand view
#include "zcommon.acs"
#define l01      1    // line tag for right digit
#define l10      2   // line tag for left digit
#define MIN    0   // counter can only display numbers
#define MAX    99   // between 0 and 99

// Runnning count:
int count = 0;

/*
* This is a dumb function that trys to display everything
* you throw @ it. So run checks BEFORE calling it.
*/
function void display (int num) {
   int s = num % 10;
   str one = StrParam(i:s);
   int t = (num-s) / 10;
   str ten ="0";
   ten = StrParam(i:t);
   setlinetexture(l01, SIDE_FRONT, TEXTURE_BOTTOM, one);
   setlinetexture(l10, SIDE_FRONT, TEXTURE_BOTTOM, ten);
}

/*
* Count down from 9 to 0 with voice output.
*/
script "countdown" (void) {
   for (int i = 9 ; i > -1 ; i--) {
      str rns = StrParam(i: i);
      ambientsound (rns, 127);
      display(i);
      delay(35); // 1 second
   }
   display(count);
}

/*
* Current value + 1
* switch to 0 if count is 100
*/
script "count_up" (void) {
   count++;
   if(count > MAX) {
      count = MIN;
   }
   display(count);
}

/*
* Current value - 1
* switch to 99 if count is -1
*/
script "count_down" (void) {
   count--;
   if(count < MIN) {
      count = MAX;
   }
   display(count);
}

/*
* Diplay a random number
*/
script "random" (void) {
   count = random(MIN,MAX);
   display(count);
}

https://drive.google.com/file/d/1SCc555Ef0CMhX3GxE_eDNEq-5xRPXwi6/view?usp=sharing
You do not have the required permissions to view the files attached to this post.
User avatar
lulle
 
Joined: 06 May 2022
Location: Germany

Return to Script Library

Who is online

Users browsing this forum: No registered users and 0 guests