Ejemplo n.º 1
0
void SpellEntry::parse_lua_table(const LuaValue& table) {
	using namespace luawrap;

	sprite = res::sprite_id(table["spr_spell"].to_str());

	cooldown = table["cooldown"].to_num();
	mp_cost = table["mp_cost"].to_num();

	if (!table["projectile"].isnil()) {
		projectile = Projectile(
				get_projectile_by_name(table["projectile"].to_str()));
	}

	if (table["autotarget_func"].isnil()) {
		table["autotarget_func"] =
				luawrap::globals(table.luastate())["spell_choose_target"];
	}
	autotarget_func = LuaLazyValue(table["autotarget_func"]);
	LANARTS_ASSERT(!autotarget_func.get(table.luastate()).isnil());
	if (!table["action_func"].isnil()) {
		action_func = LuaLazyValue(table["action_func"]);
	}
	if (!table["prereq_func"].isnil()) {
		prereq_func = LuaLazyValue(table["prereq_func"]);
	}

	can_cast_with_cooldown = set_if_nil(table, "can_cast_with_cooldown", false);
	can_cast_with_held_key = set_if_nil(table, "can_cast_with_held_key", true);
	fallback_to_melee = set_if_nil(table, "fallback_to_melee", true);
}
Ejemplo n.º 2
0
	void lua_register_ldungeon(const LuaValue& submodule, bool register_lcommon = true) {
		lua_State* L = submodule.luastate();
		if (register_lcommon) {
			lua_register_lcommon(L);
		}
		lua_register_map(submodule);
		lua_register_areatemplate(submodule);
		lua_register_tunnelgen(submodule);
		register_libxmi_bindings(submodule);
	}
Ejemplo n.º 3
0
static void draw_loop(LuaValue draw_func) {
	int frames = 0;
	while (1) {
		frames += 1;
		SDL_Event event;
		while (SDL_PollEvent(&event)) {
			if (!handle_event(&event)) {
				return; // Exit draw loop
			}
		}
		ldraw::display_draw_start();
                draw_func.push();
                luawrap::call<void>(draw_func.luastate(), frames); 
		ldraw::display_draw_finish();
		SDL_Delay(5);
	}
}