Page 1 of 1

Display Unit as build command

Posted: 17 Aug 2011, 21:04
by Tanatos
Two units to be displayed as when you choose "build".
Example of the picture.
needed:
- Simultaneously display two units
- Display the grid
- Align to grid
- Display the availability of construction for each cell

Looking for code samples, commands, lua, widgets or other assistance ...Please help.

P.S.
Sorry for my english.

Re: Display Unit as build command

Posted: 17 Aug 2011, 21:16
by knorke
Welcome :)
something like this thread?
http://springrts.com/phpbb/viewtopic.ph ... lit=abload

Re: Display Unit as build command

Posted: 17 Aug 2011, 22:00
by Tanatos
Thank you for your help!
Unfortunately I have not found answers to their questions. In the subject being discussed tech tree, but I'm only interested in place to build. I need to display identical image, but so that I could manage it himself. Maybe I did not understand your example? If so tell me where to find the flow.

how to check whether it is possible to construct an arbitrary unit (UnitID) at an arbitrary position (x, y, z) (with details like the image)?

Re: Display Unit as build command

Posted: 17 Aug 2011, 22:46
by Tanatos
Partly found the answer!

Code: Select all

-- get the coordinates of gridded
local bx, by, bz = Spring.Pos2BuildPos (UnitDefID, x, y, z)

-- check the availability of construction
local CheckResult = Spring.TestBuildOrder (UnitDefID, bx, by, bz, h)
I am looking for how to display the grid and get more detailed information about the availability of construction

Re: Display Unit as build command

Posted: 17 Aug 2011, 23:04
by knorke
get more detailed information about the availability of construction
what excactly?

The red/yellow/green/ is drawn by the engine.
drawing something yourself: http://answers.springlobby.info/questio ... game-world

Re: Display Unit as build command

Posted: 17 Aug 2011, 23:23
by Tanatos
I have no problem with how to draw.
Problems with the lack of data! How to get the details about what a square is not available for place building?

Re: Display Unit as build command

Posted: 17 Aug 2011, 23:27
by Tanatos
this function "ClosestBuildSite" not accesible from Lua Widget?
Where can I find a complete list of features available in LUA?
Here "http://springrts.com/wiki/Lua_Scripting" does not list all the functions :( ... For example there is no "Pos2BuildPos"

Re: Display Unit as build command

Posted: 17 Aug 2011, 23:33
by knorke
ah i understand.
You want something like "can not build here because at 500:450 the terrain slope is too steep and there is a tree at 510:455"
There are 4 things that can block building:
1) features (rocks, trees) -> you can test for those yourself
2) other units -> you can test for those yourself, too
3) water is too deep or too shallow -> possible to read terrain height
4) terrain is too steep -> possible to read terrain slope, too
5) is there a geovent? (for geo powerplant) -> can that for that too
(maybe forgott something)

So you could test everything yourself using GetFeatures and GetUnits functions. If there is something easier, I dont know.

Re: Display Unit as build command

Posted: 17 Aug 2011, 23:39
by jK
Tanatos wrote:Here "http://springrts.com/wiki/Lua_Scripting" does not list all the functions :( ... For example there is no "Pos2BuildPos"
use `text search`/`find` functionality of your browser

Re: Display Unit as build command

Posted: 18 Aug 2011, 00:09
by FLOZi

Re: Display Unit as build command

Posted: 18 Aug 2011, 00:25
by Tanatos
already use and Spring.TestBuildOrder Spring.Pos2BuildPos, see post number 4.
Thanks anyway!

Re: Display Unit as build command

Posted: 18 Aug 2011, 01:00
by Tanatos
knorke, thank you very much for your patience and responsiveness!
knorke wrote: 1) not interested
2) not interested
3) not interested
4) terrain is too steep -> possible to read terrain slope, too
How?
5) not interested
I decided to do without until the detail - it is difficult and the result is not worth it. If I find an affordable solution append script.
Otherwise, the result is achieved.

Added
In the picture example of mode "ShowPathMap" (F2) and the team "build."
You can get similar data from Lua Widget?

Re: Display Unit as build command

Posted: 18 Aug 2011, 11:41
by knorke
Tanatos wrote:4) terrain is too steep -> possible to read terrain slope, too
How?
Spring.GetGroundNormal ( number x, number z ) -> number x, number y, number z
A groundnormal is a vector that sits orthogonal on the terrain.
Image
(imagine the S shaped curve is terrain)
On flat ground it will point straight to the sky (0, 1, 0)
You have to compare it to the maxSlope of the unitDef you are trying to build. (needs some math to convert etc)

Yes, combining all this it would be possible to get something similiar like the F2 map.
Just wondering what you need it for?
Are you making a game or a widget or something else?

Re: Display Unit as build command

Posted: 18 Aug 2011, 12:46
by TheFatController
If you're aiming to add build options without having a build menu you could maybe do something clever with hidden build options and setactivecommand?

Re: Display Unit as build command

Posted: 18 Aug 2011, 13:17
by Tanatos
Thank you very much for your answers!
Special thanks for "maxSlope of the unitDef", sure it is key information for solving the problem.

I do not have a specific goal. Programming, a hobby of mine. Now I'm curious to deal with Lua scripts in the Spring. Learn what is already written. In the course of the study come to mind that can be done. I try to do it. Put questions and seeking answers. Something like this:)

P.S.
Sorry for my English.