Exemplo n.º 1
0
void	init(int argc, char *argv[])
{
	common_init(argc, argv);

	if (unz_exists("config.lua")) {
		script_load("config.lua");
	}

	audio_init();
	video_init();
	base_init();
	script_load("game.lua");
	script_call("init", NULL);
}
Exemplo n.º 2
0
//starts a new game on the given level
void StartNewGame(int start_level)
{
	Game_mode = GM_NORMAL;
	Function_mode = FMODE_GAME;

	Next_level_num = 0;

	InitPlayerObject();				//make sure player's object set up

	init_player_stats_game();		//clear all stats

	N_players = 1;
	#ifdef NETWORK
	Network_new_game = 0;
	#endif

#ifdef SCRIPT
	script_reset();
	script_load("default.scr");
#endif

	StartNewLevel(start_level);

	Players[Player_num].starting_level = start_level;		// Mark where they started

	game_disable_cheats();
}
Exemplo n.º 3
0
bool scriptapi_loadmod(lua_State *L, const std::string &scriptpath,
		const std::string &modname)
{
	ModNameStorer modnamestorer(L, modname);

	if(!string_allowed(modname, "abcdefghijklmnopqrstuvwxyz"
			"0123456789_")){
		errorstream<<"Error loading mod \""<<modname
				<<"\": modname does not follow naming conventions: "
				<<"Only chararacters [a-z0-9_] are allowed."<<std::endl;
		return false;
	}

	bool success = false;

	try{
		success = script_load(L, scriptpath.c_str());
	}
	catch(LuaError &e){
		errorstream<<"Error loading mod \""<<modname
				<<"\": "<<e.what()<<std::endl;
	}

	return success;
}
Exemplo n.º 4
0
int luaX_script_load(lua_State *L)
{
    const char *file = luaL_checkstring(L, 1);
    luna_script *result;

    luna_state *state = api_getstate(L);

    result = list_find(state->scripts, file, &script_cmp);

    if (result)
    {
        return luaL_error(L, "script '%s' already loaded", file);
    }
    else
    {
        if (!script_load(state, file))
        {
            result = list_find(state->scripts, file, &script_cmp);

            return luaX_push_scriptinfo(L, result);
        }
        else
        {
            return luaL_error(L, "failed to load script '%s'", file);
        }
    }
}
Exemplo n.º 5
0
int main(int c, char **v)
{
	struct st_config config;
	int config_result = NG;
	mm_init();
	switch(c){
	case 3: //t testmode target
		if(DEBUG == 0){
			goto usage;
		}
		//下へ
	case 4: //mode script target
	case 5:
		//mode script target flag
		//mode script target cpu_flash_device
	case 6:
		//mode script target flag mapper
		//mode script target cpu_flash_device ppu_flash_device
		config_result = config_init(c, (const char **) v, &config);
		break;
	usage:
	default:
		printf("famicom ROM cartridge utility - unagi version %s\n", STR_VERSION);
		printf("%s [mode] [mapper script] [target file] [flag]\n", v[0]);
		printf("mode - [d]ump ROM / [r]ead RAM/ [w]rite RAM/ [f]lash memory program\n");
		break;
	}
	if((config.mode != MODE_TEST) && (config_result == OK)){
		script_load(&config);
	}
	mm_end();
	return 0;
}
Exemplo n.º 6
0
static void gui_load_script_selected(const char *fn) {
    if (fn) {
        gui_menu_cancel_redraw();   // Stop menu redraw until after menu rebuilt from script params
        save_params_values(0);
        script_load(fn);
        gui_set_need_restore();
    }
}
Exemplo n.º 7
0
static void gui_reset_script_default(int arg)
{
    gui_menu_cancel_redraw();       // Stop menu redraw until after menu rebuilt from script params
    save_params_values(0);
    conf.script_file[0] = 0;        // Reset loaded script
    script_load(conf.script_file);
    gui_set_need_restore();
}
Exemplo n.º 8
0
int	trap_Call(lua_State *s)
{	
	const char *luafile;
	int returned;

	trap_args(s, "Call", "s", &luafile);
	returned = script_load(luafile);
	return returned;
}
Exemplo n.º 9
0
Arquivo: script.c Projeto: erikg/bmud
	/*
	 * such a nasty kludge. 
	 */
