Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 959 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 3 1 2 3
Re: Wierd invalid pointer. [Re: draculaFactory] #340429
09/04/10 09:19
09/04/10 09:19
Joined: Feb 2005
Posts: 647
Williamsburg, VA USA
draculaFactory Offline OP
User
draculaFactory  Offline OP
User

Joined: Feb 2005
Posts: 647
Williamsburg, VA USA
any luck so far?


Making dreams come true... And being erroneously accused of software piracy by Conitec in the process.
Re: Wierd invalid pointer. [Re: draculaFactory] #340522
09/04/10 23:53
09/04/10 23:53
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Not so far... I havent had that much time, but something "odd" is happening...

Im still looking...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Wierd invalid pointer. [Re: EvilSOB] #340523
09/05/10 00:29
09/05/10 00:29
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
It appears to be due to a known, POSSIBLE engine bug with handles...

See THIS thread thats still waiting on JCL to return.

In the meantime I'll modify your script to NOT use handles if I can.
I think I see a way...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Wierd invalid pointer. [Re: EvilSOB] #340525
09/05/10 00:49
09/05/10 00:49
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Went easier than expected... And only minimal changes required...
Click to reveal..
Code:
// data structure
#include <acknex.h>
#include <default.c>

STRING* test = "test.wmb";

BMAP* arrow_cursor_bmp = "arrow.tga";


var total_panels = 0;			// total number of registered panels
PANEL* panel_list[64];			// panel list array



// sets resolution, depth, and window mode and alters aspect
function set_resolution(_x,_y,_depth,_window)
{
	var new_ratio;
	var view_aspect;
	
	video_set(_x,_y,_depth,_window);
	wait(1);
	
	//if fullscreen, alter aspect
	if(video_screen == 1)
	{
		new_ratio = _x / _y;
		view_aspect = new_ratio / 1.6;
		camera.aspect = view_aspect;
	}
	
	// frame rate
	fps_max = 60;
	fps_lock = 1;
	time_factor = 1;
	
}


// main mouse function
function init_mouse()
{
	
	// local vectors
	VECTOR temp_vec;
	
	// mouse properties
	mouse_mode = 1;
	mouse_pointer = 0;
	
	// mouse start position
	wait(1);
	mouse_pos.x = (screen_size.x / 2);
	mouse_pos.y = (screen_size.y / 2);
	
	// change to default cursor
	mouse_map = arrow_cursor_bmp;
	
	// loop forever
	while(1)
	{
		
		// if mouse valid
		if(mouse_valid == 1)
		{
			
			// update mouse position
			vec_set(mouse_pos.x,mouse_cursor.x);
			
		}
		
		wait(1);
	}
}


// main startup function
function main()
{
	
	// set the resolution
	set_resolution(1440,900,32,1);
	
	// buffer before level load
	wait(3);
	
	// load level
	level_load(test);
	
	init_mouse();
}


// displays on screen text at a position for a limited time
function display_text(var x_pos, var y_pos, STRING* text_str, var seconds)
{
	
	proc_mode = PROC_LATE;
	
	var panel_size_x = 0;
	var font_height = 15;
	var display_count = 0;
	
	// set seconds to ticks
	seconds *= 16;
	
	// set draw text mode
	draw_textmode("Arial",0,font_height,100);
	
	// loop while mouse is over this entity
	while(display_count < seconds)
	{
		
		// position and show description
		panel_size_x = str_width(text_str,NULL);
		font_height = 15;
		
		draw_quad(NULL,vector(x_pos + 2,y_pos,0),NULL,vector(panel_size_x + 4,font_height,0),NULL,vector(1,1,1),100,0);
		draw_text(text_str,x_pos + 2,y_pos,vector(255,255,255));
		
		display_count = minv(display_count + (1 * time_step),seconds);
		
		wait(1);
	}
}


function sort_panels(PANEL* panel)
{
	if(panel==NULL)		return;		//invalid panel parameter
	//
	var list_no;	for(list_no=0;	list_no<total_panels;	list_no++)
	{	if(panel_list[list_no]!=NULL) 
			if(panel_list[list_no].layer > panel.layer)
				layer_sort(panel_list[list_no], panel_list[list_no].layer-1);
	}
	layer_sort(panel,total_panels);
}



//moves a panel with mouse
function move_panel(PANEL* panel)
{
	
	//local variables
	VECTOR panel_vec;
	VECTOR pointer_vec;
	VECTOR panel_offset;
	
	vec_set(panel_vec.x,vector(panel.pos_x,panel.pos_y,0));
	
	//get initial mouse position
	pointer_vec.x = mouse_pos.x;
	pointer_vec.y = mouse_pos.y;
	
	sort_panels(panel);
	
	// while mouse held, loop
	while(mouse_left == 1)
	{
		panel_offset.x = mouse_pos.x - pointer_vec.x;
		panel_offset.y = mouse_pos.y - pointer_vec.y;
		
		panel.pos_x = panel_vec.x + panel_offset.x;
		panel.pos_y = panel_vec.y + panel_offset.y;
		
		// restrict panel positions to on-screen
		panel.pos_x = clamp(panel.pos_x,0,screen_size.x - panel.size_x);
		panel.pos_y = clamp(panel.pos_y,0,screen_size.y - panel.size_y);
		
		wait(1);
	}
}


// register the panel
function register_panel(PANEL* panel)
{
	panel_list[total_panels] = panel;
	total_panels ++;
}


// inventory art
BMAP* backpack_bmp = "backpack_panel.tga";
BMAP* items_bmp = "item_icons.tga";
BMAP* item_x48_bmp = "item_button_x48.tga";

SOUND* select_snd = "select.wav";
var vol_effects = 30;						// misc. sound effect volume

// container variable arrays
var slot_owner[500];									// if > 0, the slot is being used by something
var slot_origin[500];								// original slot number
var item_id[500];										// id number of the slot item; if 0, no item in slot
var bmp_icon_x[500];									// x location of the upper left pixel of the bmap icon
var bmp_icon_y[500];									// y location of the upper left pixel of the bmap icon
var name_index[500];									// name lookup index
var file_index[500];									// mdl file lookup index
var synergy_id[500];									// item has synergy with item number (item_id)
var synergy_usecode[500];							// item synergy use code, looks up the action to be taken


// pointers used for the 6 inventory pack slots
PANEL* pack_slot1;
PANEL* pack_slot2;
PANEL* pack_slot3;
PANEL* pack_slot4;
PANEL* pack_slot5;
PANEL* pack_slot6;


// helps determine the clicked slot number
var panel_slot_start = 0;

var item_hover_time;


// test item data
var ITM_TOME[9] = 				{-99,		-99,		1,		48,	0,		1,		1,		0,		0};
var ITM_MILLBOWL[9] = 			{-99,		-99,		40,	96,	0,		40,	40,	0,		0};


STRING* welcome_str = "Welcome";

TEXT* welcome_txt =	
{
	layer = -10;
	pos_x = 10;
	pos_y = 10;
	string (welcome_str,"this is","a","TEXT");
	flags = CENTER_X | TRANSLUCENT | SHOW;
} 


// looks up and returns the icon of the indicated slot
function lookup_icon(var slot_no)
{
	
	BMAP* icon_bmp;
	STRING* icon_str = "item_icons.tga";
	
	str_cat(icon_str,"#");
	str_cat(icon_str,str_for_num(NULL,bmp_icon_x[slot_no]));
	str_cat(icon_str,"#");
	str_cat(icon_str,str_for_num(NULL,bmp_icon_y[slot_no]));
	str_cat(icon_str,"#48#48");
	
	icon_bmp = bmap_create(icon_str);
	return(icon_bmp);
}


// looks up and returns the name string of the indicated slot
function lookup_name_str(var slot_no)
{
	
	STRING* name_str = "Unknown";
	
	if(name_index[slot_no] == 1){str_cpy(name_str,"Tome");}
	
	if(name_index[slot_no] == 40){str_cpy(name_str,"Milling Bowl");}
	
	return(name_str);
}


// looks up and returns the mdl file string of the indicated slot
function lookup_file_str(var slot_no)
{
	
	STRING* file_str = "Unknown";
	
	if(file_index[slot_no] == 1){str_cpy(file_str,"tome1.mdl");}
	
	if(file_index[slot_no] == 40){str_cpy(file_str,"bowl1.mdl");}
	
	return(file_str);
}


