Page 1 of 1

How to use Unit properties marked "ScenEdit only?"

Posted: Sun Jul 26, 2020 8:20 pm
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?

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

Posted: Mon Jul 27, 2020 9:11 am
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.

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

Posted: Tue Jul 28, 2020 5:45 am
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.

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

Posted: Wed Jul 29, 2020 4:45 am
by michaelm75au
I'll investigate over the weekend.
Thanks

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

Posted: Thu Jul 30, 2020 11:55 pm
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.

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

Posted: Sat Aug 01, 2020 9:17 pm
by musurca
Makes sense, thanks for looking into it — much appreciated.

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

Posted: Wed Feb 24, 2021 5:46 pm
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