2 registered members (TipmyPip, AndrewAMD),
12,726
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: HOW TO CALL A SCRIPT?
[Re: MrGuest]
#348980
12/02/10 13:29
12/02/10 13:29
|
Joined: Nov 2006
Posts: 497 Ohio
xbox
Senior Member
|
Senior Member
Joined: Nov 2006
Posts: 497
Ohio
|
okay so, your char_select.c
#include <acknex.h>
#include <default.c>
void function1()
{
}
PANEL* pan1 //sorry, don't know how to do panels in A7, i use A6
now, call functions and panels in main code...
#include <acknex.h>
#include <default.c>
#include "char_select.c" // your character selection code
void main()
{
function1();
set(pan1,VISIBLE);
}
As you can see, once you #include files, you can call the functions or panels like usual.
|
|
|
Re: HOW TO CALL A SCRIPT?
[Re: carla_mariz]
#349348
12/06/10 18:50
12/06/10 18:50
|
Joined: Sep 2009
Posts: 1,032 Budapest
Aku_Aku
Serious User
|
Serious User
Joined: Sep 2009
Posts: 1,032
Budapest
|
If you don't use any level, you should include this statement into your main function: level_load(NULL);Like this:
void main()
{
level_load(NULL);
function1();
set(pan1,VISIBLE);
}
The mechanism of the script usage is this: 1. include your script at the very beginning of your code 2. you can call/refer to your functions (inside the script) where you want
|
|
|
Re: HOW TO CALL A SCRIPT?
[Re: Aku_Aku]
#349408
12/07/10 07:43
12/07/10 07:43
|
Joined: Sep 2010
Posts: 97
carla_mariz
OP
Junior Member
|
OP
Junior Member
Joined: Sep 2010
Posts: 97
|
uhoh..theres an error..and it said, "Invalid Arguments in rotate_agent". i used a button to call for the function, the error appears whenever i clicked it. what would be the problem? here is the code from the main menu:
#include "choosechar.c"
function load_program()
{
while (key_any) {wait (1);}
level_load(NULL);
[color:#FF6600]rotate_agent();[/color]
main_pan.flags &= ~SHOW;
}
and here the the whole code from the choosechar.c:
#include "pacmanmaze1.c"
FONT* arial_font = "Arial#20";
var i = 0; // used as an index
var active_agents = 0;
STRING* name_str = "#30";
var speed = 50;
BMAP* mouse_pcx = "mouse.pcx";
TEXT* models_txt =
{
strings = 100;
}
PANEL* output_pan =
{
digits (120, 120, "Character name: %s ", arial_font, 1, name_str);
flags = SHOW;
}
typedef struct {
STRING* name;
ENTITY* agent_model;
} AGENTS;
AGENTS* taskforces[100];
[color:#FF6600]function rotate_agent()[/color]
{
while (active_agents)
{
my.pan += 4 * time_step;
wait (1);
}
ent_remove(my);
}
function create_agent(STRING *agent_name)
{
AGENTS* temp_agent = malloc(sizeof(AGENTS));
temp_agent.name = str_create(agent_name);
temp_agent.agent_model = ent_create(agent_name, vector(130, 0, -10), rotate_agent);
str_trunc(temp_agent.name, 4);
return temp_agent;
}
function main()
{
video_screen = 1;
mouse_map = mouse_pcx;
mouse_mode = 4;
var counter = 0;
level_load (NULL);
int j;
for(j = 0; j < 100; j++)
taskforces[j] = malloc(sizeof(AGENTS));
txt_for_dir(models_txt, "*.mdl");
while (str_len((models_txt.pstring)[i]) > 0)
{
i++;
}
i--;
while (1)
{
active_agents = 0;
wait (2);
active_agents = 1;
taskforces[i] = create_agent((models_txt.pstring)[counter]);
str_cpy(name_str, taskforces[i].name);
while (!key_cud && !key_cuu) {wait (1);}
counter += key_cud - key_cuu;
counter = clamp(counter, 0, i);
while (key_cud || key_cuu) {wait (1);}
}
}
PANEL* menu=
{
button (600, 500, "player_OVER.pcx", "player_OUT.pcx", "player_OVER.pcx", load_program, NULL, NULL);
flags = OVERLAY | SHOW;
}
function load_program()
{
while (key_any) {wait (1);}
level_load("pmaze1.wmb");
output_pan.flags &= ~SHOW;
menu.flags &= ~SHOW;
}
what function should i call??? thank you!!!:)
Last edited by carla_mariz; 12/07/10 07:44.
|
|
|
Re: HOW TO CALL A SCRIPT?
[Re: carla_mariz]
#349454
12/07/10 19:29
12/07/10 19:29
|
Joined: Sep 2009
Posts: 1,032 Budapest
Aku_Aku
Serious User
|
Serious User
Joined: Sep 2009
Posts: 1,032
Budapest
|
I suspect, the loading of the level destroy alll your previously created entities. Check it in the manual. Because in your main, there is a state when you put 0 into active_agents, when it happens, in rotate_agent the control reaches the ent_remove statement. The statement tries to remove an non-existent entity, it gives back an error. It is only speculation, without any test/try and coding/running.
Last edited by Aku_Aku; 12/07/10 19:31.
|
|
|
|