Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

[ADDED] Cannot add ship to ferry mission via Lua, but can through GUI

 
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 >> [ADDED] Cannot add ship to ferry mission via Lua, but can through GUI Page: [1]
Login
Message << Older Topic   Newer Topic >>
[ADDED] Cannot add ship to ferry mission via Lua, but c... - 10/30/2018 4:44:17 PM   
TheOttoman

 

Posts: 139
Joined: 12/14/2017
Status: offline
I have a big Lua script to set up a scenario that among other things, adds ports, creates a ferry mission to that port, creates some units, and then adds those units to the mission. I've included the script for troubleshooting.

The germane portion of my issue is this. I create the mission using this script:
ports = {"Port of Singapore","Port of Batu Ampar","Port of Jakarta"...} <- I've created the facilities earlier in the script

for i, nameofport in ipairs(ports) do
    ScenEdit_AddMission('Commercial','Transit to '..nameofport,'Ferry',{destination=nameofport})
end


and then
-- [[Commercial Container Vessel - Panamax]]
ccvpname = {"[VTM] M/V Vinalines Queen","[VTM] M/V Hai Nam 89","[VTM] M/V Vinalines Sunrise","[VTM] M/V Vinalines Brave","[VTM] M/V Inlaco Express"}

for i, name in ipairs(ccvpname) do
    RandomNumber()  
    RandomPort()
    ScenEdit_AddUnit({type="ship",unitname=name,side="Commercial",dbid="2028",base=PortName})
    RandomNumber()
    ScenEdit_AssignUnitToMission(name,'Transit to '..PortName)
end


RandomNumber is a 1,24 random number generator, and RandomPort assigns the variable PortName to a specific port based on the number randomly generated..


When I run this in Lua, I get the message in the game message window "[VTM] M/V Vinalines Queen is not an aircraft and cannot be added to a Ferry mission" or something similar for each ship it tries to process.


However.... if I go into the Mission Editor (F11), I see all of the missions created as expected, and I see all of the ships as unassigned units, and I can manually assign them to any of the missions.

Am I doing something wrong in the Lua script?

Attachment (1)

< Message edited by Dimitris -- 12/12/2018 6:05:34 AM >
Post #: 1
RE: Cannot add ship to ferry mission via Lua, but can t... - 10/31/2018 8:21:23 AM   
michaelm75au


Posts: 13500
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
I will take a look.

_____________________________

Michael

(in reply to TheOttoman)
Post #: 2
RE: Cannot add ship to ferry mission via Lua, but can t... - 10/31/2018 8:57:34 AM   
michaelm75au


Posts: 13500
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
The base code doesn't allow a non-aircraft unit to be assigned to a mission.
I don't believe it has been updated for ship/submarines as the Editor Mission has empty settings for the ship/submarine also.
---
Okay, ships can be assigned to mission, but the code hasn't been fully updated.

I will look into it.

Thanks for heads up.

< Message edited by michaelm75au -- 10/31/2018 9:33:23 AM >


_____________________________

Michael

(in reply to michaelm75au)
Post #: 3
RE: Cannot add ship to ferry mission via Lua, but can t... - 10/31/2018 12:35:38 PM   
michaelm75au


Posts: 13500
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
for i, name in ipairs(ccvpname) do
    RandomNumber()
    RandomPort()
    ScenEdit_AddUnit({type="ship",unitname=name,side="Commercial",dbid="2028",base=PortName})
    RandomNumber()
    ScenEdit_AssignUnitToMission(name,'Transit to '..PortName)
end


Is this structured correctly? You are adding a ship to 'PortA', and then assigning it to 'transit to portA'.
Isn't this just going to leave the port, and then follow the mission to go back to the port?? It isn't going anywhere.
Shouldn't it be doing
        RandomNumber()
RandomPort()
[with some sort of check that it is not going to the port it is based at]
    ScenEdit_AssignUnitToMission(name,'Transit to '..PortName)



< Message edited by michaelm75au -- 10/31/2018 12:43:31 PM >


_____________________________

Michael

(in reply to michaelm75au)
Post #: 4
RE: Cannot add ship to ferry mission via Lua, but can t... - 10/31/2018 1:21:03 PM   
TheOttoman

 

Posts: 139
Joined: 12/14/2017
Status: offline
In theory, the first random number generator will deliver a number and based off of that number assign it to the corresponding Port. It then runs the random number generator again and uses that result to set the destination for the Ferry mission.

There's currently 24 numbers, so yes, there's a 1:24 chance that the ship will be assigned to the port it's currently in.

(in reply to michaelm75au)
Post #: 5
RE: Cannot add ship to ferry mission via Lua, but can t... - 11/1/2018 8:53:24 AM   
michaelm75au


Posts: 13500
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
I was trying to point out that the variable PortName is set in RandomPort(). You run RandomNumber, but don't set a new PortName.

_____________________________

Michael

(in reply to TheOttoman)
Post #: 6
RE: Cannot add ship to ferry mission via Lua, but can t... - 11/1/2018 6:23:15 PM   
TheOttoman

 

Posts: 139
Joined: 12/14/2017
Status: offline

quote:

ORIGINAL: michaelm75au

I was trying to point out that the variable PortName is set in RandomPort(). You run RandomNumber, but don't set a new PortName.

Gotcha.

I guess I'll have to do RandomPort() again

(in reply to michaelm75au)
Post #: 7
RE: Cannot add ship to ferry mission via Lua, but can t... - 11/9/2018 12:02:44 AM   
TheOttoman

 

Posts: 139
Joined: 12/14/2017
Status: offline
998.13 seems to have mention of a fix for my issue.... at least it says "Part 1"

I've installed the build and the script works as expected.

Thanks!

(in reply to TheOttoman)
Post #: 8
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Tech Support >> [ADDED] Cannot add ship to ferry mission via Lua, but can through GUI 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

3.328