How to use Unit properties marked "ScenEdit only?"

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
musurca
Posts: 168
Joined: Wed Jul 15, 2020 10:06 pm
Contact:

How to use Unit properties marked "ScenEdit only?"

Post by musurca »

In the CommandLua API documentation, there are a series of properties for the Unit wrapper marked "ScenEdit only." How are these used?

In particular I'd like to use the 'refuel' property, which is marked as a boolean and apparently triggers the unit to attempt to UNREP. (I was trying to use it as an alternative to ScenEdit_RefuelUnit, which currently has no effect on naval units.)

However, if I try to set it to true, I get the following error:
System.InvalidCastException: Unable to cast object of type 'KeraLua.LuaFunction' to type 'System.Reflection.MemberInfo'.

I also tried calling it as a method, but that doesn't work either. Is there any more information on this?
User avatar
michaelm75au
Posts: 12465
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: How to use Unit properties marked "ScenEdit only?"

Post by michaelm75au »

The ones marked 'ScenEdit Only' can only be used with the normal 'ScenEdit_' commands like ScenEdit_SetUnit().

ScenEdit_RefuelUnit() should work for ships. It use to be for aircraft only, but was changed some time back from memory.
Michael
musurca
Posts: 168
Joined: Wed Jul 15, 2020 10:06 pm
Contact:

RE: How to use Unit properties marked "ScenEdit only?"

Post by musurca »

Thanks for the reply, Michael. Unfortunately I've found that ScenEdit_RefuelUnit() does not work with ships, as of latest Steam build (1147.4).

I've attached a scenario that demonstrates it. When you start it, select the cutter marked 'Unit to UNREP,' then go to Special Actions, and go to "Run ScenEdit_RefuelUnit on selected unit." It will have no effect.

You can then right-click on the ship, go to "UNREP (if possible)," and select "Select tanker automatically" and it will start to refuel.

Basically I've found that while you can manually tell ships to refuel from the GUI, they will do not so automatically on missions, nor can you tell them to refuel from Lua.
Attachments
RefuelingDemo.zip
(7.39 KiB) Downloaded 29 times
User avatar
michaelm75au
Posts: 12465
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: How to use Unit properties marked "ScenEdit only?"

Post by michaelm75au »

I'll investigate over the weekend.
Thanks
Michael
User avatar
michaelm75au
Posts: 12465
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: How to use Unit properties marked "ScenEdit only?"

Post by michaelm75au »

Found the problem - I had a test reversed so it WASN'T doing UNREP if a ship, instead of the other way round. I think I mucked it up when I was doing some housekeeping on the code earlier this year.
Michael
musurca
Posts: 168
Joined: Wed Jul 15, 2020 10:06 pm
Contact:

RE: How to use Unit properties marked "ScenEdit only?"

Post by musurca »

Makes sense, thanks for looking into it — much appreciated.
Parel803
Posts: 962
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: How to use Unit properties marked "ScenEdit only?"

Post by Parel803 »

Good evening,
Hope it's oke to ask a little more on the RAS option, RefuelUnit
Like it it works for my ships.

The Github site states I could also assign a unit which is in a mission, does that includes ships?
Tried: ScenEdit_RefuelUnit({guid='50PVO4-0HM6OV6K7KCVP', missions={'tstrefuel'}}) where the GuiD is the ship.

Another question: is it possible to cancel a replenishment order?

with regards Gert-Jan
Post Reply

Return to “Lua Legion”