set_menu_item and debug
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
set_menu_item and debug
Hi,
I created a modification that allows the player to heal or harm any unit on the map with a right-click menu.
The idea is to show these menu items only when the player has typed in :debug
How do I make it appear only after the user switches to :debug?
I tried surrounding the event code with #ifdef DEBUG_MODE but that didn't work.
Also, when the user uses the regular debug commands, like Kill Unit (Debug!), it flashes something on the screen like "player has used a debug command on their turn".
How do I make my mod do the same thing? (have it fire the same event I'm expecting)
This is the code for the mod. It's very short
https://github.com/virtualghetto/Debug_ ... /_main.cfg
Final question, Is it allowed for me to upload this to the addons.wesnoth.org server?
I created a modification that allows the player to heal or harm any unit on the map with a right-click menu.
The idea is to show these menu items only when the player has typed in :debug
How do I make it appear only after the user switches to :debug?
I tried surrounding the event code with #ifdef DEBUG_MODE but that didn't work.
Also, when the user uses the regular debug commands, like Kill Unit (Debug!), it flashes something on the screen like "player has used a debug command on their turn".
How do I make my mod do the same thing? (have it fire the same event I'm expecting)
This is the code for the mod. It's very short
https://github.com/virtualghetto/Debug_ ... /_main.cfg
Final question, Is it allowed for me to upload this to the addons.wesnoth.org server?
Re: set_menu_item and debug
Check if viewtopic.php?t=44432 is suitable for your use case.
It is not against addon server rules, especially because you say it needs debug which allows all that anyways. I have my own debug addon, which I do not upload since I do not require debug mode there.
Specify whether this needs to work in SP or MP.
It is not against addon server rules, especially because you say it needs debug which allows all that anyways. I have my own debug addon, which I do not upload since I do not require debug mode there.
Specify whether this needs to work in SP or MP.
Re: set_menu_item and debug
Thank you. I got the first part done with this little snippet
I still couldn't figure out the second part, the one that says that a debug command has been used on the players turn so it will appear in the replay. Is there a standard event name that I can fire? or is it more complicated than that?
Edit:
It appears I need to get to the cpp function called debug_cmd_notification, but how?
Code: Select all
[lua]
code = << return wesnoth.game_config.debug >>
[/lua]
Edit:
It appears I need to get to the cpp function called debug_cmd_notification, but how?
- Mathemagician
- Posts: 39
- Joined: March 24th, 2008, 10:42 pm
- Location: Right behind you
Re: set_menu_item and debug
A simpler solution might be to use
[print]
. Though getting the fonts and duration to match up might be finicky.Formerly NeoPhile
Re: set_menu_item and debug
Thanks I didn't know about the [print] command. I looked back at Gui Debug Tools and saw that [print] was used over there as well. Thank you for drawing my attention to it.Mathemagician wrote: ↑December 27th, 2019, 9:08 pm A simpler solution might be to use[print]
. Though getting the fonts and duration to match up might be finicky.
On the other hand debug_notification has some perks, not only is the position of the text different (announce in display.cpp), it interrupts the replay and asks if you'd like to save. And that is the feature that I was hoping for, but this is turning out to be more complicated for a simple basic little mod, so I'm dropping the idea and implemented a basic print tag and no current_player.
Re: set_menu_item and debug
I am quite sure there is no way to fake debug notices.
- Celtic_Minstrel
- Developer
- Posts: 2207
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: set_menu_item and debug
In order to mimic the built-in debug command notifications, you'd need to define a custom synced command (which is possible with the
wesnoth.custom_synced_commands
table if I recall correctly), but you'd also need to be able to define the custom command as a debug command (which isn't currently possible). So your present solution is almost certainly the best that can be managed at this time.