The following runs consistently for me on my setup, it's not clear if you wanted empty lines between them or not so I showed both.
Code: Select all
local function testme(a)
if a == nil then a = false; end
local unit = ScenEdit_GetUnit({name='3MN-1 Bison B [Bomber]', guid='4FH7PU-0HMOEHD2GN2HM'});
local event_description = 'UNKNOWN EVENT';
local iff = 'SIGMA';
local fmt;
if a then
fmt = 'Event: %s\r\n\r\nUnit: [%s] - %s , %s\r\n\r\nIFF: %s\r\n\r\nGUID: %s\r\n\r\nAlt: %s\r\n\r\nSpeed: %s\r\n'
else
fmt = 'Event: %s\r\nUnit: [%s] - %s , %s\r\nIFF: %s\r\nGUID: %s\r\nAlt: %s\r\nSpeed: %s\r\n'
end
local msg = string.format(fmt,event_description,unit.name,unit.type,unit.classname,iff,unit.guid,unit.altitude,unit.speed);
return msg
end
ScenEdit_MsgBox(testme(true),0);
ScenEdit_MsgBox(testme(false),0);
ScenEdit_InputBox(testme(true));
ScenEdit_InputBox(testme(false));
produces:

- cmo_msgbox.jpg (30.15 KiB) Viewed 1491 times

- cmo_msgbox_noempty.jpg (28.86 KiB) Viewed 1491 times

- cmo_inputbox.jpg (33.04 KiB) Viewed 1491 times

- cmo_inputbox_noempty.jpg (32.04 KiB) Viewed 1491 times
At present there is no getting around the annoying forced wrapping that happens anywhere between char's 32-xx depending on char codes used, though most a-z-0-9 + space and standard symbols combos will break between 34-48 depending on spacing and actual space used by each char. If you want flexibility use SpecialMessage, of course you can't get any player input from them. Also, msgbox's inside events aren't a great idea unless you really need to halt execution and have the player decide something with a yes\no\cancel sort of response, or are just debugging.
Your code with double spacing, and correct var declarations (remove a set of \r \n to remove empty lines):
Code: Select all
-- action: present event triggering unit
ScenEdit_UseAttachment('Lua script: common.lua') --if so common why are they not global already and loaded at scene load?
local unit = ScenEdit_UnitX();
local event_description = 'UNKNOWN EVENT';
local event = EventX();
if event ~= nil then
event_description = tostring( event.description );
end
if (unit ~= nil) and (unit.guid ~= nil) then
local iff = GetUnitIFF(unit);
local message = string.format('Event: %s\r\n\r\nUnit: [ %s ] - %s, %s\r\n\r\nIFF: %s\r\n\r\nguid: %s\n\r',event_description,unit.name,unit.type,unit.classname,iff,unit.guid);
ScenEdit_MsgBox( message, 0 );
unit = nil
else
print('ERROR: unit not recognized');
end