S
Sam Brixey
Guest
I am using a script to add a slow effect and am trying to add an argument for the duration. So in the script i have as the first line "///scr_status_slow(dur)"
and in the script;
var duration = argument[0]
spd = 0.5
if (alarm[10] <= 0) {
alarm[10] = duration
}
if (alarm[10] <= 2) {
status = scr_status_normal
}
Then in my slow object for the collision event with a lifeform I have the following;
other.status = scr_status_slow(40)
For some reason however when I run my game and hit a lifeform with this the lifeform tries to run a script for its status which is entirely unrelated and the game crashes as it tried to use variables that havn't been set in the lifeform as it shouldn't be running that script. The only reason I can see that it would run that script is it is the first script in my resource tree but why is it calling this script and not setting scr_status_slow as the status script? (Have tested this by moving a different script to the top of the list of scripts and it also runs this script as the objects status).
Note that there is no problem at all if I just have the script with no arguments and instead set the duration in the collision event and then set the status to scr_status_slow. for example;
other.status = scr_status_slow
other.alarm[10] = 40
and in the script;
var duration = argument[0]
spd = 0.5
if (alarm[10] <= 0) {
alarm[10] = duration
}
if (alarm[10] <= 2) {
status = scr_status_normal
}
Then in my slow object for the collision event with a lifeform I have the following;
other.status = scr_status_slow(40)
For some reason however when I run my game and hit a lifeform with this the lifeform tries to run a script for its status which is entirely unrelated and the game crashes as it tried to use variables that havn't been set in the lifeform as it shouldn't be running that script. The only reason I can see that it would run that script is it is the first script in my resource tree but why is it calling this script and not setting scr_status_slow as the status script? (Have tested this by moving a different script to the top of the list of scripts and it also runs this script as the objects status).
Note that there is no problem at all if I just have the script with no arguments and instead set the duration in the collision event and then set the status to scr_status_slow. for example;
other.status = scr_status_slow
other.alarm[10] = 40