Find a path length by Lua

Find a path length by Lua

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Find a path length by Lua

Post by Anarchid »

I've been thinking of ways to make a certain Lua ai smarter - like not send ground units to conquer sectors that are either inaccessible to them, or obstructed by difficult terrain.

The obvious way to do that would be to make it check the path length to a candidate sector for the ground units, but the only way to do this that i found, seems to fetch the Path UserData Object, get a whole list of waypoints, and then manually calculate distances.

Is there perhaps anything easier?
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Find a path length by Lua

Post by lurker »

Easier... Can't you fit the math to calculate length from the path it returns into a piece of code that's shorter than my post?
User avatar
Tribulexrenamed
Posts: 775
Joined: 22 Apr 2008, 19:06

Re: Find a path length by Lua

Post by Tribulexrenamed »

Pythagoras has been around for a while, no?
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: Find a path length by Lua

Post by Anarchid »

Easier... Can't you fit the math to calculate length from the path it returns into a piece of code that's shorter than my post?
Äh, i probably should have written "faster". Anyway, if the obvious way is the only one, then the only way is the obvious one.
Post Reply

Return to “Lua Scripts”