// adds an item to the specified slot
function slot_add_item(var* item_array, var slot_no)
{
	// slot_owner is not modified, it is a property of the slot itself
	slot_origin[slot_no] = slot_no;
	item_id[slot_no] = item_array[2];
	bmp_icon_x[slot_no] = item_array[3];
	bmp_icon_y[slot_no] = item_array[4];
	name_index[slot_no] = item_array[5];
	file_index[slot_no] = item_array[6];
	synergy_id[slot_no] = item_array[7];
	synergy_usecode[slot_no] = item_array[8];
}


// clears the indicated slot
function slot_clear(var slot_no)
{
	
	// slot_owner is not modified, it is a property of the slot itself
	slot_origin[slot_no] = 0;
	item_id[slot_no] = 0;
	bmp_icon_x[slot_no] = 0;
	bmp_icon_y[slot_no] = 0;
	name_index[slot_no] = 0;
	file_index[slot_no] = 0;
	synergy_id[slot_no] = 0;
	synergy_usecode[slot_no] = 0;
}


// copies item data from the source slot to the target slot
function slot_copy(var source_slot, var target_slot)
{
	
	// slot_owner is not modified, it is a property of the slot itself
	slot_origin[target_slot] = slot_origin[source_slot];
	item_id[target_slot] = item_id[source_slot];
	bmp_icon_x[target_slot] = bmp_icon_x[source_slot];
	bmp_icon_y[target_slot] = bmp_icon_y[source_slot];
	name_index[target_slot] = name_index[source_slot];
	file_index[target_slot] = file_index[source_slot];
	synergy_id[target_slot] = synergy_id[source_slot];
	synergy_usecode[target_slot] = synergy_usecode[source_slot];
}


// inventory panel click event
function click_inv_panel(PANEL* inv_panel)
{
	
//	var format;
//	var pixel;
//	
//	// lock and read panel background to determine if it was actually clicked
//	format = bmap_lock(inv_panel.bmap,0);
//	pixel = pixel_for_bmap(inv_panel.bmap,mouse_pos.x - inv_panel.pos_x,mouse_pos.y - inv_panel.pos_y);
//	bmap_unlock(inv_panel.bmap);
//	
//	// if panel was clicked
//	if(pixel != 0)
//	{
		
		
		move_panel(inv_panel);
//	}
}


// inventory panel slot click event
function click_inv_slot(var button_number, PANEL* inv_panel)
{
	
	// determine which slot was clicked
	var slot = panel_slot_start + (button_number - 1);
	
	// cursor icon pointer
	BMAP* mouse_item_bmp;
	
	// end info display loop from the last slot
	item_hover_time = -99;
	
	// if clicked slot has item data
	if(item_id[slot] > 0)
	{
		
		// move item data from the slot to the cursor
		slot_copy(slot,0);
		slot_clear(slot);
		
		// play select sound
		snd_play(select_snd,vol_effects,0);
		
		// while mouse is held
		while(mouse_left == 1)
		{
			
			// draw the icon under the cursor
			mouse_item_bmp = lookup_icon(0);
			draw_quad(mouse_item_bmp,vector(mouse_pos.x - 24,mouse_pos.y - 24,0),NULL,vector(48,48,0),NULL,NULL,100,0);
			
			wait(1);
		}
		
		wait(2);
		
		// if cursor still has data (item released over game view)
		if(item_id[0] > 0)
		{
			
			// move item data from the cursor back to the original slot
			slot_copy(0,slot_origin[0]);
			slot_clear(0);
			
			// play select sound
			snd_play(select_snd,vol_effects,0);
		}
	}
}


// inventory panel slot mouse over event
function touch_inv_slot(var button_number, PANEL* inv_panel)
{
	
	// determine which slot was touched
	var slot = panel_slot_start + (button_number - 1);
	
	// name string
	STRING* name_str = "Unknown";
	
	item_hover_time = 0;
	
	// if the slot has item data
	if(item_id[slot] > 0)
	{
		while(item_hover_time < 5 && item_hover_time != -99)
		{
			if(mouse_moving == 0){item_hover_time = minv(item_hover_time + (1 * time_step),5);}
			wait(1);
		}
		
		if(item_hover_time == 5)
		{
			name_str = lookup_name_str(slot);
			while(item_hover_time != -99)
			{
				display_text(mouse_pos.x,mouse_pos.y - 18,name_str,0.001);
				wait(1);
			}
		}
	}
	
	// if slot is empty
	else
	{
		item_hover_time = -99;
	}
}


