by DerDragon
A collection of useful functions. Includes BigIcons and IconMod
  • atom/proc/bigicon(icon/I,state)

    "I" being the icon you want to give to the atom, and state being the state of that icon. "I" can also be a list of icons for creating large overlays/underlays.

    State is the state of the icon, if "I" is given as a single argument. Alternatively, you can give "I" as an associative list, where each icon's associated value is the state it should be displayed as.
  • proc/importspritesheet(source,target,size_x=1,size_y=1,icons tate,moving,dela y)

    Source is the sprite sheet file for images to be taken from. It can either be single direction single frame, single direction multi frame, multi direction single frame, or multi direction mutli frame. Refer to the included pngs for format.

    Size_x and size_y are the dimensions of the sprites in "icons". I.e. a 32x32 mob would have a size_x and size_y of 1, while 64x64 would have a 2 of each.

    Iconstate, moving, and delay work exactly like icon.Insert() in the reference.

    This proc returns the newly updated icon, which you can then ftp to yourself and store seperately, or use immediately in your game!
  • atom/proc/iconcheck(refresh,icon/I,state)

    Refresh will force an update to an icon entry in the iconcache.

    "I" is the icon you want to use, if you don't specify one, the atom's default idcon will be used

    State is the state of the icon you want to use.

    Iconcheck will update an atom's icon based on it's color and effect vars. Before doing so, however, it will check if there is an entry in the iconcache that matches the atom's type and first two colors. This makes using iconcheck for lot of atoms very quick. Iconcheck will also use bigicon() to expand the size of the icon when appropriate using overlays.
  • atom/proc/iconstate(state,time,icon/I)

    State is the state you want to display of the atom. Keep in mind, this works for "large" atoms as well, just make sure you put the state name AFTER the coordinates in the icon file. Example "0,1stand" The importspritesheet() proc can help create these for you.

    Time is the amount of time you want this state displayed for. You can use this to "flick" certain states of an icon such as attack animations. If you don't specify a time variable, the state change will not revert.

    "I" is the icon to use, if none is specified, the default icon for the atom is used.
  • atom/proc/locloc()

    Returns the turf an atom is located on, or the atom if it is a turf or area. This is useful for finding the turf of an object nested inside (a)nother object(s).
  • proc/anim(image,loc,time,justme,below=-1,pixel_y,pixel_x,ico n_state)

    Image is the image to be displayed, it can be just about anything since an image is created of it anyways.

    Loc is the location for the image to be displayed.

    Time is the length of time for the image to be displayed. 1 second is the default if none is given.

    Justme can be a list or a single mob to show the image to. If left blank, the image will be shown to all mobs.

    If below is set to 1, the image will be displayed underneath loc. You can set this to a very large negative number to display the image above all objects.

    Pixel_x and pixel_y are the pixel shifts for the image.

    icon_state is the icon_state to be displayed of the image.
  • proc/between(a,b,c)

    Returns 1 if a is between b and c, 0 otherwise.
  • proc/fontcolor(color,n)

    Color is the color you want a rgb value for.

    N is the "shade" of the color you want an rgb value for. 1-4 are valid, 1 being the darkest shade. It defaults to 1.

    Returns a rgb value for the color specified.
  • proc/iconmod(icon/I,datum/src,trg,effect)

    "I" is the icon to be modified. This should be a "base" icon and should use the color values 64, 128, 192, and 255 of red, yellow, green, blue, cyan, magenta, orange, and gray. Orange is the only color that doesn't follow this exact convention, refer to the code for it's color values. Once an icon's color has been changed, it cannot be changed back, so if you want to repeatedly modify an icon, keep it's "base" icon somewhere. I'd recommend the initial() proc.

    Src is generally a color "region" you want to modify. For instance, "red" is all pixels in the icon that have the values rgb(255,0,0), rgb(192,0,0), rgb(128,0,0) and rgb(64,0,0). You MUST use the correct color values, and it may mean editing your BYOND palette. Src also accepts a list of colors if you want to change multiple "color regions" at once.

    Trg is the color you want to change src to. You will notice in the code that there are a LOT more trg colors, while there are only 8 src colors.

    Effect is the effect to be applied to the color region. This is optional, but there are a lot of neat effects that can be applied to color regions.
  • proc/playrelsound(sound/S,atom/src,list/listeners)

    S is the sound to be played.

    Src is the atom to play the sound 'from'.

    Listeners is a list of mobs to hear the sound.

    Playrelsound will use BYOND's sound system to create a "3d" sound based on the position of the src, and the position of each listener.
  • proc/snd(sound,list/listeners,atom/ src,f,c,repeat,p,e=2,v=100)

    Sound is the sound file to play.

    Listeners is the list of mobs that will hear the sound.

    Src is the source of the sound. (This is used for playrelsound, which is called by this proc)

    F is the frequency of the sound to be played.

    C is the channel for the sound to be played on, as normal, if none is specified, an open channel will be used.

    Repeat will repeat the sound if set to 1.

    P is the priority for the sound to be played.

    E is the environment for the sound to be played. (refer to the reference)

    V is the volume of the sound to be played. This also accepts the text strings "fadein" and "fadeout" which will gradually adjust the volume over 10 seconds from 0 to 100 or back. Keep in mind, "sound" can be an already playing sound, so you can use this to sort of "crossfade" music or ambient sound.
I'm curious. Are the second and third-mentioned procs implying that one can import DMI files into a live game world without the requirement of a restart?