Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

Unit Scripting and Execution Woes...

 
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 >> Mods and Scenarios >> Lua Legion >> Unit Scripting and Execution Woes... Page: [1]
Login
Message << Older Topic   Newer Topic >>
Unit Scripting and Execution Woes... - 3/5/2021 2:46:22 AM   
jkgarner

 

Posts: 169
Joined: 4/30/2020
Status: offline
OK. I have created a mechanism to script units through Lua, taking minimal input. Basically, you identify the unit, and give it a series of commands. The command are simple, and have minimal data, like a destination of a move. So for movement, I could simply set the course, but we actually want different unit postures (doctrines) and so forth during the various steps of the script. I won't go into details.

The scripting mechanism basically functions, I can create a script for a unit, load it and then watch the unit process through the steps sequentially as directed. This involves generating, executing and deleting events for the unit as it processes.

Not too difficult.

Now here is the interesting thing: I have scripts for 7 units, for friendlies and 3 enemies. Each individual script executes correctly when loaded by itself, but if I load several scripts, ONLY the first loaded executes. It does not matter what order I choose to load them, the first, and ONLY the first, whichever of the 7 units I picked, will actually execute its script. The thing is, all the kick-off events for all units are generated. They don't execute. I can manually execute the code that should be triggered by the seven events, and all units will start moving. But let it run by itself, and rely in the events executing, and ONLY the first executes. The others sit idly waiting, with active turned on.

All events have unique names.
All events have their own triggers (uniquely named)
All events have their own actions (uniquely named)

Here is a call to the Script function:
Script({
	[1] = Ground.Order({day=1, step=1, orderType='ATTACK', side = 'USA', 
	      name = '73rd Batallion 2nd Company 1st Platoon (M2A3 Bradley AFV x 4)', 
		  to_rel="yes", to_lat=0.35,  to_lon=0, }) ,
	[2] = Ground.Order({day=1, step=2, orderType='MOVE', side = 'USA', 
	      name = '73rd Batallion 2nd Company 1st Platoon (M2A3 Bradley AFV x 4)', 
		  to_rel="yes", to_lat=0.70,  to_lon=-0.35, }) ,
	})

The Ground.Order function actually generates and returns an object that packages the information for that step of the script. The order type is used to ensure that the appropriate functionality is generated (Lua Script) for the events to execute. These objects are placed in the array, and execute in the order in the array.

The script function creates a startStep event, along with triggers and conditions from the data in element 1, and pushes the other elements into the Key Value store, for later retrieval. The startStep event will gerneates the subsequent events for the specific order. When the last event for the step executes an advance script function, it calls the advanceScript function that determine if there are more steps and generates the next start Step function call, as needed. The system works flawlessly with a single unit, and each of my test units all function correctly.

If I test with loading scripts for multiple units, while events, trigger,s and actions are generated for all the units, only the first is executed.

I'm trying to brainstorm what could cause this behavior.
Right now, I am clueless.
Post #: 1
RE: Unit Scripting and Execution Woes... - 3/5/2021 10:47:14 AM   
jkgarner

 

Posts: 169
Joined: 4/30/2020
Status: offline
OK. On a hunch I decided to insert some delays into the script. My original inputs scheduled all the units to start moving at the same time, and only the first unit would move. In fact, it did not matter what order I input the scripts, the first input would move, and the others would not, as though the orders were ignored. I got to thinking that the code was generating the events. After all I could see them, and check that everything was in place: triggers, all with the correct time, actions, all with the correct code, events all tied together. So, I concluded, it was not some error in my coding with the Lua terminating early. This had to do with how the events were executed after they were in place (and queued up) SO then I asked myself the question, how does the system handle concurrent events? Perhaps if I put delays ion the orders to separate the execution times?

Bottom line: with each unit being scheduled to start at a different time, everything worked perfectly.

This begs the question: what happens in the Command system when two events are scheduled at the same time? Is this an artifact of the user event mechanism? Or is it a deeper issue with internal simulation events?

As far as the internal simulation events, if the program is single threaded, one will have to wait to execute. If it is multi-threaded (I suspect this is NOT the case) then they could conceivably execute simultaneously, but this introduces threading issues with protecting data, signalling between threads, protecting data from concurrent usage, and race conditions... (understand this is VERY complex coding)

What happens to timed single event triggers when the time has lapsed without being executed? Are they summarily dropped/ignored? This seems to be the case in my limited testing.

What about system generated events that occur at the same time? Do they queue up and all execute, or are they also dropped?



(in reply to jkgarner)
Post #: 2
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> Unit Scripting and Execution Woes... 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.313