12
inter/db/12 · 5.6 KB
From the archive interlude_1beta5.tar.gz
Download the archive « Back to the archive contents
11
name
"Generic Coder"
/
eval-command
(method (inline)
(if (= player this)
(player:tell (+ "--> "
(tostr ((compile (+ "(method () "
(index 3 inline)
"]\n"))))
"\n"))))
/
program-syntax
(method (inline)
(if (= player this)
(tell "Syntax: @program <variable name> on <object>\n")))
/
start-program
(method (objname pname)
(if (= player this)
(if (set compile-onto (std-match objname))
(var prop
(set prop (+ pname "-txt")
(tell (+ ">> Programming " prop " from scratch\n"))
(enter-edit (tosym prop) 'compile-program '())
1))
(tell "I don't see that here\n"))))
/
program-cmd
(method (inline)
(if (= player this)
(if (= (index 4 inline) "on")
(start-program (index 5 inline) (index 3 inline))
(if (= (index 4 inline) "=")
(start-program (index 3 inline) (index 5 inline))
(program-syntax inline)))))
/
compile-program
(method (saved-to)
(if (write-ok? caller)
(begin
(tell (+ ">> compiling '" (tostr saved-to) "' into variable '"
(before "-TXT" (tostr saved-to)) "' :\n"))
(var temp
(if (set temp (compile (eval saved-to)))
(if (compile-onto:set-variable
(tosym (before "-TXT" (tostr saved-to)))
temp)
(begin
(tell ">> compilation successful\n")
(rmvar saved-to))
(tell (+ ">> unable to compile onto object "
(tostr compile-onto)
"\n>> still in editor: .xit to abort edit\n"))))))))
/
edit-syntax
(method (inline)
(if (= player this)
(tell-line "Syntax: @edit <variable name> on <object>")))
/
start-edit
(method (objname pname)
(if (= player this)
(if (set compile-onto (std-match objname))
(var prop
(set prop (+ pname "-txt")
(tell (+ ">> Editing existing version of " prop " at line one:\n"))
(enter-edit (tosym prop) 'compile-program
(explode "\n" (compile-onto:list-method (tosym pname))))
1))
(tell "I don't see that here\n"))))
/
edit-cmd
(method (inline)
(if (= player this)
(if (= (index 3 inline) "on")
(start-edit (index 4 inline) (index 2 inline))
(if (= (index 3 inline) "=")
(start-edit (index 2 inline) (index 4 inline))
(edit-syntax inline)))))
/
mutate-syntax
(method (unused)
(if (= player this)
(tell "Syntax: @mutate <object> to <object>\n")))
/
mutate-cmd
(method (inline)
(if (= player this)
(var match (var match2
(if (set match (std-match (index 2 inline)))
(if (set match2 (std-match (index 4 inline)))
(ignore E_PERM
(if (#0:set-parents match match2)
(tell "Object has been mutated\n")
(tell (+ "You cannot mutate " (index 2 inline)
" to " (index 4 inline) "\n"))))
(tell (+ "I don't see " (index 4 inline) " here\n")))
(tell (+ "I don't see " (index 2 inline) " here\n")))))
(mutate-syntax)))
/
addcommand-syntax
(method (in)
(if (= player this)
(tell "Syntax: @addcommand <symbol> on <object> with <template>\n")))
/
addcommand-creator
(method (inline)
(if (= player this)
(var obj
(if (set obj (std-match (index 4 inline)))
(var cmd-list
(if (= (typeof (set cmd-list (compile (index 6 inline))))
'LIST)
(if (obj:add-command cmd-list (tosym (index 2 inline)))
(tell "Command added\n")
(tell "Unable to add command\n"))
(tell "Command must be in the form of a list\n")))
(tell (+ "I don't see " (index 4 inline) " here.\n"))))))
/
rmcommand-syntax
(method (unused)
(if (= player this)
(tell "Syntax: @rmcommand on <object> matching <line>\n")))
/
rmcommand-cmd
(method (inline)
(if (= player this)
(var obj
(if (set obj (std-match (index 3 inline)))
(if (obj:remove-command (index 5 inline))
(tell "Command removed\n")
(tell "That line does not match a command you can remove\n"))
(tell "I can't find that object here\n")))))
/
rmvariable-syntax
(method (unused)
(if (= player this)
(tell "Syntax: @rmvariable <symbol> from <object>\n")))
/
rmvariable-cmd
(method (inline)
(if (= player this)
(if (= (index 4 inline) "=")
(rmvar-helper (index 3 inline) (index 5 inline))
(rmvar-helper (index 5 inline) (index 3 inline)))))
/
rmvar-helper
(method (obj prop)
(if (set obj (std-match obj))
(if (obj:rm-variable (tosym prop))
(tell "Variable removed\n")
(tell "You cannot remove that variable\n"))
(tell "I can't find that object\n")))
/
/
'("@prog" (or "ram" ""))
program-syntax
'("@prog" (or "ram" "") (or (before "=") (before " on ") "") (or "=" "on" "") SOME)
program-cmd
'("@edit")
edit-syntax
'("@edit" (or (before "=") (before " on ") "") (or "=" "on" "") SOME)
edit-cmd
'("eval" (or "uate" "") REST)
eval-command
'(";" "" SOME)
eval-command
'("@list")
mutate-syntax
'("@mutate" (or (before "=") (before " to ")) (or "=" "to") REST)
mutate-cmd
'("@rmvar" (or "iable" "") (or (before "=") (before " from ")) (or "=" " from ") SOME)
rmvariable-cmd
'("@rmvar" (or "iable" ""))
rmvariable-syntax
'("@addcommand")
addcommand-syntax
'("@addcommand" WORD " on " (before " with ") "with" SOME)
addcommand-creator
'("@rmcommand" " on " (before "matching") "matching" SOME)
rmcommand-cmd
'("@rmcommand")
rmcommand-syntax
/+++++++++ end of object #12 ... no lines after this ++++++++++