void
fake_main (int argc, char **argv)
{
    char *filename;

    filename = gethome_conf_file ("script.scm");
    script_load (filename, SCRIPT_GUILE);
    gtk_main ();
}
Exemplo n.º 10
0
/* Load a perl script from given data */
PERL_SCRIPT_REC *perl_script_load_data(const char *data)
{
	char *name;

        g_return_val_if_fail(data != NULL, NULL);

	name = script_data_get_name();
	return script_load(name, NULL, data);
}
Exemplo n.º 11
0
/* Load a perl script, path must be a full path. */
PERL_SCRIPT_REC *perl_script_load_file(const char *path)
{
	char *name;

        g_return_val_if_fail(path != NULL, NULL);

        name = script_file_get_name(path);
        return script_load(name, path, NULL);
}
Exemplo n.º 12
0
EXPORT
void
on_execute_menu_item_activate          (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{
        GtkWidget *file_chooser;
        GtkFileFilter *wizard_filter, *all_filter;
        int response;
        char *script_path;
        char *key;

        file_chooser = gtk_file_chooser_dialog_new ("Select script to run",
                        GTK_WINDOW (warlock_get_widget ("main_window")),
                        GTK_FILE_CHOOSER_ACTION_OPEN,
                        GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                        GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
                        NULL);

        key = preferences_get_key (PREF_SCRIPT_PATH);
        script_path = preferences_get_string (key);
        gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (file_chooser),
                        script_path);
        g_free (script_path);
        g_free (key);

        wizard_filter = gtk_file_filter_new ();
        gtk_file_filter_set_name (wizard_filter, "Wizard Scripting files");
        gtk_file_filter_add_pattern (wizard_filter, "*.[Cc][Mm][Dd]");
        gtk_file_filter_add_pattern (wizard_filter, "*.[Ww][Ii][Zz]");
        gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (file_chooser),
                        wizard_filter);

        all_filter = gtk_file_filter_new ();
        gtk_file_filter_set_name (all_filter, "All files");
        gtk_file_filter_add_pattern (all_filter, "*");
        gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (file_chooser),
                        all_filter);

        response = gtk_dialog_run (GTK_DIALOG (file_chooser));

        if (response == GTK_RESPONSE_ACCEPT) {
                char *filename;

                filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER
                                (file_chooser));
                script_load (filename, 0, NULL);
                g_free (filename);
        }

        gtk_widget_destroy (file_chooser);

}
Exemplo n.º 13
0
void gui_load_user_menu_script(const char *fn) 
{
    if (fn) {
#ifdef OPT_SCRIPTING
		script_load(fn, SCRIPT_LOAD_LAST_PARAMSET );
		load_params_names_cfg();
#endif

        // exit menu system on the assumption the user will want to run the script just loaded

        gui_set_mode(&altGuiHandler);
        kbd_reset_autoclicked_key();
        rinit();
    }
}
Exemplo n.º 14
0
Arquivo: script.c Projeto: erikg/bmud
void
script_init (int argc, char **argv)
{
#ifdef USE_PERL
    char *filename;

    perl_env = perl_alloc ();
    perl_construct (perl_env);
    filename = gethome_conf_file ("script.pl");
    script_load (filename, SCRIPT_PERL);
#endif

#ifdef USE_GUILE
    gh_enter (argc, argv, fake_main);
#endif
}
Exemplo n.º 15
0
static void conf_change_script_file() {
    script_load(conf.script_file, 2);
}
Exemplo n.º 16
0
Arquivo: menu.c Projeto: atrinik/dwc
/**
 * Analyze /cmd type commands the player has typed in the console or bound to a key.
 * Sort out the "client intern" commands and expand or pre process them for the server.
 * @param cmd Command to check
 * @return 0 to send command to server, 1 to not send it */
