• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[LUA] Writing to wrong fields

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,337
Hi,

In the LUA object generation script, it is possible to write to non-existent field in an object, if it is a name for an actual field in at least one object.

e.g. Rain of Fire has a field for the number of waves--most spells do not have this field, but any spell object can attempt to write to this field anyway.

I made such a mistake when writing to the Berserk field for attack speed modification, but via a Lightning Shield spell object.

After doing so, I get this error message whenever I delete more than 3 of any custom object.

1iztbn.png


Now when I fixed my incorrect field writing and moved to a brand new map, I was able to delete any number of custom objects without the editor crashing.

So what values did I write to that made the editor crash whenever deleting custom objects?

And is there anyway to reverse this or do I need to copy and paste all my code to a new map?
 
Lua writes directly to the w3a (and other object files), so it is indeed possible to write a field that doesn't exist for the object. However, this can easily conflict with the object editor. I'm guessing that the object editor isn't detecting that extra field, so when the object is deleted, that data is just left floating around and causes some strange parsing error. I don't know why it would be after 3 objects though.

How would you fix it? It is a little unclear. I would attempt to overwrite the object using Lua, by overwriting the problematic ability with a fresh one (and deleting the old code). Hopefully it was written well enough to accommodate such an error. If not, you can try using a hex editor to delete the field and make the necessary changes, but it requires some knowledge of the object format, and it is a little tedious.

IMO, the best option is to switch to a new map, if it is feasible. Otherwise, check your jassnewgenpack/backups folder to see if there is an old backup that was made before you added that ability.

Ultimately, while Lua was written quite well and improved over the years, there may still be slight issues such as that. The editor might check for such errors, but the object merger won't, so it still requires one to be careful. ;P
 
Status
Not open for further replies.
Top