Turn unit command for lua

Turn unit command for lua

Requests for features in the spring code.

Moderator: Moderators

Post Reply
Kinyif_fantom
Posts: 7
Joined: 28 Feb 2009, 01:49

Turn unit command for lua

Post by Kinyif_fantom »

When I played Spring1944, I found it ridiculous that I have to move the towed guns and catch the right moment to set their direction. I tried to write a widget that makes it easier, but didn't find any way to turn the unit.
Sorry, if I am wrong about that, I asked also on #lua in the lobby, and got the answer that I cannot turn my units in unsynced code.

And this is my first post.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Turn unit command for lua

Post by Argh »

They're right, it's difficult, if not impossible, to do it with a Widget. You'd need to write a Gadget for this (and submit it to the S'44 guys, or make a mutator), Widgets aren't allowed to do things like that. See http://spring.clan-sy.com/wiki/Lua_MoveCtrl for details about how to go about that.
Kinyif_fantom
Posts: 7
Joined: 28 Feb 2009, 01:49

Re: Turn unit command for lua

Post by Kinyif_fantom »

Thank you Argh. It would have been my second widget, and gadgets and mutators are too scary for me yet.

Why I think a turn command would be appropriate:
We can give any order to our units in widgets: attack, move etc. and I thought that turning our units suits well into this list.(CMD.TURN) And something that makes it easier to set the direction of towed guns belongs to UI, what should be made by widgets. I understand if there are more important things, just wanted to point this out and show, that it may be useful, and seems more logical to give turn as an order to units. As it can be done in present lua, a turn order is even less important.
User avatar
Nemo
Spring 1944 Developer
Posts: 1376
Joined: 30 Jan 2005, 19:44

Re: Turn unit command for lua

Post by Nemo »

While there's no way to take control of the physics of the unit and make it move in unsynced code, I'm sure a widget could give the gun/whatever such an order that it ends up facing that direction.

Basically something that took an order and compared it to the current unit heading, issued a move order right next to the unit until the new heading was the center of the firearc, and then gave it a stop command - that should be widget-able.

For what its worth, if you write a reliable widget for easily giving turn commands, I will totally stick it in the next S44 release.
User avatar
Evil4Zerggin
Posts: 557
Joined: 16 May 2007, 06:34

Re: Turn unit command for lua

Post by Evil4Zerggin »

Welcome to the forums!

If nobody gets to it by then, I'll try my hand at writing a widget to do this (then move on to more drastic means if this proves infeasible). Unfortunately several real life issues are conspiring to keep me from this--expect nothing before March 20th at the very earliest.
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: Turn unit command for lua

Post by aegis »

if we can get turn rate and current direction
give it a move command toward direction
then stop the command with some math like waiting this long:
frames_to_wait = abs(current_direction - final_direction) / turn_rate
or something like that.
User avatar
yuritch
Spring 1944 Developer
Posts: 1018
Joined: 11 Oct 2005, 07:18

Re: Turn unit command for lua

Post by yuritch »

I think a lua->cob call and then some set HEADING; in the unit script might work better (of course unit scripts will have to be adjusted to support this). Spring pathfinder is known for producing strange paths sometimes, I'm not sure giving a very close move order will always result in the unit just turning there and not wandering in some random direction.
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: Turn unit command for lua

Post by aegis »

well, the unit turns before it moves if the path is in the direction of the point?
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: Turn unit command for lua

Post by Tobi »

I might investigate this when I get to the point of trying to make C.R.A.I.G. deploy artillery.
Post Reply

Return to “Feature Requests”