Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

Readout for different fuel types?

 
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 >> Readout for different fuel types? Page: [1]
Login
Message << Older Topic   Newer Topic >>
Readout for different fuel types? - 6/10/2020 9:30:57 PM   
AndrewJ

 

Posts: 2318
Joined: 1/5/2014
Status: offline
Hello,

I'm currently playing a scenario with many different tankers in use, and most of these have multiple different types of fuel on board. Unfortunately, the unit display doesn't show the quantities of each different type remaining on the ship.

Is there a Lua way (for a complete Lua beginner) to get a readout of the current quantities of oil, gas, diesel, and aviation fuel on a specific ship? (Ideally, click on ship, run script, get readout?)

Many thanks,

Andrew
Post #: 1
RE: Readout for different fuel types? - 6/11/2020 1:13:13 AM   
Gunner98

 

Posts: 5508
Joined: 4/29/2005
From: The Great White North!
Status: offline
This is a great idea. A special action would work but I have no idea what the script would look like.


_____________________________

Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/

(in reply to AndrewJ)
Post #: 2
RE: Readout for different fuel types? - 6/11/2020 2:06:49 AM   
michaelm75au


Posts: 13500
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
Something like this but it can be cleaned up and made 'pretty':
quote:

local s = ScenEdit_SelectedUnits()
for k,v in pairs(s.units) do
print(string.format("Fuel status for %s ( guid: %s)", v.name, v.guid))
local u = ScenEdit_GetUnit({name=v.guid})
local f = u.fuel
--print(f)
for type,level in pairs(f) do
print(string.format("%-16.16s current: %s maximum: %s available: %.02f %%", level.name, level.current, level.max, (level.current/level.max)*100))
end
print('-------------');print('\n')
end


Results

quote:

Fuel status for AOE 421 Sagami ( guid: 004aa55d-d553-428d-a727-26853737c8f4)
DieselFuel current: 1999978.125 maximum: 2000000 available: 99.99890625 %
OilFuel current: 7150000.0 maximum: 7150000 available: 100.0 %
AviationFuel current: 100000.0 maximum: 100000 available: 100.0 %
-------------


Fuel status for SS 583 Harushio ( guid: 3a5f2a57-36e2-48f6-9352-00b819789a18)
DieselFuel current: 60000.0 maximum: 60000 available: 100.0 %
Battery current: 6000.0 maximum: 6000 available: 100.0 %
-------------


< Message edited by michaelm75au -- 6/11/2020 2:12:37 AM >


_____________________________

Michael

(in reply to Gunner98)
Post #: 3
RE: Readout for different fuel types? - 6/11/2020 3:33:54 AM   
AndrewJ

 

Posts: 2318
Joined: 1/5/2014
Status: offline
Awesome! I'll give it a try tomorrow.

(in reply to michaelm75au)
Post #: 4
RE: Readout for different fuel types? - 6/11/2020 10:51:11 AM   
KnightHawk75

 

Posts: 1450
Joined: 11/15/2018
Status: offline
Pretty version I scraped together for you (I already had the nuts and bolts).



Copy the attached SA_SelectedUnits_PrettyFuelReport.lua into a repeatable Special Action on your side.

The only thing you need to change is at the very bottom to use the correct side name.
--first param is the side you want the message generated too, true\false is if you want color coding or not.
BuildTable('RedSide',true)

note:
If you want to screw around with different numbers for red\orange\green you can just adjust the numbers in prettyFuelTableEntry()'s local redPct,orangepct,greenpct = 20.0,40.0,40.0 line. Obviously you can change the color codes and formatting as well in the stylesheet if you want to tweek the looks.




Attachment (1)

(in reply to AndrewJ)
Post #: 5
RE: Readout for different fuel types? - 6/11/2020 2:27:17 PM   
Gunner98

 

Posts: 5508
Joined: 4/29/2005
From: The Great White North!
Status: offline
Great stuff. I'll put this in the next update for the scenario - and a few others that I can think of.

Is there a way that the Special Action could be applied to one selected unit? For instance, have an AOR selected, hit the SA and get a readout for just that one ship?

Thanks

_____________________________

Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/

(in reply to KnightHawk75)
Post #: 6
RE: Readout for different fuel types? - 6/11/2020 5:33:09 PM   
KnightHawk75

 

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

quote:

ORIGINAL: Gunner98
Is there a way that the Special Action could be applied to one selected unit? For instance, have an AOR selected, hit the SA and get a readout for just that one ship?

Thanks


Yea, just select the 1 unit and press the action.??
At present it does whatever you have selected, be that 1, be that 20, and it handles selected groups too.
--
Now, if you want to specifically limit it to a particular pre-set unit or set of units, if that's what you meant, you can change where it's getting the list from and just feed it your own list of guids. All it really needs is a table of unit\group guids who's entries a 'guid' field.

To do that easiest with touching the least amount of code is create your own list.
So let's assume gBDude.SceneGlobals table exists just for spit-balling example.

Create a table with what you want it to process looking just like a selectedUnits table.
gBDude.SceneGlobals.SomeListFormatedLikeSelectedUnits = {
units{
{guid="guid1",name="bla bla"},
{guid="guid2",name='bla bla'},
...etc etc..}
};

Then in processSelectedUnits()
all you'd have to change is
local sUnits=ScenEdit_SelectedUnits() to local sUnits=gBDude.SceneGlobals.SomeListFormatedLikeSelectedUnits

