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] Cannot change posture toward reported contacts in Lua

 
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] Cannot change posture toward reported contacts in Lua Page: [1]
Login
Message << Older Topic   Newer Topic >>
[Logged] Cannot change posture toward reported contacts... - 3/23/2021 4:13:16 AM   
musurca

 

Posts: 128
Joined: 7/16/2020
Status: offline
Contacts that have been reported by another friendly side as Unknown cannot be changed to another posture from Lua. If you attempt to do so, the actual value of the posture field will change, but the contact will remain as a yellow "Unknown" on the map. Note that the user can still change the posture from the GUI, and the color will change as expected.

To reproduce:

1) Load the attached .save file and join the "PBEM" side. This is a side with one facility* on the Solomons, but no units with sensors. All contacts are reported from the friendly USN fleet.

Note that there are three Unknown contacts to start: SKUNK #1, SKUNK #2, and SKUNK #3.

2) Open the Lua Script Console, and run the following code:

local contacts = ScenEdit_GetContacts("PBEM")
for k, contact in ipairs(contacts) do
print(contact.name.." - current posture: "..contact.posture)
contact.posture = "H"
print(contact.name.." - new posture: "..contact.posture)
end


Note that this does indeed change the posture field of the contacts from "X" to "H" (or from Unknown to Hostile), but they remain yellow on the map.

This is build 1147.18 as usual. Thanks!

*NB: this is because I've also noticed that your side will not see any reported contacts unless it has at least one unit in the simulation.

Attachment (1)

< Message edited by Rory Noonan -- 4/8/2021 7:24:04 PM >
Post #: 1
RE: Cannot change posture toward reported contacts in Lua - 3/23/2021 3:20:48 PM   
PaulTheWolf

 

Posts: 40
Joined: 12/10/2017
Status: offline
Hi musurca. So I tested this with the corresponding save, and I found something interesting. You're executing the script under the PBEM side, but the contacts are rendered hostile for the USN side. (They turn red and everything when you switch sides to USN.) I can spot you're working on your PBEM project here, and I'm not 100% clear on if this is working as intended or not. Will the Player be on the PBEM side or the USN Side within your use context?

Paul.

(in reply to musurca)
Post #: 2
RE: Cannot change posture toward reported contacts in Lua - 3/23/2021 5:53:31 PM   
musurca

 

Posts: 128
Joined: 7/16/2020
Status: offline
Hi Paul-- ah, I didn't see that! That IS interesting, and, I think, demonstrates that there are actually two problems here. Those contacts on the "PBEM" side should belong to "PBEM", even though they are detected and reported by "USN." Note that if you get the underlying enemy unit and print its .ascontact field, you'll notice that it exists as TWO contacts: one on the "USN" side (the detected contact) and one on the "PBEM" side (the reported contact). So changing their posture on the "PBEM" side shouldn't affect the posture on the "USN" side, because they're two separate contact objects.

To summarize the issues I'm reporting:

1) (the original issue) In Lua, changing posture toward contacts that have been reported from a friendly side is NOT reflected in the CMO UI -- the contact remains the same color on the map as it was when first reported. Note that you can still change the contact color by changing posture manually from the right-click menu UI, but if you do the same thing with Lua, it has no effect, although it should be equivalent.

2) (the issue you found) In Lua, changing side A's posture toward contacts that have been reported to side A by a friendly side B changes B's posture toward that contact, but not A's. I would argue that it should be the other way around. Note that this ONLY happens in Lua. If you change the posture manually from the right-click menu UI, you will only change A's posture, and B's posture will be unaffected, which is the way it 'should' work.

(To answer your other question, this WAS related to some PBEM work, but I've stripped out all of that to demo this issue. In my use case, being placed on the PBEM side is how a player controlling the USN side is prevented from giving new orders during a limited order phase, but can still see what's happening -- but this contact issue would apply to any situation in which one side is receiving reported contacts from another friendly side.)

< Message edited by musurca -- 3/23/2021 6:46:33 PM >

(in reply to PaulTheWolf)
Post #: 3
RE: Cannot change posture toward reported contacts in Lua - 3/30/2021 4:17:43 PM   
PaulTheWolf

 

Posts: 40
Joined: 12/10/2017
Status: offline
Hi Musurca.

I had the team take a look at this after I'd done some reproduction testing. It looks like the way LUA interacts currently with command in the case of this scripting is approach is that the Posture 'setter' retrieves the Director/Detector's side. My team member recommended either using ScenEdit_SetSidePosture instead of GetContacts, but I'm reasonably certain that would complicate your approach with with regards to PBEM.

The other approach that was suggested to me is trying to use LUA to manually assign a director through the code, but that also might complicate the use case for PBEM as well, since you won't always be able to manually determine a director.

