diff --git a/wordle-life.cgi b/wordle-life.cgi index 43d280d..8fa0b82 100755 --- a/wordle-life.cgi +++ b/wordle-life.cgi @@ -1,7 +1,9 @@ #!/usr/pkg/bin/perl +#Above is the particular location for system binaries in SDF's metaarray, not the usual spot use strict; use warnings; use utf8; +#add my user perl library path, this is particular to each person's setup use lib qw( /usr/pkg/lib/perl5/5.24.0 /meta/p/peteyboy/perl5/lib/perl5 ); #make request for all of the following use CGI::Tiny; @@ -15,7 +17,7 @@ use Readonly; # #=== my $ORIGIN_PAGE = "/wordle-life.cgi"; - my $defaulttext = "Paste your wordle share here"; + my $defaulttext = "Paste your wordle share here (replace this text)"; cgi { @@ -88,7 +90,8 @@ sub generate_rle { Readonly my $headline_prefix => "#C "; #Part of RLE spec https://conwaylife.com/wiki/Run_Length_Encoded Readonly my $row_prefix => "x = 5"; #for wordle always 5 Readonly my $col_prefix => ",y = "; - + Readonly my $lifeviewer_settings => "\n[[\n GPS 3\n ZOOM 23\n COLOR ALIVE LIME\n COLOR BACKGROUND BLUE\n STOP 100\n GRID\n]]"; #Part of Viewer Spec + my $wordle = shift; # this is how you get variables in your function call! $rowcount = 0; @@ -99,16 +102,26 @@ sub generate_rle { $headline = $headline_prefix . $myline; }else{ - #in case of text mode + #remove all line endings with magic perl identifier R $myline =~ s/\R//; $myline =~ s/^(.*)$/$1\$/; + #these replaces are logicless, so they need to be done in this order! + + #in case of text mode (Discord) $myline =~ s/:yellow_square:/o/g; $myline =~ s/:green_square:/o/g; - $myline =~ s/:[a-z-]*square:/b/g; - # for normal unicode - $myline =~ s/\N{U+1f7e8}/o/g; #yellow - $myline =~ s/\N{U+1f7e9}/o/g; #green + $myline =~ s/:blue_square:/o/g; #HC equiv yellow + $myline =~ s/:orange_square:/o/g; #HC equiv green + + $myline =~ s/:[a-z_]*square:/b/g; + # for normal unicode + $myline =~ s/\N{U+1f7e8}/o/g; #yellow hit + $myline =~ s/\N{U+1f7e9}/o/g; #green hit + $myline =~ s/\N{U+1F7E6}/o/g; #blue + $myline =~ s/\N{U+1F7E7}/o/g; #orange + + $myline =~ s/\N{U+2B1B}/b/g; #black $myline =~ s/\N{U+2B1C}/b/g; #white @@ -117,6 +130,9 @@ sub generate_rle { $myline =~ s/white_large_square/b/g; $myline =~ s/yellow_square/o/g; $myline =~ s/green_square/o/g; + $myline =~ s/blue_square/o/g; + $myline =~ s/orange_square/o/g; + #skip blank lines, count rows added @@ -127,7 +143,8 @@ sub generate_rle { } } #this is the format with b,o, and $. Done lazily because I don't compress the repeated b or o. - return "$headline\n$row_prefix$col_prefix$rowcount\n$rleline"; + $rleline =~ s/\$$/\!/; #Correct termination of last line of RLE is !, not $, so replace it. + return "$headline\n$row_prefix$col_prefix$rowcount\n$rleline\n$lifeviewer_settings"; } @@ -140,7 +157,11 @@ __DATA__ - + @@ -161,31 +182,32 @@ __DATA__
-


  • -

    Click "Submit" and and RLE format file for Conway's Game of Life will appear in the box below and get loaded into the Life Viewer.

    +

    Click "Submit" and an RLE format file made for Conway's Game of Life will appear in the box below and get loaded into the Life Viewer.

    - +
  • Watch your Wordle score play LIFE!

    +
    -

    If the RLE is correct, it should be loaded in the Life Viewer, and so you are ready to go!

      -
    • For best results with the Life Viewer, adjust the Zoom and the playback speed (from "1x", slide left to "3/s" or so) and press the Play button:

      +
    • For best results with the Life Viewer, you may adjust the default Zoom and the playback speed, then press the Play button:

    • Press "[Pause]" when it seems stable.

    • @@ -208,10 +230,21 @@ __DATA__
       #C Wordle 235 3/6
       x = 5,y = 3
      -boobo$bobbo$ooooo$
      +boobo$bobbo$ooooo!
      +
      +[[GPS 3
      +ZOOM 23
      +COLOR ALIVE LIME
      +COLOR BACKGROUND BLUE
      +STOP 100
      +GRID
      +]]
      +
      +
       
      -

      For details about the Life RLE file format above, read this. +

      (the main thing that needs to be right are the first 3 lines. If the 3rd line has any : symbols, just try deleting them. The stuff between double brackets aren't part of the RLE but are comments that set some defaults for the Life Viewer)

      +

      For details about the Life RLE file format above, read this.