lua/wrappers/game/lua_item.cpp
/**
	 * Sets the graphic by asset name for the item, can be set to nil.
	 *
	 * @param string asset_name The asset name for the new graphic for the item.
	 * @param boolean [false] calc_size Calculates the inventory size
	 *  of the item based off the graphic size. This is based off the
	 *  the size of the item compared to the size of each inventory slot size.
	 * @returns am.item This
	 */
Sets the graphic by asset name for the item, can be set to nil.
@param string asset_name The asset name for the new graphic for the item.
@param boolean [false] calc_size Calculates the inventory size
of the item based off the graphic size. This is based off the
the size of the item compared to the size of each inventory slot size.
Sets the graphic by asset name for the item can be set to nil . @param string asset_name The asset name for the new graphic for the item . @param boolean [ false ] calc_size Calculates the inventory size of the item based off the graphic size . This is based off the the size of the item compared to the size of each inventory slot size .
int Item_graphic(lua_State *lua)
	{
		Item *item = castUData<Item>(lua, 1);
		if (item)
		{
			if (lua_gettop(lua) == 1)
			{
				Sprite *graphic = item->getGraphic();
				if (graphic)
				{
					wrapRefObject<Sprite>(lua, graphic);
					return 1;
				}
				lua_pushnil(lua);
				return 1;
			}
			else if (lua_isnil(lua, 2))
			{
				item->setGraphic(nullptr);
			}
			else
			{
				Sprite *sprite = nullptr;
				int args = lua_gettop(lua);
				if (lua::gfx::getSprite(lua, 2, sprite) && (args == 2 || (args == 3 && lua_isbool(lua, 3))))
				{
					if (args == 3)
					{
						item->setGraphic(sprite, lua_tobool(lua, 3));
					}
					else
					{
						item->setGraphic(sprite);
					}
					lua_first(lua);
				}
			}
			return LuaState::expectedArgs(lua, "graphic", 3, "am.sprite graphic, bool [true] calc_size", "string asset_name, bool [true] calc_size", "nil graphic");
		}
		return LuaState::expectedContext(lua, "graphic", "am.item");
	}
int Item_graphic ( lua_State * lua ) { Item * item = castUData < Item > ( lua , 1 ) ; if ( item ) { if ( lua_gettop ( lua ) == 1 ) { Sprite * graphic = item -> getGraphic ( ) ; if ( graphic ) { wrapRefObject < Sprite > ( lua , graphic ) ; return 1 ; } lua_pushnil ( lua ) ; return 1 ; } else if ( lua_isnil ( lua , 2 ) ) { item -> setGraphic ( nullptr ) ; } else { Sprite * sprite = nullptr ; int args = lua_gettop ( lua ) ; if ( lua :: gfx :: getSprite ( lua , 2 , sprite ) && ( args == 2 || ( args == 3 && lua_isbool ( lua , 3 ) ) ) ) { if ( args == 3 ) { item -> setGraphic ( sprite , lua_tobool ( lua , 3 ) ) ; } else { item -> setGraphic ( sprite ) ; } lua_first ( lua ) ; } } return LuaState :: expectedArgs ( lua , " " , 3 , " " , " " , " " ) ; } return LuaState :: expectedContext ( lua , " " , " " ) ; }
Sets the graphic by asset name for the item, can be set to nil.
Sets the graphic by asset name for the item can be set to nil .