F
fxokz
Guest
I'm trying to assign a random first and last name variable to a newly created object but I cant seem to get it to work. the variables just stay at -4. When I try putting the switch statement in the step event it works fine (but changes values every step...) not sure how to handle this.
the code below generates an object and sets a type var via controller object.
the code below generates an object and sets a type var via controller object.
Code:
var inst = instance_create(1, 1, obj_customer);
inst.type = argument0;
the code below is the create event of the customer object.. the switch statement doesn't go through.
Code:
type = noone;
firstName = noone;
lastName = noone;
switch(type)
{
case reg:
firstName = global.firstNames[reg, irandom_range(0, array_length_2d(global.firstNames, reg) - 1)];
lastName = global.lastNames[reg, irandom_range(0, array_length_2d(global.lastNames, reg) - 1)];
break;
case sus:
firstName = global.firstNames[sus, irandom_range(0, array_length_2d(global.firstNames, sus) - 1)];
lastName = global.lastNames[sus, irandom_range(0, array_length_2d(global.lastNames, sus) - 1)];
break;
case cop:
firstName = global.firstNames[cop, irandom_range(0, array_length_2d(global.firstNames, cop) - 1)];
lastName = global.lastNames[cop, irandom_range(0, array_length_2d(global.lastNames, cop) - 1)];
break;
}