lua/wrappers/game/lua_dialogue_component.cpp
/**
	 * Sets the starting dialogue this component will use when talked to, can be nil.
	 * @param am.dialogue dialogue The dialogue to open with.
	 * @returns am.dialogue_component This
	 */
Sets the starting dialogue this component will use when talked to, can be nil.
Sets the starting dialogue this component will use when talked to can be nil .
int DialogueComponent_start_dialogue(lua_State *lua)
	{
		DialogueComponent *comp = castUData<DialogueComponent>(lua, 1);
		if (comp)
		{
			if (lua_gettop(lua) == 1)
			{
				Dialogue *diag = comp->getStartDialogue();
				if (diag)
				{
					wrapRefObject<Dialogue>(lua, diag);
					return 1;
				}
				lua_pushnil(lua);
				return 1;
			}
			else if (lua_isnil(lua, 2))
			{
				comp->setStartDialogue(nullptr);
				lua_first(lua);
			}
			else
			{
				bool valid = true;
				Dialogue *diag = nullptr;
				if (lua_isstr(lua, 2))
				{
					diag = Engine::getGame()->getDialogue(lua_tostring(lua, 2));
				}
				else
				{
					diag = castUData<Dialogue>(lua, 2);
					if (!diag)
					{
						valid = false;
					}
				}
				if (valid)
				{
					comp->setStartDialogue(diag);
					lua_first(lua);
				}
				return LuaState::expectedArgs(lua, "start_dialogue", 3, "string dialogue_id", "am.dialogue dialogue", "nil dialogue");
			}
		}
		return LuaState::expectedContext(lua, "start_dialogue", "am.dialogue_component");
	}
int DialogueComponent_start_dialogue ( lua_State * lua ) { DialogueComponent * comp = castUData < DialogueComponent > ( lua , 1 ) ; if ( comp ) { if ( lua_gettop ( lua ) == 1 ) { Dialogue * diag = comp -> getStartDialogue ( ) ; if ( diag ) { wrapRefObject < Dialogue > ( lua , diag ) ; return 1 ; } lua_pushnil ( lua ) ; return 1 ; } else if ( lua_isnil ( lua , 2 ) ) { comp -> setStartDialogue ( nullptr ) ; lua_first ( lua ) ; } else { bool valid = true ; Dialogue * diag = nullptr ; if ( lua_isstr ( lua , 2 ) ) { diag = Engine :: getGame ( ) -> getDialogue ( lua_tostring ( lua , 2 ) ) ; } else { diag = castUData < Dialogue > ( lua , 2 ) ; if ( ! diag ) { valid = false ; } } if ( valid ) { comp -> setStartDialogue ( diag ) ; lua_first ( lua ) ; } return LuaState :: expectedArgs ( lua , " " , 3 , " " , " " , " " ) ; } } return LuaState :: expectedContext ( lua , " " , " " ) ; }
Sets the starting dialogue this component will use when talked to, can be nil.
Sets the starting dialogue this component will use when talked to can be nil .