Skip to content

Commit

Permalink
Some minor bug fixes
Browse files Browse the repository at this point in the history
Accumulator2 WIP checkpoint
Alias.tin added for custom aliases
  • Loading branch information
strnglp committed Sep 6, 2024
1 parent aca32e7 commit 4c9af48
Show file tree
Hide file tree
Showing 6 changed files with 211 additions and 26 deletions.
19 changes: 7 additions & 12 deletions Accumulator.tin
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
#echo {Loading duplicate accumulator.}
#script {screenheight} {tput lines}
#nop height of the terminal, minus the split for promps
#math {screenheight} {$screenheight[1] * -1 + 7}
#variable prevline {}
#variable matchcount {1}
#unvariable checkprompt
#nop ignore prompts, empty lines, and equipment lines
#variable checkprompt {^PROMPT_|^$|^([\r\n\t ]*?)$|^<}
#variable checkprompt {^PROMPT_|^$|^%s$|^<}
#unevent {RECEIVED LINE}
#event {RECEIVED LINE} {
#nop ensure we're not receiving a prompt or blank lines;
Expand All @@ -17,14 +14,12 @@
#buffer info {save} {buffersize};
#buffer find {%0} {pos};
#math {linesup} {($buffersize[+4] - $pos) * -1};
#if {$linesup < 0 && $linesup > $screenheight} {
#buffer clear {$linesup} {-1};
#buffer refresh;
#math {matchcount} {$matchcount + 1};
#math {color} {$matchcount % 8};
#format {color} {<0%d8>} {$color};
#substitute {%0} {%0 ${color}\(x${matchcount}\)${RESET}};
}
#buffer clear {$linesup} {-1};
#buffer refresh;
#math {matchcount} {$matchcount + 1};
#math {color} {$matchcount % 8};
#format {color} {<0%d8>} {$color};
#substitute {%0} {%0 ${color}\(x${matchcount}\)${RESET}};
} {
#variable {prevline} {%0};
#variable {matchcount} {1};
Expand Down
131 changes: 131 additions & 0 deletions Accumulator2.tin
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
#echo {Loading duplicate accumulator2.};
#nop This pattern will probably grow over time, these are things we don't;
#nop want to delete in the case of a repeat, e.g. lines starting with < are equipment;
#variable ignore_pattern {{^[^<].*}};
#nop #variable ignore_pattern {{^(?!\s*$)[^<\s].*}};

#script {screenheight} {tput lines};
#math {screenheight} {$screenheight[1] * -1 + 7};
#variable match_count {1};
#variable prev_seq {};
#unevent {RECEIVED OUTPUT};
#event {RECEIVED OUTPUT} {
#local index {};
#local line {};
#local onscreen {};
#local color {};

#nop First check if we've previously found matches and delete the counter;
#buffer find {↳ \(\+%d\)} {index};
#if {$index !== 0} {
#buffer clear {$index-1} {$index};
#buffer refresh;
};

#buffer get {onscreen} {$screenheight} {-1};
#list onscreen reverse;
#list onscreen filter {$ignore_pattern};
#local res {@longest_contiguous_seq{{$onscreen}}};
#local lower {$res[end]};
#local upper {$res[start]};
#if {$lower != 0 && $upper != 0} {
#nop #system {echo "lower: $lower upper: $upper" > test.txt};
#nop If we find a contiguous sequence clear the repeat;
#buffer clear {$lower} {$upper};
#buffer refresh;
#nop Show a repeat counter;
#math {match_count} {$match_count + 1};
#math {color} {$match_count % 8};
#format {color} {<0%d8>} {$color};
#showme {${color}↳ \(+$match_count\)${RESET}};
#nop Cache the sequence to test intermediate lines;
#variable prev_seq {$res[seq]};
#buffer refresh;
} {
#nop We didn't find a contiguous sequence...;
#nop If the new line is in the prev_seq it may be that we're amidst a mid-sequence update;
#nop Only clear the count if the latest line is not in the prev_seq;
#local prev_line {};
#local new_line {};
#buffer get {new_line} {-1};
#nop Don't count blank lines, the appear all the time, sometimes from prompts;
#if {{$new_line} == {{^\s*[^\S[:print:]]*\s*$}} } {
#return;
};
#foreach {$prev_seq[%*]} {prev_line} {
#if {{$new_line} === {$prev_line}} {
#nop Don't clear the counter yet;
#return;
};
};

#nop Ok to clear the counter, the latest line isn't a part of the prev_seq;
#list prev_seq clear;
#variable match_count {1};
};
}

#function longest_contiguous_seq {
#local arr {%1};
#local n {&arr[]};
#if {$n == 0} { #return {} };
#local max_seq {};
#local max_length {0};
#local match_start {0};
#local match_end {0};
#local max_repeat {0};

#nop Iterate over each possible starting point and slide a match window ahead;
#loop {1} {$n} {start} {
#nop Limit the sliding window to half the array length;
#local end_of_range {0};
#math end_of_range {($n - $start) / 2 + 1};
#loop {1} {$end_of_range} {length} {
#local seq_end {0};
#math seq_end {$start + $length};
#local seq {};
#list seq create {$arr[+$start..+$seq_end]};

#local next {0};
#local next_end {0};
#local next_seq {};
#local next {$seq_end + 1};
#math next_end {$next + $length};
#local repeat_count {1};
#while {$next_end <= $n} {
#list next_seq clear;
#list next_seq create {$arr[+$next..+$next_end]};
#if {{$next_seq} === {$seq}} {
#math repeat_count {$repeat_count + 1};
#math next {$next_end + 1};
#math next_end {$next + $length};
}
{
#break
};
};

#local total_length {0};
#if {$repeat_count > 1} {
#math total_length {$length * ($repeat_count - 1)};
#if {$total_length > $max_length} {
#local match_start {$start};
#local max_length {$total_length};
#math match_end {$start + $total_length};
#list max_seq clear;
#list max_seq create {$arr[+$start..+$match_end]};
#local max_repeat {$repeat_count};
}
};

};
};
#math match_start {$match_start * -1};
#math match_end {$match_end * -1};
#variable result {
{start}{$match_start}
{end}{$match_end}
{seq}{$max_seq}
};
#return $result;
}
55 changes: 55 additions & 0 deletions Alias.tin
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#unevent {CATCH RECEIVED OUTPUT};
#function parse_looks {
#variable look_chunk_count {0};
#event {CATCH RECEIVED OUTPUT} {
#math look_chunk_count {$look_chunk_count + 1};
#variable string {%%0};
#replace string {PROMPT_%*\n} {};
#replace string {\[%*\]\nNothing.\n} {};
#replace string {You see nothing special.\n} {};
#replace string {^\n$} {};
#if {"$string" != ""} {
#showme {$string};
};

#if {$look_chunk_count === 12} {
#unevent {CATCH RECEIVED OUTPUT};
#variable {look_chunk_count} {0};
};
};
}

#alias {la} {
#variable z {@parse_looks{}};
l n;
l s;
l e;
l w;
l d;
l u;
}

#alias {dis} {disengage}

#alias {startm} {
draw spear;
es shield;
}
#alias {endm} {
sheath spear;
rem shield;
}
#alias {startr} {
rem bow;
es bow;
pull quiver;
}
#alias {endr} {
rem bow;
wear bow;
}

#alias {skinning} {
get knife belt;
ep knife;
}
25 changes: 15 additions & 10 deletions Arm.tin
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,12 @@
#nop PROMPT_encumbrance_speed_riding_accent_language_scan_listen_LINETHREE;
#send {prompt PROMPT_%e_%d_%u_%U_%R_%O_LINEONE\\nPROMPT_%h_%H_%v_%V_%t_%T_%x_%X_%m_%M_%A_%s_LINETWO\\nPROMPT_%E_%w_%k_%a_%o_%p_%P_LINETHREE\\n};
change color none;
change color fg_room_name $GAME_ROOM;
change color fg_room_exits $GAME_EXITS;
change color fg_room_name bred;
change color fg_room_exits bwhite;
change color fg_object $GAME_OBJECT;
change color fg_char $GAME_CHARACTER;
change color emphasize on
change color emphasize on;
pagelength 100;
}

