Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (NnamueN, 1 invisible), 1,489 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19054 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
HOW TO CALL A SCRIPT? #348844
12/01/10 07:03
12/01/10 07:03
Joined: Sep 2010
Posts: 97
C
carla_mariz Offline OP
Junior Member
carla_mariz  Offline OP
Junior Member
C

Joined: Sep 2010
Posts: 97
hello,
i know that this is very simple question, but i still wanted to ask. i'm just new to this so i hope you could help me.

i'm creating a menu and in the menu, when the player clicked PLAY,it will go to SELECTION OF CHARCTERS.
i declared #include "script.c" into the menu code and it says, "Cant open file".
i just wanted to know what is the correct code for this?
im trying to call the code for the selection of character but it doesn't work.

thanks!:)

bdw, im using A7:)

Re: HOW TO CALL A SCRIPT? [Re: carla_mariz] #348850
12/01/10 08:11
12/01/10 08:11
Joined: Feb 2010
Posts: 886
Random Offline
User
Random  Offline
User

Joined: Feb 2010
Posts: 886
No you must declared #include "script.c" obove youre main code, like this;


#include "script.c"

function main()
{
blablablabla
level_load (blabla);
blablablabla
}

...




Re: HOW TO CALL A SCRIPT? [Re: Random] #348856
12/01/10 08:29
12/01/10 08:29
Joined: Sep 2010
Posts: 97
C
carla_mariz Offline OP
Junior Member
carla_mariz  Offline OP
Junior Member
C

Joined: Sep 2010
Posts: 97
if i do that and when i run the program, the buttons won't work and the "script.c" level is overlapped by the menu. frown

here is my menu code:
Code:
#include <acknex.h>
#include <default.c>
//#include "level2code.c"

//

////////////////////////////////////////////////////////////////////
var speed = 50;

BMAP* mouse_pcx = "mouse.pcx"; // bitmap used for the mouse pointer

///////////////////////////////////////////////////////////

function main()
{
//video_screen = 1;
  screen_size.x = 800;
  screen_size.y = 600;
  mouse_map = mouse_pcx;
  mouse_mode = 4;
}

PANEL* main_pan =
{
	layer = 30;
	bmap = "pacmantittle2.jpg";
 	pos_x = -90;     
 	pos_y = 0; 
 	button (390, 250, "player_OVER.pcx", "player_OUT.pcx", "player_OVER.pcx", load_program, NULL, NULL);      
 	button (400, 290, "lan_OVER.pcx", "lan_OUT.pcx", "lan_OVER.pcx", load_program, NULL, NULL);      
 	button (380, 330, "instructions_OVER.pcx", "instructions_OUT.pcx", "instructions_OVER.pcx", instruction_program, NULL, NULL);      
 	button (395, 370, "settings_OVER.pcx", "settings_OUT.pcx", "settings_OVER.pcx", exit_program, NULL, NULL);      
 	button (390, 410, "about_OVER.pcx", "about_OUT.pcx", "about_OVER.pcx", exit_program, NULL, NULL);      
 	button (395, 450, "exit_OVER.pcx", "exit_OUT.pcx", "exit_OVER.pcx", exit_program, NULL, NULL);      
	flags = OVERLAY | SHOW;
}
//////////////////////////////////////////////
////////////////////////////////////////////////////////

function instruction_program()
{
	while (key_any) {wait (1);}
	level_load("instruct.c");
		main_pan.flags &= ~SHOW;
   //sys_exit(main_pan);
	
}

#include "choosechar.c"

function load_program()
{
	while (key_any) {wait (1);}
	level_load("choosechar.c");
	main_pan.flags &= ~SHOW;
	
   //sys_exit(main_pan);
}

function exit_program()
{
	while (key_any) {wait (1);}
	
	sys_exit(NULL);
}


//////////////////////////////////////////////////////////////////////




and here is the choose character code:
Code:
////////////////////////////////////////////////////////////////////

#include <acknex.h>
#include <default.c>



/////////////////////////////////////////////////////////////////////

FONT* arial_font = "Arial#20";

/////////////////////////////////////////////////////////////////////

var i = 0; // used as an index
var active_agents = 0; // removes the old agent models that aren't used anymore

/////////////////////////////////////////////////////////////////////

STRING* name_str = "#30"; // used to display the name of the agent, holds up to 30 characters

/////////////////////////////////////////////////////////////////////

TEXT* models_txt =
{
	strings = 100; // store up to 100 model names
}

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];

function rotate_agent()
{
	while (active_agents)
	{
		my.pan += 4 * time_step;
		wait (1);	
	}	
	ent_remove(my); // remove the agent model when it isn't needed anymore
}

