W
Wardog
Guest
Morning All,
I'm currently attempting to use creation code to run a script that will assign a randomized variable to instances of a specific object, based on weather.
Now, it appears to mostly work as intended, except it is assigning the same value to the target variable to all instances of that object, instead of randomizing the variable between each instance.
obj_node_small Creation Code: (This is attached to each instance of the object in the room).
instance_node_spawning(room);
Script (instance_node_spawning):
Now, I could just run the script in the creation code of the object itself, and get the desired result, but it will ultimately be so large and expansive, that it made more sense to run it as a script. Any thoughts on how to resolve this? Thanks in advance.
I'm currently attempting to use creation code to run a script that will assign a randomized variable to instances of a specific object, based on weather.
Now, it appears to mostly work as intended, except it is assigning the same value to the target variable to all instances of that object, instead of randomizing the variable between each instance.
obj_node_small Creation Code: (This is attached to each instance of the object in the room).
instance_node_spawning(room);
Script (instance_node_spawning):
Code:
if(instance_exists(obj_node_small)){
repeat(instance_number(obj_node_small)){
if(argument[0] == room 1){
if(obj_weather.current_weather = 1){ // Rain
if(random(1) < 0.75){ var nodeassign = 0; } // Foliage 1
else { nodeassign = 1; } // Foliage 2
}
}
var inst = obj_node_small;
with(inst){ nodetype = nodeassign }; // Assign the Nodetype to Each Instance
}
}