I'm going to tinker with the scripting some and see if I can't puzzle something out.

Paul.

(in reply to musurca)
Post #: 4
RE: Cannot change posture toward reported contacts in Lua - 3/30/2021 6:17:47 PM   
musurca

 

Posts: 128
Joined: 7/16/2020
Status: offline
Hi Paul! Thanks for following up. I certainly don’t want to add to the team's workload, but I would argue that

quote:

the way LUA interacts currently with command in the case of this scripting is approach is that the Posture 'setter' retrieves the Director/Detector's side


is actually a bug for the following reasons (regardless of interaction with PBEM stuff):

1) Let’s say a scenario author writes a script in which the posture toward certain types of contacts is changed to Hostile:

local contacts = ScenEdit_GetContacts(“USA”)
for k, contact in ipairs(contacts) do
if contact.typedescription == “Aircraft” then
contact.posture = “H”
end
end


Under the current system, if any of those contacts have been reported to me by another side, then I’ve just accidentally issued an attack order to that side as well(!) even though I don’t control it. This could introduce strange and hard-to-find bugs in scenarios, and is certainly not what you would expect by setting one side’s posture toward a contact.

2) The Command user is already able to change his side’s posture toward a reported contact without also changing the detecting side’s posture via the right-click UI--so it IS possible to set posture without affecting the detecting side, but not through Lua. In other words, the Lua currently does not reflect how the game UI works.

My recommendation to fix this (and this is naive, since I know nothing about the architecture underlying the Lua wrappers) would be to avoid transmitting any information about posture via reported contacts in any direction. The detecting side (side A) should just report what is currently known about the contact (type, position, and side), and leave the posture to the side receiving the report (side B). This is because side A and side B, while friendly with each other, may have entirely different postures toward the side of the contact. (Imagine a Syrian war scenario here.)

If for whatever reason you guys disagree, then yes, would definitely appreciate your help in finding a workaround, although in that case I should be more specific about what I'm trying to do, which is very simply to change the color of a reported contact as seen by the side receiving the report without changing any other side's posture toward that contact. As mentioned above, this is possible through the UI, but not currently possible in Lua.

< Message edited by musurca -- 3/30/2021 6:18:21 PM >

(in reply to PaulTheWolf)
Post #: 5
RE: Cannot change posture toward reported contacts in Lua - 3/30/2021 8:08:51 PM   
PaulTheWolf

 

Posts: 40
Joined: 12/10/2017
Status: offline
Hi musurca.

I had a member of the team looked at the code directly and it was determined the functionality is working as intended. I will present this hypothetical you've presented here regarding issuing orders to non-player sides to the team, but I think it would be more of an addition or modification than a fix. This is due to how GetContacts calls contacts, which stem from the Original Detector and their corresponding Side.

It is worth noting LUA does allow players to issue commands to non-player sides, it's one of the functionalities strengths, and that we have to keep that in mind when approaching this.

I'll double check with additional members of the team but what it seems like you're looking for here is now more of a feature request and not a bug. At a glance your recommendation would likely require some changes in how the GetContact command is currently handled.

I'll consult with the wider team regarding the feasibility of these changes within LUA.

Paul.

(in reply to musurca)
Post #: 6
RE: Cannot change posture toward reported contacts in Lua - 3/31/2021 2:33:43 AM   
michaelm75au


Posts: 13500
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
To butt in, Lua only changes the setting on the contact. It does not send the update to other side contacts; that would be the normal Command code.
But you are right something is not quite right with how the posture is being set. But this hasn't been changed since 2016 so may need some more checking.

< Message edited by michaelm75au -- 3/31/2021 5:38:29 AM >


_____________________________

Michael

(in reply to PaulTheWolf)
Post #: 7
RE: Cannot change posture toward reported contacts in Lua - 4/1/2021 12:02:58 AM   
PaulTheWolf

 

Posts: 40
Joined: 12/10/2017
Status: offline
Hi musurca

The team investigated this and determined that the GetContacts LUA Script was written in a period that predated certain PerspectiveSide configurations, and needs an update to represent that more recent Code. The team is working to get that setup instituted in an upcoming update! Thanks for bringing this to our attention, it's the first time somebody has isolated an issue pertaining to this particular neck of the LUA woods in years!

Paul.

(in reply to michaelm75au)
Post #: 8
RE: Cannot change posture toward reported contacts in Lua - 4/1/2021 4:18:10 AM   
musurca

 

Posts: 128
Joined: 7/16/2020
Status: offline
Thanks, Paul! That completely makes sense, and sorry again to make trouble poking around the backwoods. Appreciate your time and attention to the issue. (And thank you as well, Michael.)

(in reply to PaulTheWolf)
Post #: 9
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Tech Support >> [Logged] Cannot change posture toward reported contacts in Lua 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.828