Next Previous Contents

4. Miscellaneous functions

4.1 Adding a color in Dil

Function: addcolor (ch : unitptr, ks : string, cstr : string ) ;

ch

character you are adding the color to

ks

key string for the color

cstr

color string

This function allows your Dils to create and add their own personal colors to a players color list. That way you can actually make an act in a color that the player chooses or you yourself choose.

Function: addcolor(pc, "clan_who","&c+w&bn");

4.2 deleting a color in Dil

Function: addcolor (ch : unitptr, ks : string) ;

ch

character you are deleting the color from

ks

key string for the color

This function is used to delete any colors from a players personal color list.

Function: delcolor(pc, "clan_who");

4.3 Getting a color

Function: getcolor (ch : unitptr, ks : string) ;

ch

character you are deleting the color from

ks

key string for the color

This function returns what color a player has for a key in the players list.

Function: string := getcolor(pc, "clan_who");

4.4 Changing a color

Function: addcolor (ch : unitptr, ks : string, cstr : string ) ;

ch

character you are adding the color to

ks

key string for the color

cstr

color string

This will change a color in a players personal list.

Function: changecolor(pc, "clan_who","&c+w&bn");

4.5 Changing the Game state

Function: gamestate( u : unitptr, gs : integer );

Change the gamestate of a unitptr, uses the GS_ defines from the vme.h. This is used on the log on menu of the VME 2.0 release. which is shown here as an example but it can also be used in a command. When used it removes the char from playing so be aware that players could use this to hide if you run a player killing style mud.

Example:



dilbegin informer();
var
tgt : unitptr;
code
{
heartbeat := PULSE_SEC;

tgt := ghead();

while(tgt.type == UNIT_ST_PC)
{

 if((isset(tgt.pcflags,PC_INFORM)) and (tgt != self))
 {
        if(visible(tgt,self))
        {
        if(self.outside == tgt.outside)
         sendtext(self.name+" has arrived.&n", tgt);
          else
           sendtext(self.name+" has entered the world.&n", tgt);
        }
 }

tgt := tgt.gnext;
}

return;
}
dilend

dilbegin aware on_connect();
external
        informer();
        login_modify(tgt : unitptr);

var
  wizlvl : integer;
        i:integer;
err : integer;
motd : string;
welcome : string;
goodbye : string;
code
{
heartbeat := PULSE_SEC;

if(dilfind("do_quit@commands",self))
        i := dildestroy("do_quit@commands", self);

err := loadstr("motd",motd);

if(err > 0)
{
        motd := textformat(motd);
        sendtext(motd+"&n&n", self);

}

err := loadstr("welcome",welcome);
if(welcome)
        welcome := textformat(welcome);

if (self.level < 200)
{

login_modify(self);
dilcopy ("clan_delete@clans",self);
dilcopy ("clan_clear@clans",self);


if(err > 0)
        sendtext("&n"+welcome+"&n&n", self);
  informer();
  exec("look", self);
  quit;
}
gamestate(self, GS_MENU);

:wiz_menu:
sendtext("Welcome to Valhalla&n&n", self);
sendtext("1) Enter Valhalla&n", self);
sendtext("W) Change Wizinv level&n [&c+g"+itoa(self.minv)+"&[default]]&n",self);
sendtext("0) Exit Valhalla&n&n", self);
sendtext("Make your choice: ", self);
wait(SFB_CMD, TRUE);

if (command("1") )
{
  gamestate(self, GS_PLAY);
  if(err > 0)
        sendtext("&n"+welcome+"&n&n", self);
  informer();
  exec("look", self);
  quit;
} else if (command("0") ) {
  err := loadstr("goodbye",goodbye);
  if(err > 0)
  {
  goodbye := textformat(goodbye);
  sendtext(goodbye, self);
  }
  destroy(self);
  quit;
} else if (command("w") ) {
  sendtext("Enter new WizInv Level: ", self);
  wait(SFB_CMD, TRUE);
  wizlvl := atoi(cmdstr);
  if (wizlvl > self.level)
    wizlvl := self.level;
  self.minv := wizlvl;
} else {
  sendtext("Invalid Selection&n&n", self);
  goto wiz_menu;
}

}
dilend

Look in vme.h for the possible values you can send to the menu function.

4.6 Does an item fit

Function: string fits ( ch : unitptr, obj : unitptr, n : integer);

ch

character you are checking for a fit

obj

object you are checking if fits

n

the wear position in 'VME.h'

returns

'way to small', 'to small', 'way to large', 'to large', or null if fits

This will return if an item fits or a string describing why not if not.

Example:


act_str:=fits(ch,obj,WEAR_BODY);
if (act_str=="")
        sendtext ("This object fits!",self);
else
        sendtext ("This object is "+act_str+" to fit.&n",self);
        quit;
        }
        
        

4.7 Getting a weapons name

Function: string weapon_name( i : integer ) ;

i

Weapon to get the name of ass defined in 'values.h' and 'weapons.def'

returns

The name of the weapon that corresponds with the integer value

example:



myweap:=weapon_name(5);

4.8 Getting a weapons info

Function: intlist weapon_info( i : integer ) ;

i

Weapon to get the info of as defined in 'values.h' and 'weapons.def'

returns

Intlist containing 4 values:

0

Number of hands

1

weapon speed

2

weapon type

3

shield block value

This function gives you access to the values in the weapons.def file. With this things like 'wear' equipment' and 'look' are much easier to write in Dil.

Example



dilcopy id_weap (arg:string);
var
  i:integer;
  il:intlist;
code
{
il:=weapon_info(atoi(arg));

if (il!=null)
{
sendtext ("Number of hands:  "+itoa(il.[0])+"&n";
             sendtext ("Speed:  " +itoa(il.[1])+"&n",self);
                         sendtext ("Type:  "+itoa(il.[0])+"&n",self);    
                         sendtext ("Shield value:  "+itoa(il.[0])+"&n",self);    
                         }
else
{
sendtext ("No such weapon.&n",self);  
}

quit;
}
dilend                   
                         

4.9 Getting a skills name

Function: string skill_name( i : integer ) ;

i

Skill to get the name of ass defined in 'values.h' and 'commands.def'

returns

The name of the skill that corresponds with the integer value

example:



myski:=skill_name(5);

4.10 Is an unit a light label id="sect-islight">

Function: integer islight ( u : unitptr )

u

Unit that you are checking

returns

''TRUE' if item is a light, 'FALSE' if it is notway to small', 'to small', 'way to large', 'to large', or null if fits

Simply checks the item to see if it is a light.

4.11 Reboot the mud

Function: reboot ;

This function works like a quit command. Anything after the reboot function in a Dil will not be executed the mud will reboot instantly. The zone must have root privileges in the zonelist in order to use this function.

Simple reboot command



dilbegin cmd_reboot (arg:string);
code
{
sendtext ("Rebooting the mud.&n",self);
reboot;
}
dilend


Next Previous Contents