No, GMS does not have references or a syntax for it. Most time I see someone asking about it, I immediately think that some kind of data structure would be a more natural way to go about it in most cases. Having said that, if you are determined to do this anyway and you're dealing with instance or global variables or structs, you have the option of using the instance, global, and struct get/set functions using a string as the variable name and by passing different strings you can get or set a different global or instance variable. Additionally, arrays are passed by reference, and using the @ accessor modifies the referenced array for the given position rather than using copy-on-write.Well the question is simple, but i couldnt find an exact answer with research.
I want a functionality like this:
number=5;
reference_number=number;
reference_number=10;
Output:
number=10
Is it possible to do it in GML with a syntax like macro, var or something?
global.player_character_health_points = 5;
#macro PLAYER_HP global.player_character_health_points
PLAYER_HP = 10;
show_debug_message(global.player_character_health_points); // 10
function d_road_construct(args_d_v_dr_s_w_r){
var day_wait=args_d_v_dr_s_w_r[0];
var vill_gone=args_d_v_dr_s_w_r[1];
var day_reducement=args_d_v_dr_s_w_r[2];
var stone_requirement=args_d_v_dr_s_w_r[3];
var wood_requirement=args_d_v_dr_s_w_r[4];
var rank=args_d_v_dr_s_w_r[5];
var district_manage=noone;
with(oGUI)
{
district_manage=selected_district;
}
var complete=false;
var under_work=false;
with(district_manage)
{
complete=buttons[rank][4]; //this is how i would like to handle particular array member but cant refer
under_work=buttons[rank][5];//this is how i would like to handle particular array member but cant refer
}
with(oPopulation)
{
if(idle_pop>=vill_gone) && (stone >= stone_requirement) &&
(wood>=wood_requirement) &&(!district_manage.buttons[rank][BUTTON.COMPLETE]) &&(!district_manage.buttons[rank][BUTTON.UNDER_WORK])
{ with(oGUI)
{ can_execute=true;
}
district_manage.buttons[rank][BUTTON.UNDER_WORK]=true; // under work
order_number++;
idle_pop-=vill_gone;
stone-=stone_requirement;
wood-=wood_requirement;
order[order_number][VARIABLES.DAY]=day_wait;
order[order_number][VARIABLES.POP]=vill_gone;
args=[district_manage,day_reducement,rank];
var sc=d_road_completed;
order[order_number][VARIABLES.TRIGGER]=[sc,args];
order[order_number][VARIABLES.E_SIZE] = 0;
}
else
{
with(oGUI)
{ can_execute=false;
}
}
}
}