Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

[Logged] AddUnit function changes input causing problem

 
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 >> Tech Support >> [Logged] AddUnit function changes input causing problem Page: [1]
Login
Message << Older Topic   Newer Topic >>
[Logged] AddUnit function changes input causing problem - 7/22/2020 6:29:53 AM   
DracheTek

 

Posts: 45
Joined: 7/5/2020
Status: offline
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.

< Message edited by apache85 -- 7/23/2020 1:22:51 AM >
Post #: 1
RE: AddUnit function changes input causing problem - 7/22/2020 6:47:16 AM   
Rory Noonan

 

Posts: 2784
Joined: 12/18/2014
From: Brooklyn, NY
Status: offline
Can you post some example code and a scenario for us to look at? It's not immediately clear what the issue is

_____________________________


(in reply to DracheTek)
Post #: 2
RE: AddUnit function changes input causing problem - 7/23/2020 12:47:59 AM   
DracheTek

 

Posts: 45
Joined: 7/5/2020
Status: offline
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.




(in reply to Rory Noonan)
Post #: 3
RE: AddUnit function changes input causing problem - 7/23/2020 1:30:55 AM   
Rory Noonan

 

Posts: 2784
Joined: 12/18/2014
From: Brooklyn, NY
Status: offline
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

< Message edited by apache85 -- 7/27/2020 3:57:50 AM >


_____________________________


(in reply to DracheTek)
Post #: 4
RE: AddUnit function changes input causing problem - 7/23/2020 4:06:03 AM   
KnightHawk75

 

Posts: 1050
Joined: 11/15/2018
Status: offline
Yup, that or just target.guid = nil before the next addunit call should work around it.

(in reply to Rory Noonan)
Post #: 5
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Tech Support >> [Logged] AddUnit function changes input causing problem 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.227