or
You could just change the first nil check and the first 'for' to operate on gBDude.SceneGlobals.SomeListFormatedLikeSelectedUnits instead of 'sUnits.units'

Now if you wanted to adjust it to take said table as parameter you could also do that but you'll have to pass the parameter into buildtable, and then have it pass it on to processselectunits, and add the params in both function declarations etc and maybe another adjustment or two I'm nothing thinking about atm. I figure the first two ways are the most simple.


(in reply to Gunner98)
Post #: 7
RE: Readout for different fuel types? - 6/11/2020 9:11:32 PM   
AndrewJ

 

Posts: 2318
Joined: 1/5/2014
Status: offline
This is working great - a superb edition to a long-duration logistics-driven scenario. Many thanks!

(in reply to KnightHawk75)
Post #: 8
RE: Readout for different fuel types? - 1/1/2022 11:22:10 AM   
Parel803

 

Posts: 579
Joined: 10/10/2019
From: Netherlands
Status: offline
I like this function and tried it out, works great. Want it to use with pre-determined units. But I'm doing something wrong. tried to change accordingly the orders but got:
'Please select one or more units first.'

I made this:
gBDude={}
gBDude.SceneGlobals={}
gBDude.SceneGlobals.SomeListFormatedLikeSelectedUnits={
{name='F 802 De Zeven Provinciën', guid='P7ML9T-0HMECC07850U3'},
{name='P 840 Holland', guid='P7ML9T-0HMED2D1QP4KD'},
{name='F 930 Leopold I [Karel Doorman]', guid='P7ML9T-0HMED2D1QP8E0'}
};

local function processSelectedUnits(pcolor)
local sUnits=gBDude.SceneGlobals.SomeListFormatedLikeSelectedUnits
local tbl ={};
if(sUnits.units ~=nil) then
local u,g; local counter=0;
for k,v in pairs(sUnits.units) do --loop though selected unit table
u = ScenEdit_GetUnit({guid=v.guid}); --get the unit.
if ((u~=nil) and u.type ~='Group') then --are we valid and not a group?
table.insert(tbl,prettyFuelTableEntry(u,pcolor)); counter = counter + 1;
elseif((u~=nil) and u.type =='Group') then --are we valid and also a group?
g = u.group.unitlist; --simply array of unit guids of members.
for l,m in pairs(g) do
u = ScenEdit_GetUnit({guid=m}); --get the unit.
if ( (u ~= nil) and u.type ~='Group') then -- are we valid and not also another group?
table.insert(tbl,prettyFuelTableEntry(u,pcolor)); counter = counter + 1;
else
ScenEdit_MsgBox('Could not obtain the object for one of selected units with guid: ' ..tostring(m), 1);
end
u=nil;
end
else
ScenEdit_MsgBox('Could not obtain the object for one of selected units with guid: ' ..tostring(v.guid), 1);
end
u=nil;
end

ScenEdit_MsgBox(string.format('Completed fuel report on %s units',tostring(counter)), 1);
else
ScenEdit_MsgBox('Please select one or more units first.', 1);
end
sUnits=nil;
return tbl;
end


It all goes beyond my comprehension, hope you spot my mistake.
best regards GJ and best wishes for 2022

(in reply to AndrewJ)
Post #: 9
RE: Readout for different fuel types? - 1/1/2022 12:08:52 PM   
BDukes

 

Posts: 1695
Joined: 12/27/2017
Status: offline
Wow. I was out of commission when this KH posted this. Vedddy niiiice!

Mike

_____________________________

Don't call it a comeback...

(in reply to Parel803)
Post #: 10
RE: Readout for different fuel types? - 1/6/2022 9:39:59 PM   
KnightHawk75

 

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

ORIGINAL: Parel803

I like this function and tried it out, works great. Want it to use with pre-determined units. But I'm doing something wrong. tried to change accordingly the orders but got:
'Please select one or more units first.'

I made this:
...

It all goes beyond my comprehension, hope you spot my mistake.
best regards GJ and best wishes for 2022


I've not had a chance to eye ball this in-game yet, but from what you explain I maybe your table of units isn't in the same format\structure as a 'selected units' table. As I recall it would look like this:

gBDude.SceneGlobals.SomeListFormatedLikeSelectedUnits={
units={
{name='F 802 De Zeven Provinciën', guid='P7ML9T-0HMECC07850U3'},
{name='P 840 Holland', guid='P7ML9T-0HMED2D1QP4KD'},
{name='F 930 Leopold I [Karel Doorman]', guid='P7ML9T-0HMED2D1QP8E0'}}
}

ie things are in sub-table 'units' (groups sub-table can exist as well), it's why that variable is named the way it is. Try that, let me know if you still get a failure.

quote:

ORIGINAL: BDukes

Wow. I was out of commission when this KH posted this. Vedddy niiiice!

Mike

Thanks :)



< Message edited by KnightHawk75 -- 1/6/2022 9:41:25 PM >

(in reply to Parel803)
Post #: 11
RE: Readout for different fuel types? - 1/7/2022 11:53:05 AM   
Parel803

 

Posts: 579
Joined: 10/10/2019
From: Netherlands
Status: offline
thanks agian for your time and answer
best regards GJ

and it works great, thx

< Message edited by Parel803 -- 1/7/2022 5:33:41 PM >

(in reply to KnightHawk75)
Post #: 12
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> Readout for different fuel types? 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.875