function create_agent(STRING *agent_name) 
{
   AGENTS* temp_agent = malloc(sizeof(AGENTS)); // create a new agent
   temp_agent.name = str_create(agent_name); // create the string that holds the agent's name
  	temp_agent.agent_model = ent_create(agent_name, vector(130, 0, -10), rotate_agent); // create the agent model
	str_trunc(temp_agent.name, 4); // now cut its name tail (.mdl) because we don't want to display it
   return temp_agent; // returns the address of the struct for further use (might be needed in the future)
}

function main() 
{
	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"); // loads the model names
	while (str_len((models_txt.pstring)[i]) > 0) // the name of the string contains something useful? (a model name)
	{
		i++;
	}
	i--; // set the proper index (i was incremented once more before we got out of the loop)
	// i stores the total number of agent models in the project folder here
	while (1)
	{
		active_agents = 0; // remove the previous agent model
		wait (2); // give it enough time to be removed
		active_agents = 1; // keep the new agent alive
  		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("level2maze.wmb");
	menu.flags &= ~SHOW;
	
   //sys_exit(main_pan);
}




thanks!


Last edited by carla_mariz; 12/01/10 08:32.
Re: HOW TO CALL A SCRIPT? [Re: carla_mariz] #348882
12/01/10 14:53
12/01/10 14:53
Joined: Dec 2006
Posts: 1,086
Queensland - Australia
Nidhogg Offline
Serious User
Nidhogg  Offline
Serious User

Joined: Dec 2006
Posts: 1,086
Queensland - Australia
All scripts must be included before any manin code.
eg:

#include <acknex.h>
#include <default.c>
#include "instruct.c"

var speed = 50;
BMAP* mouse_pcx = blah blah blah

function main()
{
blah;
blah;
blah;
}

Where you have! level_load("choosechar.c");
You must specify a level.wmb NOT a script.
eg: level_load("main_game.wmb")


Windows XP SP3
Intel Dual Core CPU: E5200 @ 2.5GHz
4.00GB DDR3 Ram
ASUS P5G41T-M LX
PCIE x16 GeForce GTS 450 1Gb
SB Audigy 4
Spyware Doctor with AntiVirus
Re: HOW TO CALL A SCRIPT? [Re: Nidhogg] #348939
12/01/10 23:35
12/01/10 23:35
Joined: Sep 2010
Posts: 97
C
carla_mariz Offline OP
Junior Member
carla_mariz  Offline OP
Junior Member
C

Joined: Sep 2010
Posts: 97
but, what if i dont have a level.wmb? just a script? how can i do that? laugh

Re: HOW TO CALL A SCRIPT? [Re: carla_mariz] #348943
12/02/10 02:21
12/02/10 02:21
Joined: Dec 2010
Posts: 13
T
tasha19 Offline
Newbie
tasha19  Offline
Newbie
T

Joined: Dec 2010
Posts: 13
how can i put an object into the block of a board game?? we tried using event_click but it doesn't work. do we also need to put the pathfinding? and where would we program it? on WED or SED?? asap reply needed thanks laugh

Re: HOW TO CALL A SCRIPT? [Re: tasha19] #348946
12/02/10 04:23
12/02/10 04:23
Joined: Nov 2006
Posts: 497
Ohio
xbox Offline
Senior Member
xbox  Offline
Senior Member

Joined: Nov 2006
Posts: 497
Ohio
@tasha19 - wrong thread.

@carla - if you just want to run code, you don't need a level_load. All you do is include the scripts as shown above, then in the main function, call the separate functions from different scripts. If it says,"Cannot open file" the script is not in the same location as the main script. I know in A6 you can define a PATH to look for stuff.

Re: HOW TO CALL A SCRIPT? [Re: xbox] #348962
12/02/10 09:59
12/02/10 09:59
Joined: Sep 2010
Posts: 97
C
carla_mariz Offline OP
Junior Member
carla_mariz  Offline OP
Junior Member
C

Joined: Sep 2010
Posts: 97
uhm...what will be the code for calling that script? im sorry i just couldn't understand it yet..:([

Re: HOW TO CALL A SCRIPT? [Re: carla_mariz] #348973
12/02/10 12:22
12/02/10 12:22
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Please, finish all workshops!!!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: HOW TO CALL A SCRIPT? [Re: 3run] #348974
12/02/10 12:28
12/02/10 12:28
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
use
Code:
#include "scriptname.c" //for including the file

function functionname(){
  beep();
}

..void main(){
   functionname(); //for calling function
}



Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1