I
itameio
Guest
i'm trying to shorten functions in GML by including them in scripts and then calling that script instead of the function itself, example :
script "d" {
instance_deactivate_object(argument0)
}
this is called in an object like{ d(self) } for example, to make it deactivate itself.
but when I tried writing a script called "limit" which goes like this :
script "limit" {
if argument0>argument1{argument0=argument1}
}
to use it to limit variables and constants such as speed for example { limit(speed,20) }, it doesn't work.
after testing the code in different ways I realized the only part that does not work is argument0=argument1 which if changed to speed=argument1 works fine. so my impression was that arguments are read-only, but the help documents doesn't say anything like that, so if they are not read-only then am I doing something wrong?
script "d" {
instance_deactivate_object(argument0)
}
this is called in an object like{ d(self) } for example, to make it deactivate itself.
but when I tried writing a script called "limit" which goes like this :
script "limit" {
if argument0>argument1{argument0=argument1}
}
to use it to limit variables and constants such as speed for example { limit(speed,20) }, it doesn't work.
after testing the code in different ways I realized the only part that does not work is argument0=argument1 which if changed to speed=argument1 works fine. so my impression was that arguments are read-only, but the help documents doesn't say anything like that, so if they are not read-only then am I doing something wrong?
Last edited by a moderator: