### Start CoffeeMud service (Fedora/Red Hat) Source: https://github.com/bozimmerman/coffeemud/blob/master/guides/InstallationGuide.html After installing the RPM package, use systemctl to start the CoffeeMud service and then check its status to ensure it started correctly. ```bash systemctl start coffeemud ``` ```bash systemctl status coffeemud ``` -------------------------------- ### Example Security Setting Source: https://github.com/bozimmerman/coffeemud/blob/master/guides/refs/ahelp.html This example demonstrates how to set security flags for a player, granting access to groups, commands, and file system operations. ```plaintext Security: BUILDER, AREA GOTO, SNOOP, VFS: RESOURCES/TEXT/ ``` -------------------------------- ### Install QuickWho JavaScript Command Source: https://github.com/bozimmerman/coffeemud/blob/master/guides/InstallationGuide.html Use LOAD COMMAND to install this sample JavaScript command. Enter QUICKWHO at the command line to run it. ```javascript LOAD COMMAND resources/examples/QuickWho.js ``` -------------------------------- ### Start CoffeeMud Proxy Server (Unix/Linux/FreeBSD) Source: https://github.com/bozimmerman/coffeemud/blob/master/guides/InstallationGuide.html Use this command to start the CoffeeMud proxy server on Unix-like systems. The classpath differs from the Windows version. ```bash java -classpath ".:./lib/js.jar:./lib/jzlib.jar" -Xmx85m com.planet_ink.coffee_mud.application.MUDProxy BOOT=coffeemud.ini STRATEGY=ROUNDROBIN ``` -------------------------------- ### Start CoffeeMud Proxy Server (Windows) Source: https://github.com/bozimmerman/coffeemud/blob/master/guides/InstallationGuide.html Use this command to start the CoffeeMud proxy server on Windows. Ensure the classpath includes the necessary JAR files. ```bash java -classpath ".;.\lib\js.jar;.\lib\jzlib.jar" -Xmx85m com.planet_ink.coffee_mud.application.MUDProxy BOOT=coffeemud.ini STRATEGY=ROUNDROBIN ``` -------------------------------- ### Implement invoke Method in Java Source: https://github.com/bozimmerman/coffeemud/blob/master/guides/Programming.html Implement the invoke method to define the core logic of an ability. This example shows how to get a target for the ability. ```java public boolean invoke( MOB mob, List commands, Physical givenTarget, boolean auto, int asLevel ) { MOB target = this.getTarget( mob, commands, givenTarget ); if( target == null ) { return false; } ``` -------------------------------- ### Define MXP Entity Source: https://github.com/bozimmerman/coffeemud/blob/master/web/pub/siplet/help/help_mxp.htm Use to define a reusable entity that can be referenced by its name. The example defines 'Start' and 'End' entities for emphasis and demonstrates their usage. ```MXP "> "> &Start;This text is emphasized&End; ``` -------------------------------- ### SHELL Command Examples Source: https://github.com/bozimmerman/coffeemud/blob/master/guides/refs/ahelp.html These examples show various ways to use the SHELL command to interact with the file system and virtual file system, including listing directories and executing commands. ```shell shell ``` ```shell shell ? ``` ```shell shell directory ``` ```shell shell cd /resources/text ``` ```shell shell copy thisfile.txt :: ``` ```shell shell del ::thisfile.txt ``` ```shell shell edit thisfile.txt ``` -------------------------------- ### Configure and Run CoffeeMud from ZIP (Unix/Linux) Source: https://github.com/bozimmerman/coffeemud/blob/master/guides/InstallationGuide.html For Unix/Linux users installing from a ZIP package, first make the configuration script executable and then run it. Finally, run the server using the provided shell script. ```bash chmod +x config.sh ./config.sh ``` ```bash chmod +x mud.sh ./mud.sh ``` -------------------------------- ### Get Trap Components for Disassembly Source: https://github.com/bozimmerman/coffeemud/blob/master/guides/Programming.html Provides a list of items resembling the components used to create the trap, useful for disassembly skills. This example creates 10 pieces of raw iron. ```Java public List getTrapComponents() { Vector V = new Vector(); for( int i = 0 ; i < 10 ; i++ ) V.addElement( CMLib.materials().makeItemResource( RawMaterial.RESOURCE_IRON ) ); return V; } ``` -------------------------------- ### Implement preInvoke Method in Java Source: https://github.com/bozimmerman/coffeemud/blob/master/guides/Programming.html Implement the preInvoke method to perform checks or setup before an ability is invoked. It must return true for the invoke method to execute. This example simply returns true. ```java public boolean preInvoke( MOB mob, List commands, Physical givenTarget, boolean auto, int asLevel, int secondsElapsed, double actionsRemaining ) { return true; } ``` -------------------------------- ### Configure Siplet UI and Load Scripts Source: https://github.com/bozimmerman/coffeemud/blob/master/web/pub/siplet/index.html Initializes the Siplet UI, sets up event listeners for resizing and beforeunload, and begins the sequential loading of JavaScript dependencies. If any script fails to load, the user is prompted to refresh the page. ```javascript class SipSkip extends Error {}; function ConfigureSiplet() { window.sipfs = new SipletFileSystem('SipletFileSystem'); document.getElementById('loadingmsg').outerHTML = ''; document.getElementById('inputarea').style.visibility='visible'; ConfigureInput(document.getElementById('inputarea'), document.getElementById('input')); ConfigureTopMenu(document.getElementById('menuarea')); ConfigureMainTabs(document.getElementById('tabarea')); var tabStyle = window.getComputedStyle(document.getElementById('tabarea')); window.winAreaTop = parseInt(tabStyle.top) + parseInt(tabStyle.height) + 1; window.windowArea = document.getElementById('windowarea'); window.winAreaHeight = 'calc(100% - '+(winAreaTop+inputAreaHeight)+'px)'; window.windowArea.style.cssText='background-color:black;position:absolute;width:100%;top:'+window.winAreaTop+'px;height:'+winAreaHeight+';'; window.addEventListener("beforeunload", CloseAllSiplets); setTimeout(LoadGlobalPhonebook, 500); document.body.style.fontFamily='Arial'; document.body.style.fontSize='14'; var resizeDebouncer = null; window.addEventListener('resize', function() { if(resizeDebouncer == null) resizeDebouncer =setTimeout(function() { ResizeAllSiplets(); resizeDebouncer = null; }, 500); }); } ``` ```javascript var loadableScripts = [ "js/config.js", "js/input.js", "js/menu.js", "js/tabs.js", "js/websock.js", "js/util.js", "js/plugins.js", "js/ctxmenu.js", "js/binparser.js", "js/ansiparser.js", "js/telnetparser.js", "js/textparser.js", "js/filesys.js", "js/mspsupport.js", "js/mxpsupport.js", "js/mapper.js", "js/gmcp.js", "js/siplet.js", "js/pako_inflate.min.js" ] function LoadJavaScript() { if(loadableScripts.length == 0) { ConfigureSiplet(); } else { var url = loadableScripts[0]; loadableScripts.splice(0,1); var scriptElement = document.createElement("script"); scriptElement.src = url; scriptElement.onload = function() { setTimeout(LoadJavaScript, 10); }; scriptElement.onerror=function() { window.alert('Unable to load. Click OK to refresh.'); location.reload(); }; document.head.appendChild(scriptElement); } } ``` ```javascript window.addEventListener('load', function() { setTimeout(LoadJavaScript, 100); }); ``` -------------------------------- ### Getting String Length Source: https://github.com/bozimmerman/coffeemud/blob/master/guides/Scriptable.html Append '.LENGTH#' to a variable to get the number of words it contains. ```CoffeeMud Scripting .LENGTH# ``` -------------------------------- ### Cancel 'get rock' Command Source: https://github.com/bozimmerman/coffeemud/blob/master/guides/Scriptable.html This snippet cancels the specific command 'get rock' entered by a player. ```CoffeeMud Script cnclmsg_prog GET p get rock mpechoat $n You may not get the rock. return cancel ~ ``` -------------------------------- ### Initialize Building Variables Source: https://github.com/bozimmerman/coffeemud/blob/master/guides/Programming.html Sets up variables for the building process, including the 'messedUp' flag and the 'building' reference item. It also obtains the required fire. ```Java fire = getRequiredFire( mob,autoGenerate ); if( fire == null ) { return false; } building = null; messedUp = false; ``` -------------------------------- ### RaceHelper Behavior Example Source: https://github.com/bozimmerman/coffeemud/blob/master/guides/refs/behav.html Example of RaceHelper behavior parameters, specifying a maximum number of combatants and a custom attack message. ```mudscript 5 msg="OMG ATTACK!" ``` -------------------------------- ### TargetPlayer Behavior Example Source: https://github.com/bozimmerman/coffeemud/blob/master/guides/refs/behav.html Example configuration for the TargetPlayer behavior. This behavior makes a MOB target the weakest player in their group during combat. ```plaintext min=2 max=3 chance=99 ``` -------------------------------- ### Initialize Media Tree Source: https://github.com/bozimmerman/coffeemud/blob/master/web/pub/siplet/dialogs/media.htm Sets up the media tree interface, including event handlers and rendering logic. It fetches the media tree structure and renders it to the specified DOM element. ```javascript var fixsmediapage=function(){ if(document.getElementById('SCRIPTREE')) { var RED = '#FF555B'; var root = document.getElementById('MEDIAROOT'); var simg = document.getElementById('MEDIASPAN'); var img = document.getElementById('MEDIAPREV'); root.rootNode = document.getElementById('SCRIPTREE'); root.tree = {}; root.selected = null; root.map = {}; window.sipfs.getMediaTree(function(err,newtree){ if(err) { SiAlert(err); return; } root.tree = newtree; root.tree.opened = true; root.tree.name = '/'; root.rootNode.innerHTML = ''; root.renderNode(root.rootNode, [root.tree]); }); root.selectNode = function(nr) { simg.style.visibility='hidden'; if(nr != root.tree) nr.opened = !nr.opened; root.selected = nr; root.rootNode.innerHTML = ''; root.renderNode(root.rootNode, [root.tree]); if(!nr.isFolder) { var x = nr.name.lastIndexOf('.'); if((x>0)&&(nr.name.substr(x+1).toLowerCase() in window.imgMimeTypes)) { simg.style.visibility='visible'; img.src = 'media://'+nr.path; updateMediaImagesInSpan(window.sipfs, simg); } } }; root.renderNode = function(parent, nodes) { for(var i=0;i 0) { var pn = stk.pop(); if(pn.children && pn.children.length > 0) stk = stk.concat(pn.children); if(pn.entries && pn.entries.length > 0) nodesToDel = nodesToDel.concat(pn.entries); } } else { msg = "Delete the file '"+root.selected.path+"'?"; nodesToDel.push(root.selected); } SiConfirm(msg, function() { for(var i=0;i=0) pn.children.splice(x,1); } if(pn.entries) { var x = pn.entries.indexOf(root.selected); if(x>=0) pn.entries.splice(x,1); } } root.selected = null; root.rootNode.innerHTML = ''; root.renderNode(root.rootNode, [root.tree]); }); }; root.trydlmedia = function() { if(!root.selected) { SiAlert("You need to select a node."); return; } if(root.name == '/') { SiAlert("You can not download root."); return; } if(root.selected.isFolder) { SiAlert("You can not download a folder."); return; } else { window.sipfs.load(root.selected.path,function(err, dataUrl) { if (err) { console.error('Error loading ' + path + ':', err); return; } if(dataUrl) { if(!dataUrl.startsWith('blob:')) { const blob = new Blob([dataUrl], { type: 'application/octet-stream' }); const url = URL.createObjectURL(blob); setTimeout(() => URL.revokeObjectURL(url), 2000); dataUrl = url } } }); } }; ``` -------------------------------- ### TaxCollector Behavior Example Source: https://github.com/bozimmerman/coffeemud/blob/master/guides/refs/behav.html Example configuration for the TaxCollector behavior, specifying wait and grace periods. This behavior makes a mob an annoying collector. ```plaintext WAIT=60000 GRACE=600000 ``` -------------------------------- ### Start HSQLDB Database Manager Source: https://github.com/bozimmerman/coffeemud/blob/master/guides/InstallationGuide.html Command to launch the HSQLDB DatabaseManager utility from the command line. This is used to create and configure the HSQLDB database for CoffeeMud. ```bash java org.hsqldb.util.DatabaseManager ``` -------------------------------- ### Create and Initialize a MOB Source: https://github.com/bozimmerman/coffeemud/blob/master/guides/Programming.html Use this code to create a new MOB, set its starting room, and bring it to life. Ensure the MOB and Room IDs are valid. ```java MOB mob = CMClass.getMOB( "MyNewMOB" ); Room room = CMLib.map().getRoom( "Midgaard#3504" ); mob.setStartRoom( room ); mob.basePhyStats().setRejuv( 500 ); mob.recoverPhyStats(); mob.bringToLife( room, true ); ``` -------------------------------- ### Emote Trigger Examples Source: https://github.com/bozimmerman/coffeemud/blob/master/guides/refs/behav.html Examples of how to configure emote triggers for various events. Triggers can be based on timed chances or specific game events. ```plaintext sound 80 wiggles his bottom.;sound 60 smiles evilly.;sound 20 burps! ``` ```plaintext min=20 max=20;wear $p looks good on you.;remove Now you don't look so good.;remove_room $n doesn't look so good. ``` -------------------------------- ### Nanny Behavior Example Source: https://github.com/bozimmerman/coffeemud/blob/master/guides/refs/behav.html An example of setting up the Nanny behavior for a mob. This behavior makes the mob a protector of other mobs and items for a specified rate. ```plaintext rate=2.5 name="The Stables" watches="mounts,wagons" ```