// inventory panel slot mouse off event
function release_inv_slot(var button_number, PANEL* inv_panel)
{
	
	// determine over which slot the mouse was released
	var slot = panel_slot_start + (button_number - 1);
	
	// if cursor moved away from the slot
	if(event_type == EVENT_RELEASE)
	{
		item_hover_time = -99;
	}
	
	// if mouse was truely released over a slot
	if(event_type == EVENT_BUTTONUP)
	{
		
		// cursor has item data
		if(item_id[0] > 0)
		{
			
			// if drop slot is empty
			if(item_id[slot] == 0)
			{
				
				// move item data from the cursor to the slot
				slot_copy(0,slot);
				slot_clear(0);
				
				// slot_origin must be updated to new slot location
				slot_origin[slot] = slot;
			}
			
			// if drop slot is not empty
			else
			{
				
				// move item data from the cursor back to the original slot
				slot_copy(0,slot_origin[0]);
				slot_clear(0);
			}
			
			// play select sound
			snd_play(select_snd,vol_effects,0);
			
		}
	}
}


// fills the inv panel with an amount of inventory slots
function create_slots(PANEL* inv_panel, var rows, var cols, var start_x, var start_y, var start_slot)
{
	
	var rows_created = 0;
	var cols_created = 0;

	var x_pos;
	var y_pos;
	var slot_step;

	x_pos = start_x;
	y_pos = start_y;
	slot_step = start_slot;

	while(rows_created < rows)
	{
		
		while(cols_created < cols)
		{
			pan_setwindow(inv_panel,0,x_pos,y_pos,48,48,items_bmp,bmp_icon_x[slot_step],bmp_icon_y[slot_step]);
			pan_setbutton(inv_panel,0,0,x_pos,y_pos,item_x48_bmp,item_x48_bmp,item_x48_bmp,item_x48_bmp,click_inv_slot,release_inv_slot,touch_inv_slot);
			
			x_pos += 48;
			slot_step ++;
			
			cols_created ++;
			
			wait(1);
		}
		
		y_pos += 48;
		x_pos = start_x;
		
		cols_created = 0;
		rows_created ++;
		
		
		wait(1);
	}
}


// creates the pack panel
function create_inv_panel(var start_slot, var x_pos, var y_pos)
{

	PANEL* inv_panel = pan_create("bmap = backpack_bmp; event = click_inv_panel;",NULL);
	
	inv_panel.pos_x = x_pos;
	inv_panel.pos_y = y_pos;
	
	create_slots(inv_panel,4,8,64,168,start_slot);
	
	register_panel(inv_panel);
	
	// bring this panel to front
	layer_sort(inv_panel,total_panels);
	
	return(inv_panel);
}


