Paste: Add UUIDs to relevant fields in a godot 3.x tscn

Author: yumaikas
Mode: factor
Date: Wed, 14 Dec 2022 03:57:35
Plain Text |
USING: io.files sequences sequences.deep locals uuid 
io.encodings.utf8 kernel combinators arrays 
combinators.smart ;
IN: godot.meta

: (world-scn-lines) ( -- lines ) 
    "A/Path/to.tscn" utf8 file-lines ;

: save-lines-to-world-scn ( lines -- )
   "A/Path/out.tscn" utf8 set-file-lines ;

: uuid-line ( -- line )
    [ "uuid = \"" uuid4 "\"" ] "" output>sequence ; 

: map-lines-for-uuids ( lines -- new-lines ) 
    [ "uuid = \"" subseq-of? not ] filter
    [| line |
        {
            { 
              [ line "name=\"Latch\"" subseq-of? ] 
              [ line uuid-line 2array ] 
            }
            [ line ] 
        } cond
    ] map flatten
;

Annotation: Errata 1

Author: yumaikas
Mode: markdown
Date: Wed, 14 Dec 2022 04:02:39
Plain Text |
`output>sequence` should be switched to `output>array "" join` for now

New Annotation

Summary:
Author:
Mode:
Body: