Page 1 of 1

Message Box Format

Posted: Mon May 30, 2022 8:44 pm
by vettim89
First here is the code

Code: Select all

local SUB1=ScenEdit_GetKeyValue('SUB1')
if SUB1==nil then 
SUB1='0'
end
local SUB2=ScenEdit_GetKeyValue('SUB2')
if SUB2==nil then 
SUB2='0'
end
local SUB3=ScenEdit_GetKeyValue('SUB3')
if SUB3==nil then 
SUB3='0'
end
local SUB4=ScenEdit_GetKeyValue('SUB4')
if SUB4==nil then 
SUB4='0'
end
local SUB5=ScenEdit_GetKeyValue('SUB5')
if SUB5==nil then 
SUB5='0'
end
local SUB6=ScenEdit_GetKeyValue('SUB6')
if SUB6==nil then 
SUB6='0'
end
local SUB7=ScenEdit_GetKeyValue('SUB7')
if SUB7==nil then 
SUB7='0'
end
local SUB8=ScenEdit_GetKeyValue('SUB8')
if SUB8==nil then 
SUB8='0'
end
local SUB9=ScenEdit_GetKeyValue('SUB9')
if SUB9==nil then 
SUB9='0'
end
local SUB10=ScenEdit_GetKeyValue('SUB10')
if SUB10==nil then 
SUB10='0'
end
local SURFACE1=ScenEdit_GetKeyValue('SURFACE1')
if SURFACE1==nil then 
SURFACE1='0'
end
local SURFACE2=ScenEdit_GetKeyValue('SURFACE2')
if SURFACE2==nil then 
SURFACE2='0'
end
local SURFACE3=ScenEdit_GetKeyValue('SURFACE3')
if SURFACE3==nil then 
SURFACE3='0'
end
local mess='The remaining telports are:\n\nSUB 1  ('..SUB1..')\n\nSUB 2  ('..SUB2..')\n\nSUB 3  ('..SUB3..')\n\nSUB 4  ('..SUB4..')\n\nSUB 5  ('..SUB5..')\n\nSUB 6  ('..SUB6..')\n\nSUB 7  ('..SUB7..')\n\nSUB 9  ('..SUB9..')\n\nSUB 10  ('..SUB10..')\n\nSURFACE 1  ('..SURFACE1..')\n\nSURFACE 2  ('..SURFACE2..')\n\nSURFACE 3  ('..SURFACE3..')'
ScenEdit_MsgBox(mess, 1)
Now I have a bunch of special actions that allow the player to teleport units in the first few hours of the scenario. I was trying to create a Special Action with the above code so the player could check on how many of each teleports that are remaining. The message box pops up but is tiny and all the text is smashed. Also the message is incorrect as it reads: SUB 1 ()
SUB 2 ()
etc

With the error check built in as all the Key Values are nil in this iteration, the values should all be converted to '0'.

So I have two questions: why am I not getting the proper data inserted into the message? I have used the ('..variable..') syntax before and it works. Secondly, why is my message box so small and more importantly is there a way to make it bigger?

Thanks as always. I have been coding a lot this weekend and my brain is a bit fried. Just hoping you nice people can detangle this for me

Re: Message Box Format

Posted: Mon May 30, 2022 8:48 pm
by musurca
1) SE_GetKeyValue(...) never returns nil. It returns an empty string if there's no entry -- check for that instead.

2) You can't adjust the size of SE_MsgBox(...), unfortunately -- there's a hard character limit beyond which your messages are just truncated. For longer messages with special formatting, use SE_SpecialMessage(...) instead (which uses HTML tags).

Re: Message Box Format

Posted: Tue May 31, 2022 1:40 pm
by vettim89
musurca wrote: Mon May 30, 2022 8:48 pm 1) SE_GetKeyValue(...) never returns nil. It returns an empty string if there's no entry -- check for that instead.

2) You can't adjust the size of SE_MsgBox(...), unfortunately -- there's a hard character limit beyond which your messages are just truncated. For longer messages with special formatting, use SE_SpecialMessage(...) instead (which also supports HTML tags).
I tried using special message but the text didn't accept the \n for a new line - it just appeared as one continuous line which is very hard to read

Re: Message Box Format

Posted: Tue May 31, 2022 6:18 pm
by musurca
That's right — a "\n" won't read as a newline to SE_SpecialMessage(...) because it uses HTML formatting. Use a "<br>" tag instead.

Re: Message Box Format

Posted: Wed Jun 01, 2022 10:32 pm
by vettim89
musurca wrote: Tue May 31, 2022 6:18 pm That's right — a "\n" won't read as a newline to SE_SpecialMessage(...) because it uses HTML formatting. Use a "<br>" tag instead.
I am just posting this so others can see the HTML code. There are some minor variations from Java and the text in SE_MessageBox

Code: Select all

local SUB1=ScenEdit_GetKeyValue('SUB1')
if SUB1=='' then 
SUB1='0'
end
print(SUB1)
local SUB2=ScenEdit_GetKeyValue('SUB2')
if SUB2=='' then 
SUB2='0'
end
local SUB3=ScenEdit_GetKeyValue('SUB3')
if SUB3=='' then 
SUB3='0'
end
local SUB4=ScenEdit_GetKeyValue('SUB4')
if SUB4=='' then 
SUB4='0'
end
local SUB5=ScenEdit_GetKeyValue('SUB5')
if SUB5=='' then 
SUB5='0'
end
local SUB6=ScenEdit_GetKeyValue('SUB6')
if SUB6=='' then 
SUB6='0'
end
local SUB7=ScenEdit_GetKeyValue('SUB7')
if SUB7=='' then 
SUB7='0'
end
local SUB8=ScenEdit_GetKeyValue('SUB8')
if SUB8=='' then 
SUB8='0'
end
local SUB9=ScenEdit_GetKeyValue('SUB9')
if SUB9=='' then 
SUB9='0'
end
local SUB10=ScenEdit_GetKeyValue('SUB10')
if SUB10=='' then 
SUB10='0'
end
local SURFACE1=ScenEdit_GetKeyValue('SURFACE1')
if SURFACE1=='' then 
SURFACE1='0'
end
local SURFACE2=ScenEdit_GetKeyValue('SURFACE2')
if SURFACE2=='' then 
SURFACE2='0'
end
local SURFACE3=ScenEdit_GetKeyValue('SURFACE3')
if SURFACE3=='' then 
SURFACE3='0'
end

local mess2='The remaining telports are:<br><br>SUB1............'..(SUB1)..'<br>SUB2............'..(SUB2)..'<br>SUB3............'..(SUB3)..'<br>SUB4............'..(SUB4)..'<br>SUB5............'..(SUB5)..'<br>SUB6............'..(SUB6)..'<br>SUB7............'..(SUB7)..'<br>SUB8............'..(SUB8)..'<br>SUB9............'..(SUB9)..'<br>SUB10..........'..(SUB10)..'<br>SURFACE1....'..(SURFACE1)..'<br>SURFACE2....'..(SURFACE2)..'<br>SURFACE3....'..(SURFACE3)
ScenEdit_SpecialMessage('USSR', mess2)
It works as intended. I used the '...' because I couldn't figure out the tab character. I guess there is not <tab> in HTML. Or that is what I could figure out. I am not...repeat...not learning yet another coding language

Re: Message Box Format

Posted: Wed Jun 01, 2022 10:43 pm
by musurca
https://www.geeksforgeeks.org/how-to-in ... -html-css/

Code: Select all

Regular space = &nbsp;

Two spaces  gap = &ensp;

Four spaces    gap = &emsp;
Welcome to 1993!