Topic: Newbie struggling with message box syntax
SandJ![]() Topic Opener |
Posted at:
2025-08-14, 20:45 UTC+2.0
I am trying to get the hang of scripting and want to use one of my favourite debugging techniques: a pop-up box at start and end of each function so I can trace what is happening. But I can't work out how to use send_to_inbox or message_box or campaign_message_box. I either get an error about trying to index a string or index a number null values or an outright crash saying "FATAL ERROR: Received signal 11 (Segmentation fault)" I have tried using:
and various forms of:
and also wl.game.Player.message_box() and player:message_box() without success. Q1. Is there a better way to trace program execution than pop-ups for the start and end of programs and functions? Q2. Can someone point me at an example of working code for inclusion in an init.lua that provides that sort of functionality? Yes, I have tried looking at the wiki and at existing scripts, but cannot work out what I am getting wrong, despite spending about four hours on just this one thing.
Edited:
2025-08-14, 20:49 UTC+2.0
![]() ![]() |
SandJ![]() Topic Opener |
Posted at:
2025-08-14, 22:14 UTC+2.0
gives me "attempt to index a nil value (global 'game')"
gives me "attempt to index a nil value (global 'game')"
crashes with "FATAL ERROR: Received signal 11 (Segmentation fault)"
crashes with "FATAL ERROR: Received signal 11 (Segmentation fault)"
crashes with "FATAL ERROR: Received signal 11 (Segmentation fault)"
gives me "attempt to index a number value (local 'player'"
gives me "attempt to index a string value (local 'message')" and so on.
Edited:
2025-08-14, 22:14 UTC+2.0
![]() ![]() |
SandJ![]() Topic Opener |
Posted at:
2025-08-14, 23:30 UTC+2.0
I have tried:
from the Scenario Tutorial, but that causes a "FATAL ERROR: Received signal 11 (Segmentation fault)" crash. ![]() ![]() |
Nordfriese![]() |
Posted at:
Yesterday 10:43 UTC+2.0
Some pointers to the documentation
Importantly, are you running this in a game, in the editor, or in the main menu? As an interactive player or as a spectator? Several of these functions are intended for interactive players in-game only.
This seems to be a bug in
This should be fixed in the function to use ![]() ![]() |
kaputtnik![]() |
Posted at:
Yesterday 10:50 UTC+2.0
Working with lua can be hard … If this is just for you you can leave out the localization function ( Personally i use just This works for me:
Shows immediately a messagebox. With Easier might be to to use show_messagebox():
If you are struggling further you need to provide the full command chain, e.g. with all includes and commands before the failing command. ![]() ![]() |
SandJ![]() Topic Opener |
Posted at:
Yesterday 21:38 UTC+2.0
Thank you both, very much. After a few more hours fiddling and following your advice, I've come to the conclusion Lua scripting is not for me. My past knowledge of COBOL, Pascal, BASIC, C, Python and smatterings of other languages is not helping me here. I think I am making assumptions that do not apply. I am finding the inconsistencies of when to finish a line with a comma or not, of code that works in one pre-existing init.lua not working in another and similar oddness very puzzling. Google searches for answers take me to people giving inconsistent answers. "Working with lua can be hard …". I concur. I think I ought to do a clean re-install and try again. Since I am not getting the results you and I expect - even from your examples - there must be something else mucking stuff up that I do not have the experience to look for. I would usually struggle on, but I'm doing this for fun, and fun it ain't. Anyway, thank you both. Sometimes, knowing when to give up is important too.
Edited:
Yesterday 21:39 UTC+2.0
![]() ![]() |