Guest User

convert.sh

a guest
Sep 4th, 2020
45
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. input=$1
  4. output="output.txt"
  5.  
  6. iconv -f ISO-8859-1 -t UTF-8 $input > $output
  7.  
  8. sed -i 's/\\\\/\/\//g' $output # \\ to // for comments. \\ Comment -> // Comment
  9. sed -i "s/\"/'/g" $output # Replace " with ' for strings. "STUNT" -> 'STUNT'
  10. sed -i 's/\([0-9]\+\)?/\1/g' $output # Remove ? after numbers. 100? -> 100
  11. sed -i 's/\([0-9]\+\)&/\1/g' $output # Remove & after numbers. 250& -> 250
  12. sed -i 's/\([0-9]\+\)!/\1.0/g' $output # Remove ! after numbers and convert to float. 10! -> 10.0
  13. sed -i 's/££/@/g' $output # Change ££ to @. jump ££BOGOFF -> jump @BOGOFF
  14. sed -i 's/if\s\+[0-1]\s*$/if/g' $output # Change "if 0"/"if 1" constructs to "if". if 0 -> if
  15. sed -i 's/if\s\+[2-7]\s*$/if and/g' $output # Change "if N" construct for ANDs to "if or". if 2 -> if and
  16. sed -i 's/if\s\+2[1-7]\s*$/if or/g' $output # Change "if N" construct for ORs to "if or". if 21 -> if or
  17. sed -i 's/\(\S\+\) = car \S\+ x_pos, \(\S\+\) = car \S\+ y_pos, \(\S\+\) = car \(\S\+\) z_pos/store_car \4 position_to \1 \2 \3/g' $output # Changes old-style 00AA opcode to new. "00AA: $Save1X = car $Curr_Car x_pos, $Save1Y = car $Curr_Car y_pos, $Save1Z = car $Curr_Car z_pos" to "00AA: store_car $Curr_Car position_to $Save1X $Save1Y $Save1Z"
  18.  
  19. exit 0
RAW Paste Data