Jump to content

Recommended Posts

Posted (edited)

Hi, need some help about a text msg display script here.

 

I have 4 active aircrafts, and want to check their status like this way - flag 1~4 are for checking each aircrafts' status(flag 1 is for AC 1, flag 2 is for AC 2....), values of flag 11~14 are status of each aircrafts, so if the checking flag is true, message will display the value of the status flag, but false, will display 'NA'

 

For example, if the condition is

flag 1 is true, value of flag 11 is 12

flag 2 is false, value of flag 12 is 32

flag 3 is true, value of flag 13 is 21

flag 4 is false, value of flag 14 is 15

 

then the text message will display all aircrafts' values at once

AC 1 - 12

AC 2 - NA

AC 3 - 21

AC 4 - NA

 

I think it will be possible to do this via lua scripting, but don't have any idea how.

Help me guys!

Edited by horus0129
Posted

When do you want to check the status of each aircraft? If you check the status in a trigger then at the action you simply display the messages you posted in the last part, no need for a script.

[sIGPIC]OK[/sIGPIC]

Posted

To check the value of the flag via scripting you use

 

http://wiki.hoggit.us/view/Part_1

 number function trigger.misc.getUserFlag(string userFlagName)

 

If you want to continuously check their status and act upon it, you may want to use this: http://wiki.hoggit.us/view/ScheduleFunction

 

-- The following would schedule mist.groupToRandomZone to call and move 'myGroup' to a random point in zone every 900 seconds up till 3600 seconds after the function was first called.
do
   mist.scheduleFunction(mist.groupToRandomZone, {'myGroup', 'myZone'}, timer.getTime() + 10, 900, timer.getTime() + 3600)
end

 

But all of this can be done in the Missions Editor. More information is required as to when do you want to check the status and what triggers it.

314-я смешанная авиационная дивизия

314th Mixed Aviation Division: The "Fighting Lemmings"- Forums: http://314thsquadron.enjin.com/ - ED Forum Group: http://forums.eagle.ru/group.php?groupid=119

Posted
When do you want to check the status of each aircraft? If you check the status in a trigger then at the action you simply display the messages you posted in the last part, no need for a script.

 

I want all values of the flags and true or false conditions to be displayed in a single msg field. This msg will be activated at any time through F10 radio menu.

Posted (edited)

OK, then if you have added your radio item for F10 menu you can do this - or something similar - at the Action side (Do Script) of the trigger :

 

local statusMsg = ''
for i = 1, 4 do
if trigger.misc.getUserFlag(i) == true then
	statusMsg = statusMsg .. '\nAC ' .. i .. '-'..misc.getUserFlag(i)
else
	statusMsg = statusMsg .. '\nAC ' .. i.. '- N/A'
end
end
trigger.action.outText(statusMsg,10)

 

There may be an issue because a flag with a value can be considered true but that can be corrected. Try this first.

 

LE: scratch that, I see that you want to display other flags and not 1-4. Luckily the notation you chose is pretty similar so you will have to change it like that

 

local statusMsg = ''
for i = 1, 4 do
       j = '1'..i
if trigger.misc.getUserFlag(i) == true then
	statusMsg = statusMsg .. '\nAC ' .. i .. '-'..misc.getUserFlag(j)
else
	statusMsg = statusMsg .. '\nAC ' .. i.. '- N/A'
end
end
trigger.action.outText(statusMsg,10)

Edited by Zayets

[sIGPIC]OK[/sIGPIC]

Posted
OK, then if you have added your radio item for F10 menu you can do this - or something similar - at the Action side (Do Script) of the trigger :

 

local statusMsg = ''
for i = 1, 4 do
if trigger.misc.getUserFlag(i) == true then
	statusMsg = statusMsg .. '\nAC ' .. i .. '-'..misc.getUserFlag(i)
else
	statusMsg = statusMsg .. '\nAC ' .. i.. '- N/A'
end
end
trigger.action.outText(statusMsg,10)

 

There may be an issue because a flag with a value can be considered true but that can be corrected. Try this first.

 

LE: scratch that, I see that you want to display other flags and not 1-4. Luckily the notation you chose is pretty similar so you will have to change it like that

 

local statusMsg = ''
for i = 1, 4 do
       j = '1'..i
if trigger.misc.getUserFlag(i) == true then
	statusMsg = statusMsg .. '\nAC ' .. i .. '-'..misc.getUserFlag(j)
else
	statusMsg = statusMsg .. '\nAC ' .. i.. '- N/A'
end
end
trigger.action.outText(statusMsg,10)

 

Thanks Zayets! I'll try that soon.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...