int client_command_check(char *cmd)
{
	if (!strncasecmp(cmd, "/ready_spell", 12))
	{
		cmd = strchr(cmd, ' ');

		if (!cmd || *++cmd == 0)
		{
			draw_info("Usage: /ready_spell <spell name>", COLOR_GREEN);
		}
		else
		{
			int i, ii;

			for (i = 0; i < SPELL_LIST_MAX; i++)
			{
				for (ii = 0; ii < DIALOG_LIST_ENTRY; ii++)
				{
					if (spell_list[i].entry[0][ii].flag >= LIST_ENTRY_USED)
					{
						if (!strcmp(spell_list[i].entry[0][ii].name, cmd))
						{
							if (spell_list[i].entry[0][ii].flag == LIST_ENTRY_KNOWN)
							{
								fire_mode_tab[FIRE_MODE_SPELL].spell = &spell_list[i].entry[0][ii];
								RangeFireMode = FIRE_MODE_SPELL;
								sound_play_effect("scroll.ogg", MENU_SOUND_VOL);
								draw_info("Spell ready.", COLOR_GREEN);
								return 1;
							}
						}
					}

					if (spell_list[i].entry[1][ii].flag >= LIST_ENTRY_USED)
					{
						if (!strcmp(spell_list[i].entry[1][ii].name, cmd))
						{
							if (spell_list[i].entry[1][ii].flag==LIST_ENTRY_KNOWN)
							{
								fire_mode_tab[FIRE_MODE_SPELL].spell = &spell_list[i].entry[1][ii];
								RangeFireMode = FIRE_MODE_SPELL;
								sound_play_effect("scroll.ogg", MENU_SOUND_VOL);
								draw_info("Spell ready.", COLOR_GREEN);
								return 1;
							}
						}
					}
				}
			}
		}

		draw_info("Unknown spell.", COLOR_GREEN);
		return 1;
	}
	else if (!strncasecmp(cmd, "/pray", 5))
	{
		/* Give out "You are at full grace." when needed -
		 * server will not send us anything when this happens */
		if (cpl.stats.grace == cpl.stats.maxgrace)
			draw_info("You are at full grace. You stop praying.", COLOR_WHITE);
	}
	else if (!strncasecmp(cmd, "/keybind", 8))
	{
		map_udate_flag = 2;

		if (cpl.menustatus != MENU_KEYBIND)
		{
			keybind_status = KEYBIND_STATUS_NO;
			cpl.menustatus = MENU_KEYBIND;
		}
		else
		{
			save_keybind_file(KEYBIND_FILE);
			cpl.menustatus = MENU_NO;
		}

		sound_play_effect("scroll.ogg", 100);
		reset_keys();
		return 1;
	}
	else if (!strncmp(cmd, "/target", 7))
	{
		/* Logic is: if first parameter char is a digit, is enemy, friend or self.
		 * If first char a character - then it's a name of a living object. */
		if (!strncmp(cmd, "/target friend", 14))
			strcpy(cmd, "/target 1");
		else if (!strncmp(cmd,"/target enemy", 13))
			strcpy(cmd, "/target 0");
		else if (!strncmp(cmd, "/target self", 12))
			strcpy(cmd, "/target 2");
	}
	else if (!strncmp(cmd, "/help", 5))
	{
		cmd += 5;

		if (cmd == NULL || strcmp(cmd, "") == 0)
			show_help("main");
		else
			show_help(cmd + 1);

		return 1;
	}
	else if (!strncmp(cmd, "/script ", 8))
	{
		cmd += 8;

		if (!strncmp(cmd, "load ", 5))
		{
			cmd += 5;

			script_load(cmd);
		}
		if (!strncmp(cmd, "unload ", 7))
		{
			cmd += 7;

			script_unload(cmd);
		}
		else if (!strncmp(cmd, "list", 4))
		{
			script_list();
		}
		else if (!strncmp(cmd, "send ", 5))
		{
			cmd += 5;

			script_send(cmd);
		}

		return 1;
	}
	else if (!strncmp(cmd, "/shop", 5))
	{
		if (!shop_gui)
		{
			initialize_shop(SHOP_STATE_NONE);
		}
		else
		{
			draw_info("You must close the shop window before trying to set up another shop.", COLOR_RED);
		}

		return 1;
	}
	else if (!strncmp(cmd, "/ignore", 7))
	{
		ignore_command(cmd + 7);
		return 1;
	}
	else if (!strncmp(cmd, "/reply", 6))
	{
		cmd = strchr(cmd, ' ');

		if (!cmd || *++cmd == '\0')
		{
			draw_info("Usage: /reply <message>", COLOR_RED);
		}
		else
		{
			if (!cpl.player_reply[0])
			{
				draw_info("There is no one you can /reply.", COLOR_RED);
			}
			else
			{
				char buf[2048];

				snprintf(buf, sizeof(buf), "/tell %s %s", cpl.player_reply, cmd);
				send_command(buf);
			}
		}

		return 1;
	}
	else if (!strncmp(cmd, "/resetwidgets", 13))
	{
		reset_widget(NULL);
		return 1;
	}
	else if (!strncmp(cmd, "/resetwidget", 12))
	{
		cmd = strchr(cmd, ' ');

		if (!cmd || *++cmd == '\0')
		{
			draw_info("Usage: /resetwidget <name>", COLOR_RED);
		}
		else
		{
			reset_widget(cmd);
		}

		return 1;
	}

	return 0;
}