View topic - Display Unit as build command


All times are UTC + 1 hour


Post new topic Reply to topic  [ 15 posts ] 
Author Message
PostPosted: 17 Aug 2011, 20:04 

Joined: 17 Aug 2011, 19:51
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.


Attachments:
File comment: Sample
Build.png
Build.png [ 656.84 KiB | Viewed 636 times ]
Top
 Offline Profile  
 
PostPosted: 17 Aug 2011, 20:16 
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
Welcome :)
something like this thread?
viewtopic.php?f=23&t=26353&hilit=abload
Top
 Offline Profile  
 
PostPosted: 17 Aug 2011, 21:00 

Joined: 17 Aug 2011, 19:51
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)?
Top
 Offline Profile  
 
PostPosted: 17 Aug 2011, 21:46 

Joined: 17 Aug 2011, 19:51
Partly found the answer!

Code:
-- 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
Top
 Offline Profile  
 
PostPosted: 17 Aug 2011, 22:04 
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
Quote:
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
Top
 Offline Profile  
 
PostPosted: 17 Aug 2011, 22:23 

Joined: 17 Aug 2011, 19:51
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?


Attachments:
File comment: Grid Detail Info
Build.png
Build.png [ 598.08 KiB | Viewed 605 times ]
Top
 Offline Profile  
 
PostPosted: 17 Aug 2011, 22:27 

Joined: 17 Aug 2011, 19:51
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"
Top
 Offline Profile  
 
PostPosted: 17 Aug 2011, 22:33 
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
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.
Top
 Offline Profile  
 
PostPosted: 17 Aug 2011, 22:39 
Spring Developer
User avatar

Joined: 28 Jun 2007, 06:30
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
Top
 Offline Profile  
 
PostPosted: 17 Aug 2011, 23:09 
MC: Legacy & Spring 1944 Developer
User avatar

Joined: 29 Apr 2005, 00:14
Location: #moddev - join it!
Try http://springrts.com/wiki/Lua_SyncedRead#Test_Building :-)
Top
 Offline Profile  
 
PostPosted: 17 Aug 2011, 23:25 

Joined: 17 Aug 2011, 19:51
already use and Spring.TestBuildOrder Spring.Pos2BuildPos, see post number 4.
Thanks anyway!
Top
 Offline Profile  
 
PostPosted: 18 Aug 2011, 00:00 

Joined: 17 Aug 2011, 19:51
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?


Attachments:
F2(2).png
F2(2).png [ 330.24 KiB | Viewed 570 times ]
File comment: F2 + Build Comand
F2.png [508.1 KiB]
Downloaded 2 times
Top
 Offline Profile  
 
PostPosted: 18 Aug 2011, 10:41 
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
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?
Top
 Offline Profile  
 
PostPosted: 18 Aug 2011, 11:46 
Balanced Annihilation Maintainer
User avatar

Joined: 10 Dec 2006, 18:46
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?
Top
 Offline Profile  
 
PostPosted: 18 Aug 2011, 12:17 

Joined: 17 Aug 2011, 19:51
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.
Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Site layout created by Roflcopter et al.