// starts the inventory system
function inv_startup()
{
	
	slot_add_item(ITM_TOME,16);
	slot_add_item(ITM_MILLBOWL,17);
	pack_slot1 = create_inv_panel(16,32,32);
	pack_slot2 = create_inv_panel(49,160,48);
	pack_slot3 = create_inv_panel(81,288,64);
	pack_slot4 = create_inv_panel(113,416,80);
	pack_slot5 = create_inv_panel(145,544,96);
	pack_slot6 = create_inv_panel(177,672,112);
	
	set(pack_slot1,SHOW);
	set(pack_slot2,SHOW);
	set(pack_slot3,SHOW);
	set(pack_slot4,SHOW);
	set(pack_slot5,SHOW);
	set(pack_slot6,SHOW);
	
	while(1)
	{
		
		if(key_1 == 1)
		{
			snd_play(select_snd,vol_effects,0);
			toggle(pack_slot1,SHOW);
			sort_panels(pack_slot1);
			while(key_1 == 1){wait(1);}
		}
		
		if(key_2 == 1)
		{
			snd_play(select_snd,vol_effects,0);
			toggle(pack_slot2,SHOW);
			sort_panels(pack_slot2);
			while(key_2 == 1){wait(1);}
		}
		
		if(key_3 == 1)
		{
			snd_play(select_snd,vol_effects,0);
			toggle(pack_slot3,SHOW);
			sort_panels(pack_slot3);
			while(key_3 == 1){wait(1);}
		}
		
		if(key_4 == 1)
		{
			snd_play(select_snd,vol_effects,0);
			toggle(pack_slot4,SHOW);
			sort_panels(pack_slot4);
			while(key_4 == 1){wait(1);}
		}
		
		if(key_5 == 1)
		{
			snd_play(select_snd,vol_effects,0);
			toggle(pack_slot5,SHOW);
			sort_panels(pack_slot5);
			while(key_5 == 1){wait(1);}
		}
		
		if(key_6 == 1)
		{
			snd_play(select_snd,vol_effects,0);
			toggle(pack_slot6,SHOW);
			sort_panels(pack_slot6);
			while(key_6 == 1){wait(1);}
		}
		
		// determine starting slot number for inventory mouse functions
		if(mouse_panel == pack_slot1){panel_slot_start = 16;}
		if(mouse_panel == pack_slot2){panel_slot_start = 49;}
		if(mouse_panel == pack_slot3){panel_slot_start = 81;}
		if(mouse_panel == pack_slot4){panel_slot_start = 113;}
		if(mouse_panel == pack_slot5){panel_slot_start = 145;}
		if(mouse_panel == pack_slot6){panel_slot_start = 177;}
		
		wait(1);
	}
}




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Wierd invalid pointer. [Re: draculaFactory] #340573
09/05/10 19:03
09/05/10 19:03
Joined: Mar 2009
Posts: 146
USA
P
paracharlie Offline
Member
paracharlie  Offline
Member
P

Joined: Mar 2009
Posts: 146
USA
Wow, nice inventory you have. I was trying to create my own inventory for my rpg that is as save friendly as possible. I would desperately like to use your inventory system in my rpg if you dont mind, minus the artwork of course?


A8 Commercial
Re: Wierd invalid pointer. [Re: paracharlie] #340582
09/05/10 20:15
09/05/10 20:15
Joined: Feb 2005
Posts: 647
Williamsburg, VA USA
draculaFactory Offline OP
User
draculaFactory  Offline OP
User

Joined: Feb 2005
Posts: 647
Williamsburg, VA USA
Wow didn't think that I could do an array of panel pointers.... That helps a lot, I'll give it a shot.

Paracharlie: You should see the actual inventory grin that was just a bare bones version. Go for it I guess. BTW you might run into some funkiness with it later, the idea was to make an inventory that allowed you to have completely variable inventory panels on screen; for example, opening a chest would create an inventory screen that only displays the slots that the chest was using, thats what the slot_owner variable is for, the slot is not considered to be "free" unless nothing was using it, otherwise a chest might bleed into another set of slots by just checking to see if the inventory slot is simply occupied.

Last edited by draculaFactory; 09/05/10 20:24.

Making dreams come true... And being erroneously accused of software piracy by Conitec in the process.
Re: Wierd invalid pointer. [Re: draculaFactory] #340583
09/05/10 20:34
09/05/10 20:34
Joined: Mar 2009
Posts: 146
USA
P
paracharlie Offline
Member
paracharlie  Offline
Member
P

Joined: Mar 2009
Posts: 146
USA
Drac I would like the whole system if you dont mind sharing with me. I would love to see the whole thing.
I tried making my own, but I just have not been able to make one myself, I always get lost somewhere in the process and end up with a pile of crap, lol.
For that matter, I'd even give you a small donation for your time for a full working system.

Last edited by paracharlie; 09/05/10 20:36.

A8 Commercial
Re: Wierd invalid pointer. [Re: paracharlie] #340602
09/06/10 01:02
09/06/10 01:02
Joined: Feb 2005
Posts: 647
Williamsburg, VA USA
draculaFactory Offline OP
User
draculaFactory  Offline OP
User

