Bramsko
Bramsko

Reputation: 15

GameMaker Studio 2; Weapon System. Error: DoConv :1: illegal undefined/null use; how to fix it?

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

Answers (1)

YellowAfterlife
YellowAfterlife

Reputation: 3202

This error may mean a few things:

  • You did not wrap the contents of the script in 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)
  • You called your script without an argument (ChangeWeapon() vs ChangeWeapon(arg)).
  • You called your script with an argument, but argument's value is undefined.

Based on the error message, I would assume this to be the first of three.

Upvotes: 2

Related Questions