#alias {ManaOff}
Expand Down Expand Up @@ -210,12 +211,13 @@
#function {foodicon} {
#local {result} {};
#switch {"%1"} {
#case {"full"} #format {result} {${FG_BGREEN}󱐟 %n${RESET}} {%1};
#case {"stuffed"} #format {result} {${FG_BCYAN}󱐟 %n${RESET}} {%1};
#case {"full"} #format {result} {${FG_GREEN}󱐟 %n${RESET}} {%1};
#case {"satisfied"} #format {result} {${FG_BGREEN}󱐟 %n${RESET}} {%1};
#case {"peckish"} #format {result} {${FG_GREEN}󱐟 %n${RESET}} {%1};
#case {"little hungry"} #format {result} {${FG_GREEN}󱐟 %n${RESET}} {%1};
#case {"hungry"} #format {result} {${FG_YELLOW}󱐟 %n${RESET}} {%1};
#case {"very hungry"} #format {result} {${FG_BYELLOW}󱐟 %n${RESET}} {%1};
#case {"peckish"} #format {result} {${FG_YELLOW}󱐟 %n${RESET}} {%1};
#case {"little hungry"} #format {result} {${FG_BYELLOW}󱐟 %n${RESET}} {%1};
#case {"hungry"} #format {result} {${FG_MAGENTA}󱐟 %n${RESET}} {%1};
#case {"very hungry"} #format {result} {${FG_BMAGENTA}󱐟 %n${RESET}} {%1};
#case {"starving"} #format {result} {${FG_RED}󱐟 %n${RESET}} {%1};
#case {"near death"} #format {result} {${FG_BRED}󱐟 %n${RESET}} {%1};
#default #format {result} {%1 unhandled hunger};
Expand Down Expand Up @@ -404,8 +406,11 @@
#read {$armdir/Help.tin};

#nop Accumulate repeated lines into one line
#read {$armdir/Accumulator.tin};
#alias {rlacc} { #read {$armdir/Accumulator.tin} }
#nop #read {$armdir/Accumulator2.tin};
#alias {rlacc} { #read {$armdir/Accumulator2.tin} }

#read {$armdir/Alias.tin};
#alias {rlalias} { #read {$armdir/Alias.tin} }

#nop reload it all
#alias {reconnect} {#read $armdir/Arm.tin}
4 changes: 2 additions & 2 deletions Globals.tin
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

#nop GAME_* are used for color matching regex else where, so use the ANSI colors
#nop the game will send from the server (after installing infobar)
#nop bred
#nop bred cached as ansi escape seq for use in regex
#variable {GAME_ROOM} {\e[38;5;9m}
#nop bwhite
#nop bwhite cached as ansi escape seq for use in regex
#variable {GAME_EXITS} {\e[0m\e[38;5;15m}
#variable {GAME_OBJECT} {bgreen}
#variable {GAME_CHARACTER} {bblue}
Expand Down
3 changes: 1 addition & 2 deletions Map.tin
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#action {^You try to climb, but slip.} {#map undo}
#action {Maybe you should get on your feet first.} {#map undo}
#action {That opening is too small for you.} {#map undo}
#action {^You feel too relaxed to do that.} {#map undo}
#action {, stepping in front of you.$} {#map undo}
#action {steps in front of you, blocking your path.$} {#map undo}
#action {scowls at you and blocks their path into the warehouse.$} {#map undo}
Expand Down Expand Up @@ -88,7 +87,7 @@
};
#nop mapping highlights and info;
#map set roomname %1;
#regexp {%2} {{^Inside the.*Gate|Road|Circle|Walk|Way|Path|Street|Aisle|Archway|Plaza|Alley|Alleyway}} {
#regexp {%1} {{^Inside the.*Gate|Road|Circle|Walk|Way|Path|Street|Aisle|Archway|Plaza|Alley|Alleyway}} {
#map get {roomsymbol} {symbol};
#if {{$symbol} == "{| }"} {
#map set roomcolor ${FG_BYELLOW}
Expand Down

0 comments on commit 4c9af48

Please sign in to comment.