Page 1 of 1

Lua doesn't set speed

Posted: Wed Apr 03, 2019 3:01 pm
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)

RE: Lua doesn't set speed

Posted: Thu Apr 04, 2019 6:28 am
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?

RE: Lua doesn't set speed

Posted: Thu Apr 04, 2019 7:51 am
by michaelm75au
Aircraft appear to be working, but ships & subs not so much.
---

Defect logged

RE: Lua doesn't set speed

Posted: Thu Apr 04, 2019 11:10 am
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]

RE: Lua doesn't set speed

Posted: Thu Apr 04, 2019 12:18 pm
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

RE: Lua doesn't set speed

Posted: Thu Apr 04, 2019 9:25 pm
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.

RE: Lua doesn't set speed

Posted: Fri Apr 05, 2019 12:09 am
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.

RE: Lua doesn't set speed

Posted: Sun Apr 21, 2019 10:29 am
by Dimitris
Is this still a problem in B1009.27.8/.9 ?