BasicScript

From CoffeeMud Wiki
Jump to navigation Jump to search
CoffeeMUD
Administrator                                                  Builder                                                              Player
=CoffeeMUD Builder Information=
Basics Praetor     Player Support     Commands     Zapper Masks Advanced Races     Classes     Abilities     Socials     Scripting    
Building Behaviors     Properties     Areas     Rooms     Exits     Items     Mobs Systems Achievements     Crafting     Help Info     Ships     Planes of Existence     Quests     Triumphs    

Simple starter script example

There are 2 different syntax/approaches to choose from:

  • in a separate file
  • all within the scriptable behavior parameter

I prefer to have my scripts run from a file rather than all keyed into the parameter of the script behavior. The syntax for a file script uses a new line for each new line rather than a semicolon for each new line which is done when it is all in the parameter. So:

  • use the file browser on the grinder to create a new directory structure where to keep your scripts.
    • I like the naming convention of starting in the resources folder/directory and then adding a path like: progs/areas/Midgaard for example.
  • use the file browser to create your new text file
  • enter the example script as follows:
greet_prog 100
  #this line is a comment line.  Note that $i is a variable for the name of the mob the script is running on.
  mpecho $i turns to look your direction.
~
  • save the file name: GreeterMob.script
  • copy the full path name progs/areas/Midgaard/GreeterMob.script

In the grinder:

  • edit the mob (in this case it assumes he is in the Midgaard area, just according to the naming convention)
    • add the scriptable behavior
      • enter the following parameter: load=progs/areas/Midgaard/GreeterMob.script
        • note you can use paste to put in the path which you had copied earlier so you dont have to rekey it all and risk a typo

Thats it, next time you walk into the room with that mob, it should do the one line shown in the script.

Notes

.