game maker studio transferring multiple variables to a script

136 views Asked by At
var am = random_range(2,9)
Blood(dir,am);

for (i = 0; i < am; i ++)
{
    bl = instance_create(x,y,Obj_Blood);
    bl.dir = dir
}

When the script is run, I want to transfer multiple variables across from the object to the script. It works if I use Blood(dir); but not if I add am. How can I use both variables in the script?

1

There are 1 answers

0
Maxim Nuriev On BEST ANSWER
  1. Use argument0, argument1, ... inside the script

    var dir = argument0 var am = argument1

  2. You can also use outer variables inside the script (I suppose it's almost your case) but it's more complicated. It's like a method of class that uses private variables inside the object, so better be sure that script is using object variables and not using some not declared (and it's a pitfall because GML easy creates variables).