Lua doesn't set speed

Post bug reports and ask for game support here.

Moderator: MOD_Command

Post Reply
User avatar
lumiere
Posts: 286
Joined: Tue Mar 19, 2019 10:38 am

Lua doesn't set speed

Post by lumiere »

(1009.27.6) Seems that "ScenEdit_SetUnit(table)" Lua function couldn't set speed correctly.

In the attached savefile, open Lua Console and run the following script individually (sorry if there's typo or any error)
Throttle setting window (F2) is useful for check.

[font="Courier New"]ScenEdit_SetUnit({guid='9ae1b22f-8178-4ec8-a178-b1e54b5bac7c', speed=15})

ScenEdit_SetUnit({guid='9ae1b22f-8178-4ec8-a178-b1e54b5bac7c', throttle=2})

ScenEdit_SetUnit({guid='9ae1b22f-8178-4ec8-a178-b1e54b5bac7c', manualSpeed=2})[/font]

If they works, submarine (Phoenix) alters its current or desied speed to 15kts.
Instead however, if you set current speed by knots, submarine always set its speed to 0kts.
For throttle, submarine certainly changes throttle once, but immidiately returns the original throttle.

Also, Can I set desired speed by kts, rather than throttle using Lua? (Looks like "manualSpeed" is by throttle)
Yeah it is meaningless setting fighter speed to 515kt or 535kt, but recently I noticed that reduing sub's speed to 1 knot does works
for reducing passive sonar detection range.


P.S. Do not approach Romeo. It's a trap. (patrol mission always get fooled)
Attachments
ASWTest.zip
(13.04 KiB) Downloaded 16 times
"How Do You Stay Calm With A 7,000 Ton Nuclear Predator Listening For Your Heartbeat?"
My Lua garbages (Github)
User avatar
michaelm75au
Posts: 12467
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Lua doesn't set speed

Post by michaelm75au »

I'll have a look. It should work by number or throttle. It did in the past.

Is it only on subs? Does it work for ships and aircraft?
Michael
User avatar
michaelm75au
Posts: 12467
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Lua doesn't set speed

Post by michaelm75au »

Aircraft appear to be working, but ships & subs not so much.
---

Defect logged
Michael
User avatar
lumiere
Posts: 286
Joined: Tue Mar 19, 2019 10:38 am

RE: Lua doesn't set speed

Post by lumiere »

I tried some more, this time ship, helicopter, aircraft too (save attached).
What I found:

"speed" doesn't works at all. Unit's current speed always becomes 0kt.

For ship/helicopter/ aircraft, "throttle" and "manualSpeed" sometimes works,
but sometime doesn't work. I don't know sure when they works.

For submarine, even "throttle" nor "manualSpeed" works at all.

[font="Courier New"]
--submarine (Phoenix)
ScenEdit_SetUnit({guid='9ae1b22f-8178-4ec8-a178-b1e54b5bac7c', speed=15})

ScenEdit_SetUnit({guid='9ae1b22f-8178-4ec8-a178-b1e54b5bac7c', throttle=2})

ScenEdit_SetUnit({guid='9ae1b22f-8178-4ec8-a178-b1e54b5bac7c', manualSpeed=2})


--ship (Knox)
ScenEdit_SetUnit({guid='1d980339-223f-4a9e-a743-cf37a7069cd3', speed=15})

ScenEdit_SetUnit({guid='1d980339-223f-4a9e-a743-cf37a7069cd3', throttle=2})

ScenEdit_SetUnit({guid='1d980339-223f-4a9e-a743-cf37a7069cd3', manualSpeed=2})

--helicopter (SH-2)
ScenEdit_SetUnit({guid='b1b1b8c6-866f-4bfa-a88c-3d8fa9178600', speed=130})

ScenEdit_SetUnit({guid='b1b1b8c6-866f-4bfa-a88c-3d8fa9178600', throttle=2})

ScenEdit_SetUnit({guid='b1b1b8c6-866f-4bfa-a88c-3d8fa9178600', manualSpeed=2})

--aircraft (Nimrod)
ScenEdit_SetUnit({guid='9fae58d6-51bf-4817-abbe-9fd0622672cb', speed=420})

ScenEdit_SetUnit({guid='9fae58d6-51bf-4817-abbe-9fd0622672cb', throttle=2})

ScenEdit_SetUnit({guid='9fae58d6-51bf-4817-abbe-9fd0622672cb', manualSpeed=2}) [/font]
Attachments
ASWTest2.zip
(17.22 KiB) Downloaded 15 times
"How Do You Stay Calm With A 7,000 Ton Nuclear Predator Listening For Your Heartbeat?"
My Lua garbages (Github)
User avatar
stilesw
Posts: 1572
Joined: Wed Jun 25, 2014 10:08 pm
Location: Hansville, WA, USA

RE: Lua doesn't set speed

Post by stilesw »

Just a thought but when I had problems with this it worked after I added the manualSpeed='OFF' code. After that I could get units to change and hold the desired speed.

ScenEdit_SetUnit({side="Iraq", unitname="Assault Group M", manualSpeed='OFF'})

I could then use ScenEdit_SetUnit({side="Iraq", unitname="Assault Group M", manualSpeed=x}) as I wanted.

michaelm75au can probably give more/better information though.

-Wayne Stiles
“There is no limit to what a man can do so long as he does not care a straw who gets the credit for it.”

Charles Edward Montague, English novelist and essayist
~Disenchantment, ch. 15 (1922)
User avatar
michaelm75au
Posts: 12467
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Lua doesn't set speed

Post by michaelm75au »

I think that there is a conflict between the speed, desired speeed, manual speed, throttle. They seem to be fighting with each other as to who is boss.[:D]
I'll delve into this over the weekend.
Michael
User avatar
michaelm75au
Posts: 12467
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Lua doesn't set speed

Post by michaelm75au »

Trying to code for the presets and knots has caused some issues. One of them being if you try to set the speed to '1 knot', it is treating this as a preset throttle of 'Creep'.
I am dropping the preset throttle as part of 'ManualSpeed', and creating a new 'ManualThrottle' if you want to use the throttle presets.
Note about the variable 'speed'. Once you try to change it, it won't necessarily stay that value. The AI will change the speed to match its own settings. If you want to change the speed, you have to use manual override setting; as as for altitude/depth.
Michael
Dimitris
Posts: 15987
Joined: Sun Jul 31, 2005 10:29 am
Contact:

RE: Lua doesn't set speed

Post by Dimitris »

Is this still a problem in B1009.27.8/.9 ?
Post Reply

Return to “Tech Support”