Difference between revisions of "DebuggingCampaigns"

From The Battle for Wesnoth Wiki
m
(Things to check when your scenario doesn't load)
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
"Debugging" means to fix by removing errors. Here are some ideas to help you when you are building a campaign and need to fix it.
+
"Debugging" means to fix by removing errors. Here are some ideas to help you when you are building a campaign (or other add-on) and need to fix it.
  
 +
== Instructions also useful for users reporting bugs ==
 +
 +
=== Fully clearing a corrupted cache ===
 +
 +
Sometimes the cache can get corrupted, in Wesnoth 1.14 this seems to be the cause of `Undefined macro in #ifver/#ifnver first argument: 'WESNOTH_VERSION'` errors. In this case, please purge the cache with the button in Preferences, General, Cache (at the bottom of the General tab), labelled Purge.
 +
 +
== Tips ==
 +
 +
Use F5 in main game menu to reload WML code and invalidate cache. By this way you save time on rebooting game each time you change map or WML code.
 +
 +
Always backup your work. Use a DVCS (for example Git), so that you can revert any added or deleted code, and to check the differences between versions. Even without a DVCS, you can comment out part of the WML code by prefixing it with "#", and later uncomment it again.
  
 
== Things to check when your scenario doesn't load ==
 
== Things to check when your scenario doesn't load ==
Line 8: Line 19:
 
*Is the ".cfg" extension appended to the script filename?  
 
*Is the ".cfg" extension appended to the script filename?  
  
*Is the script in the right location (usually campaigns/YOUR_MODULE/scenarios)  
+
*Is the script in the right location (usually ~add-ons/YOUR_ADDON/scenarios)  
  
*Is it really a scenario load problem? Maybe the main.cfg file isn't being loaded correctly.  
+
*Is it really a scenario load problem? Maybe the _main.cfg file isn't being loaded correctly.  
  
*Are all the linking tags spelled correctly? ("first_scenario=???", "next_scenario=???", "id=???")  
+
*Are all the linking tags spelled correctly? (<b>first_scenario=???</b>, <b>next_scenario=???</b>, <b>id=???</b>)  
  
*If you're using the template, did you remember to change the script in the utils directory to load your module? Otherwise you might get a recursion error that may prevent your scenarios from loading (remember, scenarios are loaded last)
+
*If you're using the template, did you remember to change all include and file paths to match your setup?
  
*Is a downloaded module breaking your version of the game?  
+
*Is another downloaded add-on breaking your version of the game or conflicting with your content?  
  
 
*Do you have read permissions on your scripts?
 
*Do you have read permissions on your scripts?
  
 +
== Other tips ==
  
 +
A recommended approach by zookeeper is to remove half your code, and try to load your add-on. If the error is gone, you know it's in the half you removed. Take whichever half has the error, and keep removing half of what remains until you isolate the error.
  
 
== See Also: ==
 
== See Also: ==
  
 
*[[BuildingCampaigns]]
 
*[[BuildingCampaigns]]
*[[BuildingCampaignsDirectoryStructure]]
+
*[[AddonStructure]]
  
 
[[Category:Create]]
 
[[Category:Create]]

Latest revision as of 03:30, 23 March 2023

"Debugging" means to fix by removing errors. Here are some ideas to help you when you are building a campaign (or other add-on) and need to fix it.

Instructions also useful for users reporting bugs

Fully clearing a corrupted cache

Sometimes the cache can get corrupted, in Wesnoth 1.14 this seems to be the cause of `Undefined macro in #ifver/#ifnver first argument: 'WESNOTH_VERSION'` errors. In this case, please purge the cache with the button in Preferences, General, Cache (at the bottom of the General tab), labelled Purge.

Tips

Use F5 in main game menu to reload WML code and invalidate cache. By this way you save time on rebooting game each time you change map or WML code.

Always backup your work. Use a DVCS (for example Git), so that you can revert any added or deleted code, and to check the differences between versions. Even without a DVCS, you can comment out part of the WML code by prefixing it with "#", and later uncomment it again.

Things to check when your scenario doesn't load

  • Do the id tags match exactly? Does the id in the caller script have the same case (lowercase/uppercase) as the scenario's id?
  • Is the ".cfg" extension appended to the script filename?
  • Is the script in the right location (usually ~add-ons/YOUR_ADDON/scenarios)
  • Is it really a scenario load problem? Maybe the _main.cfg file isn't being loaded correctly.
  • Are all the linking tags spelled correctly? (first_scenario=???, next_scenario=???, id=???)
  • If you're using the template, did you remember to change all include and file paths to match your setup?
  • Is another downloaded add-on breaking your version of the game or conflicting with your content?
  • Do you have read permissions on your scripts?

Other tips

A recommended approach by zookeeper is to remove half your code, and try to load your add-on. If the error is gone, you know it's in the half you removed. Take whichever half has the error, and keep removing half of what remains until you isolate the error.

See Also:

This page was last edited on 23 March 2023, at 03:30.