[Guide] How to use icon variables

Discussion for ongoing CM development. Visible to Donors.
Post Reply
User avatar
Infernus
Registered user
Posts: 985
Joined: 16 Oct 2014, 17:02
Location: Croatia

[Guide] How to use icon variables

Post by Infernus » 19 Jan 2016, 17:36

So, you head probably exploded due to all icon variables you see and no documented comments on them. I hope this guide will somewhat explain what each of them does.

icon
This variable defines a path to the .dmi file where icon_state and icon_color is checked.

It does not point to where the mob overlays are (Helmet where your head is, gloves where your hands are...), that is done automatically in code.

icon_state
This variable defines the name of the sprite inside the .dmi file that icon var defined. This is the variable that displays the sprite in the game, like doors, machines, guns and items on your HUD.

If that item can be equipped on, lets say, your belt slot, the sprite name inside icons/mob/belt must be the same as icon_state for it to be visible on your little mob. If it doesn't exists, and it is set to be able to go to that slot, it will be invisible on your mob. If you wish for it to appear in your hands, use item_state too.

item_color
Used only by some special uniforms and gloves, probably for washing machines and coloring with crayons. If item_color is used, icon_state is ignored when applying some overlays on your mob, so don't use it if you don't know what you are doing.

item_state
Item state defines the name of the sprite in icons/mob/items_lefthand_0.dmi and icons/mob/items_roghthand_0.dmi, which is then used to display the sprite overlay in the mob hands. If you wish to use items_lefthand_1 and items_righthand_1, check the sprite_sheet_id variable.

icon_override
For the love of god, DO NOT USE THIS. The person who made it should die. It overrides the location where the code looks for sprites which will be applied to the mob. It is used to bypass the icon limit per .dmi file, but it doesn't allow you to use that icon for multiple slots.

If you, for some reason want to use it, it works similar as icon variable, but also forces the game to look for overlays inside it, instead of in icons/mob folder. Since you cannot have multiple sprites with the same names, it only allows one sprite to be used)

sprite_sheet_id
Aww yisss...
Not this is a proper way to bypass icon limit.

If set to sprite_sheet_id = 0 (default),
game looks for overlays in these files in icons/mob:
  • items_lefthand_0.dmi
  • items_righthand_0.dmi
  • head_0.dmi
  • suit_0.dmi
  • uniform_0.dmi
If set to sprite_sheet_id = 1,
game looks for overlays in these files in icons/mob:
  • items_lefthand_1.dmi
  • items_righthand_1.dmi
  • head_1.dmi
  • suit_1.dmi
  • uniform_1.dmi
And other files, it doesn't matter what sprite_sheet_id is set to, as there is enough space for them. Like:
  • belt.dmi
  • suit_slot.dmi
  • back.dmi
  • mask.dmi
  • ....dmi
So, let's say you want to use this variable for your new gun, you would set it to 1, and use the following icon files:
  • items_lefthand_1.dmi
  • items_righthand_1.dmi
  • belt.dmi
  • suit_slot.dmi
  • back.dmi
Using this var also greatly reduces time the game requires to find the right sprite, as it doesn't have to go trough 300 sprites to find the right one.

Post Reply