Topic: Newbie struggling with message box syntax

SandJ
Avatar
Topic Opener
Joined: 2015-05-08, 22:46 UTC+2.0
Posts: 29
OS: Linux
Ranking
Pry about Widelands
Location: UK
Posted at: Yesterday 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:

include "scripting/ui.lua"
include "scripting/messages.lua"

and various forms of:

send_to_inbox(plr, _("xyz"), _("ABC"), {popup=false}),
message_box(_("xyz"), _("ABC")),
campaign_message_box(_("xyz"), _("ABC")),
campaign_message_box({title = "xyz",
    body = p(_("ABC")),    and    body = "ABC",
    position = "top"}
 ),

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: Yesterday 20:49 UTC+2.0

Top Quote
SandJ
Avatar
Topic Opener
Joined: 2015-05-08, 22:46 UTC+2.0
Posts: 29
OS: Linux
Ranking
Pry about Widelands
Location: UK
Posted at: Yesterday 22:14 UTC+2.0
    send_to_all_inboxes("text"),

gives me "attempt to index a nil value (global 'game')"

    send_to_all_inboxes(_("text")),

gives me "attempt to index a nil value (global 'game')"

    message_box(_("xyz"), _("ABC")),

crashes with "FATAL ERROR: Received signal 11 (Segmentation fault)"

    message_box(_("xyz"), p(_("ABC"))),

crashes with "FATAL ERROR: Received signal 11 (Segmentation fault)"

    message_box("xyz","ABC"),

crashes with "FATAL ERROR: Received signal 11 (Segmentation fault)"

    send_to_inbox(1, _("xyz"), _("ABC"), {popup=false}),

gives me "attempt to index a number value (local 'player'"

    campaign_message_box(_("xyz"), _("ABC")),

gives me "attempt to index a string value (local 'message')"

and so on.

Edited: Yesterday 22:14 UTC+2.0

Top Quote
SandJ
Avatar
Topic Opener
Joined: 2015-05-08, 22:46 UTC+2.0
Posts: 29
OS: Linux
Ranking
Pry about Widelands
Location: UK
Posted at: Yesterday 23:30 UTC+2.0

I have tried:

campaign_message_box({title = "This is the title", body = p("Hi, this is my first scenario")})

from the Scenario Tutorial, but that causes a "FATAL ERROR: Received signal 11 (Segmentation fault)" crash.


Top Quote