Reputation: 15
Im trying to implement a weapon switching system in GameMaker Studio 2 and I'm following a tutorial to do so since I'm not too experienced with GML. When I'm trying to run this script I'm getting the following error, and I can't find a way to get it to work.
############################################################################################ ERROR in action number 1 of Create Event for object :
DoConv :1: illegal undefined/null use at gml_GlobalScript_ChangeWeapon (line 2) - var wp_map = weapons[weapon]; ############################################################################################ gml_GlobalScript_ChangeWeapon (line 2)
And the script is:
weapon = argument0;
var wp_map = weapons[weapon];
sprite = wp_map[? "sprite"];
recoil = wp_map[? "recoil"];
recoil_push = wp_map[? "recoil_push"];
damage = wp_map[? "damage"];
projectile = wp_map[? "projectile"];
startup = wp_map[? "startup"];
bulletspeed = wp_map[? "bulletspeed"];
length = wp_map[? "length"];
cooldown = wp_map[? "cooldown"];
automatic = wp_map[? "automatic"];
Upvotes: 0
Views: 309
Reputation: 3202
This error may mean a few things:
function <name>() { ... }
(as per the message that you get when you create new scripts in 2.3), causing your code to be executed on game start (and, surely enough, without arguments)ChangeWeapon()
vs ChangeWeapon(arg)
).undefined
.Based on the error message, I would assume this to be the first of three.
Upvotes: 2