All pastes #503509 Raw Edit

BASH!!!

public text v1 · immutable
·published 2007-05-22 22:15 UTC
rendered paste body
alias bash {
  var %w = @bash, %timeset = -

  if ($hget(bash) = $null) {
    hmake bash 10    
    if ($isfile(bash.dat)) hload bash bash.dat
  }
  hadd bash game_enabled 1
  hadd bash startcountdown 3

  if ($hget(bash,highscore) !isnum) hadd bash highscore 0
  elseif (($hget(bash,time) != $null) && ($hget(bash,time) isnum)) %timeset = $asctime($hget(bash,time), dddd dd $+ oo of mmmm yyyy $+ $chr(44) HH:nn:ss)

  window %w | clear %w
  echo %w Welcome to BASH!
  echo %w ----------------
  echo %w Your highscore: $hget(bash,highscore)
  echo %w Set on: %timeset
  echo %w ----------------
  bashstarttimer
}
alias -l bashstarttimer {
  if ($hget(bash,game_enabled) = 0) { .timerbashstarttimer off | return }
  if ($hget(bash,startcountdown) = 0) { .timerbashstarttimer off | startbash | return }
  var %w = @bash, %com = rline %w 6
  if (!$line(%w,6)) %com = echo %w
  %com The game will start in4 $hget(bash,startcountdown) seconds...
  hdec bash startcountdown
  .timerbashstarttimer 1 1 bashstarttimer
}
alias -l startbash {
  hadd bash bashes 0
  hadd bash bashtimer 150
  var %w = @bash | clear %w
  echo %w Press [SPACE]! bash! bash! BASH!
  echo %w --------------------------------
  echo %w Bashes: $hget(bash,bashes)
  echo %w Time: $hget(bash,bashtimer)
  hadd bash game_enabled 2
  bashtimer
}
alias -l bashtimer {
  if ($hget(bash,game_enabled) != 2) {
    .timerbashtimer off | return
  }
  if ($hget(bash,bashtimer) = 0) bashgameover
  rline @bash 4 Time: $hget(bash,bashtimer)
  hdec bash bashtimer
  .timerbashtimer -m 1 100 bashtimer
}
alias -l bashgameover {
  hadd bash game_enabled 0
  var %w = @bash | clear %w
  if ($hget(bash,bashes) > $hget(bash,highscore)) {
    hadd bash highscore $hget(bash,bashes)
    hadd bash time $ctime
    hsave -o bash bash.dat
    echo %w 3NEW HIGHSCORE! ( $+ $hget(bash,highscore) $+ )
  }
  else {
    echo %w 4You scored $hget(bash,bashes) $+ , not enough for a highscore...
  }
  hadd bash game_enabled 3
  echo %w -------------------
  echo %w [ENTER] = Try again
  halt
}
on *:KEYUP:@bash:32:{
  if ($hget(bash,game_enabled) != 2) return
  hinc bash bashes
  rline @bash 3 Bashes: $hget(bash,bashes)
}
on *:KEYDOWN:@bash:13:if ($hget(bash,game_enabled) = 3) bash
on *:CLOSE:@bash:hadd -m bash game_enabled 0