Name-detecting entrance/exit conversions

This commit is contained in:
2023-03-20 21:15:29 -06:00
parent 44702a6231
commit cf0e0800a5
3 changed files with 32 additions and 1 deletions

View File

@@ -0,0 +1,8 @@
package ktxt2;
import kiss.Prelude;
import kiss.List;
import bad_nlp.Names;
@:build(kiss.Kiss.build())
class NamesConversion {}

View File

@@ -0,0 +1,9 @@
(defNew [&prop &mut :String name
&prop &mut :String sourceType
&prop &mut :String outputType
:(String,Array<String>)->Bool canConvertNames
:Array<String>->String convertNames]
[
&mut :String->Bool canConvert ->block ?(whenLet [names (Names.findNames block)] (canConvertNames block names))
&mut :String->String convert ->block (let [names (Names.findNames block)] (convertNames names))
])

View File

@@ -53,3 +53,17 @@
(.replace stream.content "/*" "")
"*/" "")
"*" ""))\n"))
(function isScreenLine [:String block]
(= 1 .length (filter (block.split "\n"))))
(function doWithCharacters [:String thing :String args]
(registerConversion
(new ktxt2.NamesConversion "${thing} characters" "fountain" "hollywoo"
->[block names] (isScreenLine block)
->names (+
(.join (for name names "$(thing.toUpperCase)CHARACTER \"${name}\" $args") "\n")
"\n"))))
(doWithCharacters "Add" "<position key> <facing>")
(doWithCharacters "Remove" "")