Lua mod help

duckstab

Child of Noble Family
Joined
May 5, 2008
Messages
1,477
Location
New York, NY
I'm trying to create a Lua mod to set the name of a unit to a unique value when it's built / added to the map. My mod appears to be loading, or at least, I see no obvious errors in Modding.log. But I see no evidence that my code is actually being run.

I'd appreciate any advice on where to go from here. Is there a way I can see more debug logs? Or is what I'm doing just fundamentally not doable? Thanks.
 

Attachments

  • Name All The Things.zip
    1.2 KB · Views: 19
The problem is here
Code:
    <ImportFiles id="JcsNattImport">
      <File>UnitNameManager.lua</File>
    </ImportFiles>
You are importing the file into the game's VFS but that does not accomplish anything because there is no base game lua file with the same filename. So the game ends up not using your code for anything.

You would need to create a new User Interface context and load your file into the game as the "context's" lua script. Or else you would need to add your code onto a copy of the game's UnitPanel.lua file (for example) and then import that altered version of UnitPanel.lua

And the place to look for lua issues is lua.log
Modding.log will only tell you that the Action in the modinfo file was implemented but not whether or not the file itself was ever used for anything or had an error within the code.
 
Thanks, LeeS, I'll try one of those approaches.

Does everything written with Lua's print() function end up in lua.log, or do you have to do something special to get debug output directed there?
 
yes. essentially the lua.log is everything that gets posted to the main tab of the firetuner. but if you don't have firetuner enabled you don't get anything in firetuner. looking at the lua.log file can be done after exiting the game, tho, so it is also convenient as a reference when seeking to trace down an error and rework one's code.
 
Top Bottom