F
FunkyB
Guest
Hello, I am a beginner with GM. I just started an RPG (just like FF1 but with a twist). I can now say that without for loops, I would have died long ago from exhaustion.
I have been getting by with establishing global arrays and using for loops. However, I have found that it can get very messy (nomenclature issues). I wonder if I should be using a data structure instead. FYI: I have no experience using data structures, but I will learn if that is the way to go.
For example:
obj_buy_spell
Step Event
//When in the magic shop, and the player clicks on a spell on the shelf to buy, this obj is created.
//This is an obj that the player drags over a character, and left clicks to teach it to him/her.
/*
global.char[ 0, 0 ] = "fighter";
global.char[ 1, 0 ] = "blackmage";
global.char[ 2, 0 ] = "whitemage";
*/
var inst = collision_point( mouse_x, mouse_y, obj_char_parent, false, false );
if( inst != noone ) && ( mouse_check_button_pressed( mb_left ) )
{
//First, find out who you clicked on
for( var i = 0; i < global.party_count; i += 1 )
{
if( inst.name == global.char[ i, 0 ] ) //Ex: obj_fighter.name = "fighter" and global.char[ 0, 0 ] = "fighter"
{
var target = i; //target now equals the char you clicked on
}
}
}
There is a lot more code that follows, but basically I check if the target has or hasn't learned the spell. If he/she has, the spell is learned.
I end up checking arrays against arrays and it gets pretty wild. Am I on the right track? Or should I be taking another approach.
Thank you for reading, and let me know if I left anything unclear.
I have been getting by with establishing global arrays and using for loops. However, I have found that it can get very messy (nomenclature issues). I wonder if I should be using a data structure instead. FYI: I have no experience using data structures, but I will learn if that is the way to go.
For example:
obj_buy_spell
Step Event
//When in the magic shop, and the player clicks on a spell on the shelf to buy, this obj is created.
//This is an obj that the player drags over a character, and left clicks to teach it to him/her.
/*
global.char[ 0, 0 ] = "fighter";
global.char[ 1, 0 ] = "blackmage";
global.char[ 2, 0 ] = "whitemage";
*/
var inst = collision_point( mouse_x, mouse_y, obj_char_parent, false, false );
if( inst != noone ) && ( mouse_check_button_pressed( mb_left ) )
{
//First, find out who you clicked on
for( var i = 0; i < global.party_count; i += 1 )
{
if( inst.name == global.char[ i, 0 ] ) //Ex: obj_fighter.name = "fighter" and global.char[ 0, 0 ] = "fighter"
{
var target = i; //target now equals the char you clicked on
}
}
}
There is a lot more code that follows, but basically I check if the target has or hasn't learned the spell. If he/she has, the spell is learned.
I end up checking arrays against arrays and it gets pretty wild. Am I on the right track? Or should I be taking another approach.
Thank you for reading, and let me know if I left anything unclear.