Jump to content

Simple mod breaks the GUI


pyrothagorus
 Share

Recommended Posts

I've been enjoying playing 0AD recently, so I thought I'd try my hand at modding. I thought I'd start simple, and because I always find that I've not built enough houses, I thought I'd tweak the population bonus of the civic centre template. I've created a mod with the required mod.json and ./simulation/templates/template_structure_civic_civil_centre.xml. It works, in the sense that the population bonus is higher when I run the game with the mod. But it seems to break all the unit/structure right click info windows. Loads of error messages pop up in the game console when I right click on a unit icon in a build menu. I've seen some mention in the modding guide of having to save/reload, but that wasn't 100% clear. In any case I've opened/closed 0AD several times.

Game version is 0.27.1, running on Linux Mint.

How do I get the error messages outside of 0AD? I hoped there'd be some logs in ./local/share/0ad, but can't see anything in there.

Grateful for any help.

Also, on newbies starting modding, the user experience / guidance could probably do with some tweaking. My route into modding was to use the in-game mod.io downloader. I then tested the mod to see if it was working in the game. Then went into ./local/share/0ad/mods to edit it. I extracted the zip file and started playing around. No effect. I figured the game engine reads from the zip rather than folders by default, so I deleted the zip. And then the mod doesn't do anything any more. I finally realised that extracting the zip downloaded via mod.io doesn't generate the right folder structure. I think the below line from the tutorial is trying to get at this point, but it's not the clearest, particularly given the common definition of zip bomb: https://en.wikipedia.org/wiki/Zip_bomb.

If you extract the mod so you can further work on it beware a properly packaged mod is a zip-bomb. 

Link to comment
Share on other sites

10 minutes ago, pyrothagorus said:

How do I get the error messages outside of 0AD? I hoped there'd be some logs in ./local/share/0ad, but can't see anything in there.

./config/0ad/logs

Or gather the errors from terminal if you open 0ad from there.

I don't see any reasons why editing the population bonus of structures in template would break anything so probably you are right to try to look into how you packaged your mod. A random guess would be that you extracted the mod you're playing with creating a extra folder like 0ad/mods/yourmod/yourmod/simulation/templates/..., and should be 0ad/mods/yourmod/simulation/templates/.... Besides this, mods downloaded from the downloader should create the correct folder structure.

Link to comment
Share on other sites

Thanks for your help. I've included the error message I was getting below for completeness, but I realise what I had done wrong. The template I used as the base was from the current live repo, which has edits that aren't in version 0.27.1 ("health_females_01" being renamed to "health_civilians_01").

<!DOCTYPE html>
<meta charset="utf-8">
<title>Pyrogenesis Log</title>
<style>body { background: #eee; color: black; font-family: sans-serif; } p { background: white; margin: 3px 0 3px 0; } .error { color: red; } .warning { color: blue; }</style>
<h2>0 A.D. (0.27.1) Main log (warnings and errors only)</h2>
<p class="error">ERROR: File 'simulation/data/technologies/health_civilians_01.json' does not exist</p>
<p class="error">ERROR: JavaScript error: gui/reference/common/TemplateLoader.js line 114
data is undefined
  loadTechnologyTemplate@gui/reference/common/TemplateLoader.js:114:8
  isPairTech@gui/reference/common/TemplateLoader.js:310:17
  deriveProduction@gui/reference/common/TemplateLoader.js:173:14
  deriveTemplateListsFromTemplate@gui/reference/common/TemplateLister.js:126:45
  compileTemplateLists@gui/reference/common/TemplateLister.js:40:21
  setActiveCiv@gui/reference/common/ReferencePage.js:26:51
  selectTemplate@gui/reference/viewer/ViewerPage.js:38:9
  init@gui/reference/viewer/viewer.js:18:9
  showTemplateDetails@gui/session/selection_panels.js:1272:15
  showTemplateFunc@gui/session/selection_panels.js:194:53</p>
<p class="error">ERROR: GUI page 'page_viewer.xml': Failed to call init() function</p>

 

Regarding the zip file, you're correct that the zip extract created an additional folder layer. But my point its that's the way most zip applications work, so the user workflow fails by default. As the mod.io zip files contain an mod.json plus a zip file, and then the zip file contains the same mod.json, I just think it's a bit confusing for someone first dipping their toes into modding.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...