Joined: Feb 2005
Posts: 647
Williamsburg, VA USA
Eh the thing is that it's still not finished; so anything that I give you would be a pile of crap because you would have to practically re-write it to fit your system. Typically an inventory system has tie-ins to stat systems and quest systems, etc. I can give it to you in a nut shell:

Use a panel for the inventory screen, use windows on the panel to display a section of an image file (all icons placed on a single "sprite sheet"), place a button over each window on the panel with an invisible image the size of the window object, each button controls a specific slot. When clicking on a button, the data from one section of the array is copied to another, I generally use position 0 on the array to indicate the cursor.

I've done lots of inventory systems in the past, I have just never shared them with anyone because I noticed that mine were totally different from the way others were doing it. This one just uses some of the cool new lite-c functions that make stuff neater. Like I used to use a different panel that follows the mouse to display an item "in" the cursor; now I use the bitmap cut out thingie, which just draws an icon under the cursor.

The only way that this inventory system differs is that the panels, buttons, and windows are all created during gameplay, and not pre-defined.

Last edited by draculaFactory; 09/06/10 01:05.

Making dreams come true... And being erroneously accused of software piracy by Conitec in the process.
Re: Wierd invalid pointer. [Re: draculaFactory] #340603
09/06/10 02:09
09/06/10 02:09
Joined: Mar 2009
Posts: 146
USA
P
paracharlie Offline
Member
paracharlie  Offline
Member
P

Joined: Mar 2009
Posts: 146
USA
Well I've screwed it up enough times to actually understand what your saying. What throws confuses me is copying data from one array to another. Is that where having an item_id would be used? See I still have alot of confusion and inventory's are definately not easy but I'm learning.
No problem though Drac. I'll figure it out eventually, I still have so much other things to do.

Last edited by paracharlie; 09/06/10 02:36.

A8 Commercial
Re: Wierd invalid pointer. [Re: paracharlie] #340608
09/06/10 03:23
09/06/10 03:23
Joined: Feb 2005
Posts: 647
Williamsburg, VA USA
draculaFactory Offline OP
User
draculaFactory  Offline OP
User

Joined: Feb 2005
Posts: 647
Williamsburg, VA USA
No see like this, just take a look at my script where it uses arrays. The actual item data could look something like this...
Code:
var item_spoon[3] = {1, 48, 96};



Each item, in this example, has 3 properties. The spoon's properties are: item_id (which is 1), bmp_x (which is pixel x location 48 on the icon sprite sheet), and bmp_y (which is pixel y location 96 on the icon sprite sheet).

The arrays that are the inventory slots would look like this:
Code:
var item_id[500];
var bmp_x[500];
var bmp_y[500];



The [500] after each array means that there are 500 inventory slots, you could increase it to 1000, or like 278394 if you wanted to...

The items are moved around by simply altering the [number] of the property arrays, not the item data arrays. This means that if the spoon item was contained in slot 54, then it would look like this in code:
Code:
...
item_id[54] = 1;
bmp_x[54] = 48;
bmp_y[54] = 96;
...


The above is the state of the three defined properties of inventory slot number 54. To delete the item from the slot, just set them all to zero grin

If you want more properties for your items you have to define more arrays:
Code:
var item_id[500];
var bmp_x[500];
var bmp_y[500];
var gold_value[500];
var sound_effect_number[500];
var weight[500];



And since we've added more properties, you must alter the item data array to allow for more properties:
Code:
var item_spoon[3] = {1, 48, 96, 100, 22, 1};



100 being the gold value of the spoon, 22 is the number of the sound effect that it makes, and 1 is the spoon's weight.

Take a look at the function in the script that adds an item, it simply uses a variable pointer to fill the correct array (inventory slot) with the correct numbers grin

So a function that adds your spoon would look like this:
Code:
function add_item(var* item_array, var slot)
{
	item_id[slot] = item_array[0];
	bmp_x[slot] = item_array[1];
	bmp_y[slot] = item_array[2];
	gold_value[slot] = item_array[3];
	sound_effect_number[slot] = item_array[4];
	weight[slot] = item_array[5];
}


You call the function like this: add_item(item_spoon,54);


Making dreams come true... And being erroneously accused of software piracy by Conitec in the process.
Page 2 of 3 1 2 3

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