Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

MSG Box

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> MSG Box Page: [1]
Login
Message << Older Topic   Newer Topic >>
MSG Box - 3/13/2021 8:40:36 PM   
No New Messages
vettim89
Matrix Legion of Merit



Posts: 3615
Joined: 7/14/2007
From: Toledo, Ohio
Status: offline
Is there a way to embed game data into a msg box message? For example a message pops up when a ship has approached within a mile of it and the message reads: "Merchant ship (ship.name) reports that enemy naval forces are ordering them to stop?" The ship.name would be the ship being asked to stop

_____________________________

"We have met the enemy and they are ours" - Commodore O.H. Perry
Post #: 1
RE: MSG Box - 3/13/2021 11:48:03 PM   
No New Messages
michaelm75au
Moderator



Posts: 13500
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
In a Lua script:
local ship = SE_GetUnit({name='SS Minow'})
local msg = 'Merchant ship (' .. ship.name .. ') reports that enemy naval forces are ordering them to stop'
ScenEdit_MsgBox (msg,0)

_____________________________

Michael

(in reply to vettim89)
Post #: 2
RE: MSG Box - 5/9/2021 11:40:32 AM   
No New Messages
butch4343
Matrix Veteran


 

Posts: 327
Joined: 3/26/2015
Status: offline
Michael,

I wonder if you might be able to help me with something similar, I know am always asking for help, I have been learning , watched a couple of videos on you tube about scripting functions and am taking baby steps lol but huge leaps for me lol

I have discovered how to create a special action msg for a player and it works fine for fixed responses, ie XXX now added to airfield YYY

I want to be able to get a special action that will return a score, so I can use the following to print the score in the console

>> local y= ScenEdit_GetScore('Loop')
print(y)
53


And I can use ScenEdit_SpecialMessage('Loop','The Score Is') to get a pop up special action box that says The Score Is

What I cant see is how to combine the result of the score with the message , I tried :


local a= ScenEdit_GetScore('Loop')

ScenEdit_SpecialMessage('Loop','The Score Is ..(a)')


I bet this will be a real easy thing as well


That treats the whole lot as a string so I get 'The Score Is ..(a)'

So I guess what am asking is how do I add a string and a variable in a message?

I have tried
ScenEdit_SpecialMessage('Loop','The Score Is' and a) that got me a
ERROR: [string "Console"]:4: Invalid arguments to method call

Ive checked the Github page and the LUA documentation page and even tried a google search to no avail.I bet this will be a real easy thing as well


Regards

Butch




(in reply to michaelm75au)
Post #: 3
RE: MSG Box - 5/9/2021 11:17:51 PM   
No New Messages
KnightHawk75
Matrix Elite Guard


 

Posts: 1450
Joined: 11/15/2018
Status: offline
quote:

ORIGINAL: butch4343

...
What I cant see is how to combine the result of the score with the message , I tried :

local a= ScenEdit_GetScore('Loop')
ScenEdit_SpecialMessage('Loop','The Score Is ..(a)')

I bet this will be a real easy thing as well

That treats the whole lot as a string so I get 'The Score Is ..(a)'

So I guess what am asking is how do I add a string and a variable in a message?
....

When you want to append
Var .. ThingYouWantToAppend
examples:
-- print "Sometext " 1 through 10 
for i=1,10 do
  print("SomeText " .. i);
end
-- your example:
local a= ScenEdit_GetScore('Loop');
ScenEdit_SpecialMessage('Loop','The Score is '  .. a)

-- your example no intermediate var: 
ScenEdit_SpecialMessage('Loop','The Score is '  .. tostring(ScenEdit_GetScore('Loop') );

-- your example no intermediate var with old school html mark up to color Score text as Green: 
ScenEdit_SpecialMessage("Loop",'<P>The Score is <FONT color="#00FF00">'  .. tostring(ScenEdit_GetScore('Loop') .. '</FONT></P>'));


This is pretty dated (written for 5.0) but all the basic language concepts are mostly still the same in 5.3.x
Programming in Lua 5.0: https://www.lua.org/pil/contents.html#P1 (can find later versions on web or buy them.)
Concatenation: https://www.lua.org/pil/3.4.html

Lua 5.3.x manual (for the things that are different in 5.3): https://www.lua.org/manual/5.3/


< Message edited by KnightHawk75 -- 5/10/2021 12:31:58 AM >

(in reply to butch4343)
Post #: 4
RE: MSG Box - 5/9/2021 11:48:51 PM   
No New Messages
KnightHawk75
Matrix Elite Guard


 

Posts: 1450
Joined: 11/15/2018
Status: offline
BTW for those wanting to know what the options are for the numeric option values for MsgBox, and the exact return values when different things are pressed here they.
-- 6+ will result to 0 \ ie OkOnly.
--[[
gKH.Constants.MsgBoxType={}
gKH.Constants.MsgBoxType.OKOnly=0;
gKH.Constants.MsgBoxType.OKCancel=1;
gKH.Constants.MsgBoxType.AbortRetryIgnore=2;
gKH.Constants.MsgBoxType.YesNoCancel=3;
gKH.Constants.MsgBoxType.YesNoOnly=4;
gKH.Constants.MsgBoxType.RetryCancel=5;
gKH.Constants.MsgBoxResult={}
gKH.Constants.MsgBoxResult.OK = "OK";
gKH.Constants.MsgBoxResult.No = "No";
gKH.Constants.MsgBoxResult.Yes = "Yes";
gKH.Constants.MsgBoxResult.Cancel = "Cancel";
gKH.Constants.MsgBoxResult.Retry = "Retry";
gKH.Constants.MsgBoxResult.Ignore = "Ignore";
--]]
Example of getting input from user, and checking which button was pressed after you repeat their entry back to them.
local msgboxresult = ScenEdit_MsgBox("You entered the text: \n\r" .. tostring(ScenEdit_InputBox("Please enter some text:")),
4);
if msgboxresult == "Yes" then 
  ScenEdit_MsgBox('You pressed Yes.',0);
elseif msgboxresult == "No" then 
  ScenEdit_MsgBox('You pressed No.',0);
elseif msgboxresult == "Cancel" then 
  ScenEdit_MsgBox('Hey, you close the window before answering!',0);
else 
  ScenEdit_MsgBox('Um, we should never get here.',0);
end


< Message edited by KnightHawk75 -- 5/9/2021 11:49:11 PM >

(in reply to KnightHawk75)
Post #: 5
RE: MSG Box - 5/12/2021 11:11:37 AM   
No New Messages
butch4343
Matrix Veteran


 

Posts: 327
Joined: 3/26/2015
Status: offline
Knighthawk,

Thanks for this, I could'nt figure out the link between the two. As always your help has been invaluable mate.

Regards

Butch

(in reply to KnightHawk75)
Post #: 6
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> MSG Box Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

0.750