So I noticed when trying the unit wrapper .moveto property it throws an error.
Not sure what I'm doing wrong to access\set this property?
Code: Select all
local tbl;
--tbl = {type = 'Submarine', name = 'SSN-802 single', dbid = 554, side = 'Blue',
--loadoutid = 0,heading = 0, Latitude="S4.50.00",Longitude="W10.00.00",
--autodetectable="false",holdfire="true",proficiency=4,speed=0,depth=0,altitude=0};
tbl = {type = 'Aircraft', name = 'F-22', dbid = 3821, side = 'Blue',loadoutid = 4526,
heading = 0, Latitude="S2.50.00",Longitude="W10.00.00",autodetectable="false",
holdfire="true",proficiency=4,speed=0,depth=0,altitude=12000};
local u = ScenEdit_AddUnit(tbl);
u.moveto = false;
--u.moveto = 'false';-- same error
--u.moveto = 'No'; -same error
--print(tostring(u.moveto)) -- function address luaNet_function: 49A3B028
--print(u.moveto); --KeraLua.LuaFunction
Code: Select all
System.InvalidCastException:
Unable to cast object of type 'KeraLua.LuaFunction' to type
'System.Reflection.MemberInfo'.at NLua.MetaFunctions.TrySetMember
(Lua luaState, ProxyType targetType, Object target, BindingFlags
bindingType, String& detailMessage) at NLua.MetaFunctions.
SetFieldOrPropertyInternal(Lua luaState)
at NLua.MetaFunctions.SetFieldOrProperty(IntPtr state)
at KeraLua.NativeMethods.lua_pcallk(IntPtr luaState,
Int32 nargs, Int32 nresults,
Int32 errorfunc, IntPtr ctx, IntPtr k)
at NLua.Lua.DoString(String chunk, String chunkName)
at Command_Core.Lua.LuaSandBox.RunScript(String str, Boolean RunInteractively,
String script),nil
Also when trying to use .manualAltitude when feeding it anything other than 'off',
'current','desired', I get no results \ change, other than the default 20 meters\-66 ft.
Code: Select all
local tbl;
tbl = {type = 'Submarine', name = 'SSN-802 single', dbid = 554,
side = 'Blue', loadoutid = 0,heading = 0, Latitude="S4.50.00",
Longitude="W10.00.00", autodetectable="false",holdfire="true",
proficiency=4,speed=0,depth=0,altitude=0};
-- tbl = {type = 'Aircraft', name = 'F-22', dbid = 3821, side = 'Blue',
-- loadoutid = 4526, heading = 0, Latitude="S2.50.00",Longitude="W10.00.00",
-- autodetectable="false",holdfire="true",proficiency=4,
-- speed=0,depth=0,altitude=11000};
local u = ScenEdit_AddUnit(tbl);
print(tostring(u.manualAltitude)); --nil expected i guess?
u.manualAltitude = -100; print(u.manualAltitude);
u.manualAltitude = '-100 FT'; print(u.manualAltitude);
u.manualAltitude = 6; print(u.manualAltitude); --surface code for subs?
u.manualAltitude = -6; print(u.manualAltitude);
u.manualAltitude = '-100'; print(u.manualAltitude);
u.manualAltitude = 'OVERLAYER'; print(u.manualAltitude); --change for air
u.manualAltitude = 'Surface'; print(u.manualAltitude); --change for air
u.manualAltitude = 'Off'; print(u.manualAltitude);
Works entire as expected with aircraft however, just not with subs.
Also found cases where using ScenEdit_SetUnit() throws the follow errors where
I don't understand why it's doing so, when any preset keywords are used other then
current,desired, or off, however unlike the above supplying numbers or text form of
number does work.
Code: Select all
local tbl;
tbl = { type = 'Submarine', name = 'SSN-802 single', dbid = 554,
side = 'Blue',loadoutid = 0,heading = 0, Latitude="S4.50.00",
Longitude="W10.00.00", autodetectable="false",holdfire="true",
proficiency=4,speed=0,depth=0,altitude=0 };
local u = ScenEdit_AddUnit(tbl);
print(u.manualAltitude);
u= ScenEdit_SetUnit({guid=u.guid,moveto=false,manualAltitude=0});
print(u.manualAltitude);
u= ScenEdit_SetUnit({guid=u.guid,moveto=true,manualAltitude=6});
print(u.manualAltitude);
u= ScenEdit_SetUnit({guid=u.guid,moveto=false,manualAltitude=-90});
print(u.manualAltitude);
u= ScenEdit_SetUnit({guid=u.guid,moveto=false,manualAltitude='6'});
print(u.manualAltitude);
u= ScenEdit_SetUnit({guid=u.guid,moveto=false,manualAltitude='-100'});
print(u.manualAltitude);
u= ScenEdit_SetUnit({guid=u.guid,moveto=false,manualAltitude='-90 FT'});
print(u.manualAltitude);
u= ScenEdit_SetUnit({guid=u.guid,moveto=false,manualAltitude='Off'});
print(u.manualAltitude);
Code: Select all
--- examples that throws errors
u= ScenEdit_SetUnit({guid=u.guid,moveto=false,manualAltitude='Overlayer'});
-- print(u.manualAltitude);
-- u= ScenEdit_SetUnit({guid=u.guid,moveto=false,manualAltitude='Surface'});
-- print(u.manualAltitude);
-- u= ScenEdit_SetUnit({guid=u.guid,moveto=false,manualAltitude="Underlayer"});
-- print(u.manualAltitude);
ERROR: Unable to cast object of type 'Command_Core.Submarine'
to type 'Command_Core.Aircraft'.
Again only problematic on subs when using the keywords, on aircraft with the right keywords
for aircraft they work.
Sort of besides the point but the simple thing I was trying to do, spawn sub that
would not start going to default desired -66 feet upon pressing play via,
when I ran into the above.
Code: Select all
u = addunit ({bla, bla ,etc, altitude = 0})
u.moveto = false
u.manualAltitude = 'off'I know the workaround is to do this instead, but something seems wrong
with manualAltitude and subs.
Code: Select all
u = addunit({bla,bla, bla,altitude=0});
u=setunit({guid= u.guid,moveto=true,manualAltitude='Off',depth=u.altitude})
Edit: Added attachment for the post in .txt form due to formatting.
..never-mind fixed post formatting I think.
