[Logged] AddUnit function changes input causing problem (Full Version)

All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Tech Support



Message


DracheTek -> [Logged] AddUnit function changes input causing problem (7/22/2020 6:29:53 AM)

When input a barebone unit selector-name, type, side, position, dbid- in the function ScenEdit_AddUnit, the function autonomously fill the unit selector with information from spawned unit, especially guid, which will prevent me from spawning another unit with the original unit selector. This is annoying when I am doing a loop spawning multiple units using one set of data. Plus, it seems inconsistence with AddReferencePoint, which does not alter selector.

Currently my workaround is to do a hard copy of unit selector, and a new workaround is to set new properties to nil, but it will longer my code about twice.




Rory Noonan -> RE: AddUnit function changes input causing problem (7/22/2020 6:47:16 AM)

Can you post some example code and a scenario for us to look at? It's not immediately clear what the issue is




DracheTek -> RE: AddUnit function changes input causing problem (7/23/2020 12:47:59 AM)

EXAMPLE:

quote:

target = {name = 'TEST', latitude = *SOME LAT*, longitude = *SOME LON*, type = 'Ship', dbid = *Some Random DBID*, side = 'RED'}
ScenEdit_AddUnit(target)
print(target)
--OUTPUT: { speed = 0, side = 'RED', throttle = FullStop, desiredheading = 0, heading = 0, guid = '0IYVAT-0HM1EJSER3RM4', dbid = 1024, name = 'TEST', unitname = 'TEST', type = 'Ship', longitude = 122, latitude = 26 }
--Note that it autonomously filled in a guid to the input unit selector, and I cannot use this input to generate units again because of the conflicting GUID.







Rory Noonan -> RE: AddUnit function changes input causing problem (7/23/2020 1:30:55 AM)

Thanks, I see your issue now.

A simple solution is:

quote:

local target = {name = 'TEST', latitude = *SOME LAT*, longitude = *SOME LON*, type = 'Ship', dbid = *Some Random DBID*, side = 'RED'}

local thisUnit = ScenEdit_AddUnit(name=target.name, type=target.type, dbid=target.dbid, side=target.side, latitude=target.latitude, longitude=target.longitude)
print(thisUnit)

We'll see if there's any improvements that can be made.

0014038




KnightHawk75 -> RE: AddUnit function changes input causing problem (7/23/2020 4:06:03 AM)

Yup, that or just target.guid = nil before the next addunit call should work around it.




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
2.390625