Wasp's Computer

A computer system, with a todo list, file and directory system, and encryption/decryption.

Author: Wasp@Denver
Category: Other
Features: color substitutions.
Compatibility: TinyMUX.

Instructions

Copy and paste the below code into a compatible MUSH or MUX.

MUSHCode for Wasp's Computer

@create Computer
&CMD_APPEND Computer=$+append *=*:&dir_[v(cfg_dir)] me=[setunion(v(dir_[v(cfg_dir)]),u(fn_nospace,%0))];&file_[v(cfg_dir)]/[u(fn_nospace,%0)] me=[v(file_[v(cfg_dir)]/[u(fn_nospace,%0)])] %1;@pemit %#=%xh%xgText added to end of file.
&CMD_PREPEND Computer=$+prepend *=*:&dir_[v(cfg_dir)] me=[setunion(v(dir_[v(cfg_dir)]),u(fn_nospace,%0))];&file_[v(cfg_dir)]/[u(fn_nospace,%0)] me=%1 [v(file_[v(cfg_dir)][u(fn_nospace,%0)])];@pemit %#=%xh%xgText added to begenning of file.
&CMD_READ Computer=$+read *:@swi member(v(dir_[v(cfg_dir)]),u(fn_nospace,%0))=0,{@pemit %#=%xh%xrError%xn: No such file exists.},{@pemit %#=%xh%xc[repeat(-,78)]%R%xhFile: %xn%0%R%xhLocation: %xn[v(cfg_dir)]%R%xhFilesize:%xn [strlen(v(file_[v(cfg_dir)]/[u(fn_nospace,%0)]))]%R%xh%xc[repeat(-,78)]%R%xn[u(file_[v(cfg_dir)]/[u(fn_nospace,%0)])]%R%xh%xc[repeaT(-,78)]}
&CMD_DELETE Computer=$+del *:@swi member(v(dir_[v(cfg_dir)]),u(fn_nospace,%0))=0,{@pemit %#=%xh%xrError%xn: No such file.},{&file_[v(cfg_dir)]/[u(fn_nospace,%0)] me;&dir_[v(cfg_dir)] me=[remove(v(dir_[v(cfg_dir)]),u(fn_nospace,%0))];@pemit %#=%xh%xgFile deleted.}
&CREDITS Computer=Original coder Unknown; Modified by Wasp@Denver;
&CMD_EDIT Computer=$+edit *=*/*:@swi member(v(dir_[v(cfg_dir)]),u(fn_nospace,%0))=0,{@pemit %#=%xh%xrError%xn: No such file.},{&file_[v(cfg_dir)]/[u(fn_nospace,%0)] me=[edit(v(file_[v(cfg_dir)]/[u(fn_nospace,%0)]),%1,%2)];@pemit %#=%xh%xgFile Edited.}
@Adesc Computer=@pemit %#=[center(%b%xh%xr+chelp%xn for help.%b,79,%xg=%xn)]%r
@Desc Computer=%r[repeat(%xg=%xn,79)]%r[switch(hasattr(me,cdesc),1,[u(me/cdesc)],[center(This is a generic computer,79)]%r[center(Use %xh%xr+CHELP%xn for detailed instructions,79)]%r%r&cdesc [name(me)]=Whatever you want the desc of the computer to be.)]
&CMD_DIR Computer=$+dir:@pemit %#=%xh%xgDirectory Listing%xn: %xh(Current Directory: [v(cfg_dir)])%xn [iter(sort(u(dirs_[v(cfg_dir)])),%R%b%b[u(fn_addspace,##)]%xh/ %xn%xc\(files: [words(v(dir_[v(cfg_dir)]/##))] dirs: [words(v(dirs_[v(cfg_dir)]/##))]%xn%xc\))][iter(sort(u(dir_[v(cfg_dir)])),%R%b%b[u(fn_addspace,##)] %xn%xc\(size: [strlen(v(file_[v(cfg_dir)]/##))]%xn%xc\))]
&CFG_DIR Computer=root
&CMD_CHDIR Computer=$+chdir *:@swi/first [member(v(dirs_[v(cfg_dir)]),u(fn_nospace,%0))]%0=0..,{&cfg_dir me=[extract(v(cfg_dir),1,sub(words(v(cfg_dir),/),1),/)];@pemit %#=%xh%xgDirectory changed to: [v(cfg_dir)]},0/,{&cfg_dir me=root;@pemit %#=%xh%xgDirectory changed to: root},0*,{@pemit %#=%xh%xrError%xn: No such directory.},{&cfg_dir me=[v(cfg_dir)]/[u(fn_nospace,%0)];@pemit %#=%xh%xgDirectory changed to: %0}
&FN_NOSPACE Computer=[edit(%0,%b,~)]
&FN_ADDSPACE Computer=[edit(%0,~,%b)]
&CMD_RMDIR Computer=$+rmdir *:@swi [member(v(dirs_[v(cfg_dir)]),u(fn_nospace,%0))][or(words(v(dir_[u(fn_nospace,%0)])),words(v(dirs_[u(fn_nospace,%0)])))]=0?,{@pemit %#=%xh%xrError%xn: No such directory.},?1,{@pemit %#=%xh%xrError%xn: That directory is not empty.},{&dirs_[v(cfg_dir)] me=[remove(v(dirs_[v(cfg_dir)]),u(fn_nospace,%0))];@pemit %#=%xh%xgDirectory removed: %0}
&CMD_CWD Computer=$+cwd:@pemit %#=%xh%xgCurrent Working Directory is: [v(cfg_dir)]%xn
&CMD_MKDIR Computer=$+mkdir *:@swi member(v(dirs_[v(cfg_dir)]),u(fn_nospace,%0))=1,{@pemit %#=%xh%xrError%xn: Directory already exists.},{&dirs_[v(cfg_dir)] me=[setunion(v(dirs_[v(cfg_dir)]),u(fn_nospace,%0))];@pemit %#=%xh%xgDirectory created: %0}
&CMD_WRITE Computer=$+write *=*:&dir_[v(cfg_dir)] me=[setunion(v(dir_[v(cfg_dir)]),u(fn_nospace,%0))];&file_[v(cfg_dir)]/[u(fn_nospace,%0)] me=%1;@pemit %#=%xh%xgText written to file.
&CMD_LOAD Computer=$+load *:@swi member(v(dir_[u(cfg_dir)]),u(fn_nospace,%0))=0,{@pemit %#=%xh%xrError%xn: No such file exists.},{&cfg_file me=[u(fn_nospace,%0)];&cfg_filedir me=[u(cfg_dir)];@pemit %#=%xh%xgFile loaded.}
&CMD_UNLOAD Computer=$+unload:@swi hasattr(me,cfg_file)=0,{@pemit %#=%xh%xrError%xn: No file is current loaded.},{&cfg_file me;&cfg_filedir me;@pemit %#=%xh%xgFile unloaded.}
&CMD_ENCRYPT Computer=$+encrypt *=*:@swi member(v(dir_[v(cfg_dir)]),u(fn_nospace,%0))=0,{@pemit %#=%xh%xrError%xn: No such file.},{&file_[v(cfg_dir)]/[u(fn_nospace,%0)] me=[encrypt(u(file_[v(cfg_dir)]/[u(fn_nospace,%0)]),%1)];@pemit %#=%xh%xgFile Encrypted.}
&CMD_DECRYPT Computer=$+decrypt *=*:@swi member(v(dir_[v(cfg_dir)]),u(fn_nospace,%0))=0,{@pemit %#=%xh%xrError%xn: No such file.},{&file_[v(cfg_dir)]/[u(fn_nospace,%0)] me=[decrypt(u(file_[v(cfg_dir)]/[u(fn_nospace,%0)]),%1)];@pemit %#=%xh%xgFile Decrypted.}
&CMD_CHDIR2 Computer=$+cd *:@swi/first [member(v(dirs_[v(cfg_dir)]),u(fn_nospace,%0))]%0=0..,{&cfg_dir me=[extract(v(cfg_dir),1,sub(words(v(cfg_dir),/),1),/)];@pemit %#=%xh%xgDirectory changed to: [v(cfg_dir)]},0/,{&cfg_dir me=root;@pemit %#=%xh%xgDirectory changed to: root},0*,{@pemit %#=%xh%xrError%xn: No such directory.},{&cfg_dir me=[v(cfg_dir)]/[u(fn_nospace,%0)];@pemit %#=%xh%xgDirectory changed to: %0}
&CMD_CHELP Computer=$+chelp:@pemit %#=%xhComputer System Help:%R%R%T%xh+chelp dirs %xn- Directory Help%R%T%xh+chelp files %xn - File help%R%T%xh+chelp crypt %xn- Encryption/Decryption Help%R%T%xh+chelp todo %xn- ToDo System Help%R%T%xh+chelp notes %xn- Extra Information. Send me some feature sugguestions!
&CMD_CREAD Computer=$+cread *=*:@swi member(v(dir_[v(cfg_dir)]),u(fn_nospace,%0))=0,{@pemit %#=%xh%xrError%xn: No such file exists.},{@pemit %#=%xh%xc[repeat(-,78)]%R%xhFile: %xn%0 (encrypted)%R%xhLocation: %xn[v(cfg_dir)]%R%xhFilesize:%xn[strlen(v(file_[v(cfg_dir)]/[u(fn_nospace,%0)]))]%R%xh%xc[repeat(-,78)]%R%xn[decrypt([u(file_[v(cfg_dir)]/[u(fn_nospace,%0)])],%1)]%R%xh%xc[repeaT(-,78)]}
&CMD_CHELP_NOTES Computer=$+chelp notes:@pemit %#=%xhImportant things to keep in mind: %R%T%xh%xr-%xnTo create just a blank file, do '%xh+write file=%xn'.%R
&CMD_CHELP_DIRS Computer=$+chelp dirs:@pemit %#=%xhComputer Help: Directories.%R%R%xn[ljust(%xh%xg+dir,20)] List all files (and directories) in the current directory.%R[ljust(%xh%xg+chdir %xn%xcdirectory,20)] Change to the specified directory. %R%T%T%T%xhThis command may be shortened as %xh%xg+cd%R[ljust(%xh%xg+rmdir %xn%xcdirectory,20)] Remove the specified directory.%R[ljust(%xh%xg+mkdir %xn%xcdirectory,20)] Make the specified directory.%r[ljust(%xh%xg+cwd,20)] Specify your current directory.
&CMD_CHELP_FILES Computer=$+chelp files:@pemit %#=%xhComputer Help: Files.%R%R[ljust(%xh%xg+write %xn%xcfile%xn=%xctext,20)] Write text to file.%R[ljust(%xh%xg+append %xn%xcfile%xn=%xctext,20)] Append text to the end of file%R[ljust(%xh%xg+prepend %xn%xcfile%xn=%xctext,20)] Prepend text to the start of file%R[ljust(%xh%xg+del %xn%xcfile,20)] Delete the specified file.%R[ljust(%xh%xg+edit %xn%xcfile%xn=%xcold%xn%xc/new,20)]%xn As in @edit.%R%R[ljust(%xh%xg+read %xn%xcfile,20)] Read the specified file%R[ljust(%xh%xg+load %xn%xcfile,20)]%xn Load the specified file. Others may view it by looking at the computer.%R[ljust(%xh%xg+unload,20)] Unload the specified file, it no longer is view-able on the computer.%R%r[ljust(%xh%xg+find %xn%xctext,20)]%xn Searches for all files which contain 'text' and displays them. Case-insensitive.%R%r[ljust(%xh%xg+initroom %xn%xcDBRef#,20)]%xn Initializes the room/player to use the project code.%R%r[ljust(%xh%xg+upload %xn%xcfile,20)]%xn Projects the file to initialized rooms.%R%r[ljust(%xh%xg+unupload,20)]%xn Deactivates projected files.
&CMD_CHELP_CRYPT Computer=$+chelp crypt:@pemit %#=%xhComputer Help: Crypt.%R%R[ljust(%xh%xg+encrypt %xn%xcfile%xn=%xcpassword,20)] Encrypt the specified file.%R[ljust(%xh%xg+decrypt %xn%xcfile%xn=%xcpassword,20)] Decrypt specified file.%R[ljust(%xh%xg+cread %xn%xcfile%xn=%xcpassword,20)] Decrypts the specified file, and read it, but does not actually modify the file. (No need to re-encrypt after)
&CMD_CHELP_TODO Computer=$+chelp todo:@pemit %#=%xhComputer Help: ToDo%xn%r%r[ljust(%xh%xg+todo/add %xn%xcitem%xn,20)] Add an item to list%R[ljust(%xh%xg+todo/done %xn%xcitem#%xn,20)] Remove the numbered item%R[ljust(%xh%xg+todo/insert %xn%xcplace#%xn=%xcitem,20)] Add an item before the specified number.%R[ljust(%xh%xg+todo/clear%xn,20)] Clear the entire ToDo list.
&CMD_TODO Computer=$+todo:@pemit %#=%xh%xc[center(ToDo List,78,-)][iter(v(todo_list),%R%xh#@. %xn##,|)]%R%xh%xc[repeat(-,78)]
&CMD_TODO_ADD Computer=$+todo/add *:@swi words(v(todo_list),|)=0,{&todo_list me=%0},{&todo_list me=[v(todo_list)]|%0};@pemit %#=%xh%xgToDo Added.
&CMD_TODO_DONE Computer=$+todo/done *:&todo_list me=[ldelete(v(todo_list),%0,|)];@pemit %#=%xh%xgToDo item removed.
&CMD_TODO_INSERT Computer=$+todo/insert *=*:&todo_list me=[setq(0,switch(gt(%0,words(v(todo_list),|)),1,words([v(todo_list)]|xtra,|),%0))][insert(v(todo_list),%q0,%1,|)];@pemit %#=%xh%xgToDo item added.
&CMD_TODO_CLEAR Computer=$+todo/clear:&todo_list me=;@pemit %#=%xh%xgToDo list cleared.
&CMD_FIND Computer=$+find *:@pemit %#=%xhSearch Results:%xn[iter(grepi(me,file_*,%0),%r%t[after(##,FILE_)])]%rEnd.
&CMD_INITROOM Computer=$+initroom *:@va me=[num(me)];@va %0=%va;@desc %0=[lit([u(cfg_desc)][switch(hasattr(%va,cfg_upload),1,%R%R%xhThe screen displays the following information:%R%xh%xc[repeat(-,78)]%R%xhFile: %xn[u(%va/cfg_upload)]%R%xhLocation: %xn[u(%va/cfg_uploaddir)]%R%xhFilesize:%xn [strlen(u(%va/file_[u(%va/cfg_uploaddir)]/[u(%va/cfg_upload)]))]%R%xh%xc[repeat(-,78)]%R%xn[u(%va/file_[u(%va/cfg_uploaddir)]/[u(%va/cfg_upload)])]%R%xh%xc[repeat(-,78)]%R%xn)])]
&CMD_UPLOAD Computer=$+upload *:@swi member(v(dir_[u(cfg_dir)]),u(fn_nospace,%0))=0,{@pemit %#=%xh%xrError%xn: No such file exists.},{&cfg_upload me=[u(fn_nospace,%0)];&cfg_uploaddir me=[u(cfg_dir)];@pemit %#=%xh%xgFile projected.}
&CMD_UNUPLOAD Computer=$+unupload:@swi hasattr(me,cfg_upload)=0,{@pemit %#=%xh%xrError%xn: No file is currently projected.},{&cfg_upload me;&cfg_uploaddir me;@pemit %#=%xh%xgFile unprojected.}
@set Computer=OPAQUE
@set Computer=PARENT_OK
@set Computer=COMMANDS