#!/usr/bin/newlisp ;; Creative Commons Attribution (by) License v2.5 ;; Full text - http://creativecommons.org/licenses/by/2.5/ ;; Contact - tyler.mace@versantvoice.com ;; Copyright (c) 2009, Versant Voice, LLC. ;; Context: PLAYER ;; This context will contain information and functionality ;; related to other secsec players in our world ;; Context: NPC ;; This context will contain information and functionality ;; strictly related to the NPCs in our world. ;; Context: SYSTEM ;; This context will contain information and functionality ;; related to the computer systems in our world. We'll ;; keep track of system address, services, owners, etc. ;; Context: WORLD ;; The world context contains information and functionality ;; related to the world in which our players will be hacking. ;; This includes things like target systems, NPCs, and other ;; players ;; Context: SHELL ;; The shell context provides the interface the player will ;; be interacting with. ;; Context: MAIN ;; The main context provides our splash screen, exit, ;; versioning information, etc. (context 'WORLD) (context 'SHELL) ;; Shell variables (setq scripts_directory "scripts/") (setq ps1 "secsec> ") (setq quit_command "quit") (setq current_command "") (setq last_command "") ;; Process command lambda ;; Takes a command as an argument and processes it (define (Process_Command command_string) (begin ;; Local variables (setq command_list (parse command_string)) (setq command (first command_list)) (setq command_args (rest command_list)) (setq all_scripts (directory SHELL:scripts_directory)) (setq usable_scripts (begin ;; Strip out ".", "..", and scripts named the same as quit command ;; Returns only usable scripts (pop all_scripts (find "." all_scripts)) (pop all_scripts (find ".." all_scripts)) (pop all_scripts (find SHELL:quit_command all_scripts)) all_scripts ) ) ;; Debug information ;;(println (append "Command: " command)) ;;(println (append "Argument(s): " (join command_args ", "))) ;;(println (append "Commands available: " (join usable_scripts ", "))) ;; Find our command script and run it, if available, else show available commands (if (find command usable_scripts) (begin ;; Gather script data (setq script_data (read-file (append SHELL:scripts_directory command))) ;; Evaluate script data (setq evaluated_script_data (eval-string script_data)) ) (println (append "Unknown command: " command)) ) ) ) ;; Run shell lambda ;; Run our shell, looping to process commands as they're entered (define (Run_Shell) (begin ;; Process commands so long as player doesn't enter quit command (while (begin (print SHELL:ps1 ) (setq SHELL:current_command (read-line))) (begin ;; Is the player trying to quit? (if (= SHELL:current_command SHELL:quit_command) (MAIN:Exit_Game) ) ;; Process current command (SHELL:Process_Command SHELL:current_command) ) ) ) ) (context 'MAIN) ;; Main variables (setq game_name "SecSec") (setq game_major_version "0") (setq game_minor_version "3") (setq game_full_version (append game_major_version "." game_minor_version)) ;; Splash Screen lambda ;; Display version and other game information (define (Splash_Screen) (begin (println (append MAIN:game_name " - v" MAIN:game_full_version "\r\n")) ) ) ;; Exit lambda (define (Exit_Game) (begin (println "Exiting...") (exit) ) ) ;; Let's play! (MAIN:Splash_Screen) (SHELL:Run_Shell)