Author Topic: [fixed] lua - createUnit - x,y  (Read 1248 times)

uuu

  • Guest
[fixed] lua - createUnit - x,y
« on: 19 February 2012, 17:36:59 »
Hi.

I was trying to create a scenario, but it wasn't possible to create units close to each other (which is necessary for my scenario).

Example lua code on empty map:
createUnit('spearman', 0, { 5, 5 })
createUnit('spearman', 0, { 5, 6 })

It creates units, but second unit is not below the first one, but on other position. I need to position them just next to each other, in a row (I am actually creating guard towers).

Thnx
« Last Edit: 23 February 2012, 17:53:24 by tomreyn »

MuwuM

  • Ornithopter
  • *****
  • Posts: 426
  • No Game without Move(ment)
    • View Profile
    • MuwuM - Lexicons
Re: lua - createUnit - x,y
« Reply #1 on: 19 February 2012, 21:11:01 »
try ( unit-size + 1 ) distance then it should work ... there will be 1 space between all units and you can't have units build in other units....

uuu

  • Guest
Re: lua - createUnit - x,y
« Reply #2 on: 20 February 2012, 16:22:22 »
Of course I did consider unit size. Spearmen in example is 1x1 unit.
Another example that does not work:
createUnit('spearman', 0, { 5, 5 })
createUnit('spearman', 0, { 5, 7 })
createUnit('spearman', 0, { 5, 9 })

To make it easier to find bug, this code works:
createUnit('spearman', 0, { 5, 5 })
createUnit('spearman', 0, { 5, 10 })
createUnit('spearman', 0, { 5, 15 })

But, of course, creates 4 empty spaces between the 3 spearmen. So it is not helpful.

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: lua - createUnit - x,y
« Reply #3 on: 20 February 2012, 18:48:46 »
I'm pretty sure the forced space is 2 cells. Of course, I would like a way to more accurately place unit, as it's impossible to build walls with our current Lua function.
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,239
    • View Profile
Re: lua - createUnit - x,y
« Reply #4 on: 21 February 2012, 20:48:50 »
I'm adding a new lua method called:

createUnitNoSpacing

Which will take exact same parameters but will NOT use the 2 cell spacing, making this more usable in this scenario.

treba

  • Guest
Re: lua - createUnit - x,y
« Reply #5 on: 21 February 2012, 23:08:02 »
what is the reason for the spacing anyways?

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: lua - createUnit - x,y
« Reply #6 on: 22 February 2012, 06:43:25 »
what is the reason for the spacing anyways?
So that when you create a base by placing all the buildings at the player's start location, they aren't too close together. Mostly just to save time in trying to create exact placements for every unit, which would be an utter disaster since the map editor doesn't show the coordinates of the cell you hover over (hint hint).
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

uuu

  • Guest
Re: lua - createUnit - x,y
« Reply #7 on: 22 February 2012, 12:28:46 »
I just checked the SVN if I can pin-point or even write the proper code and suggest it - but it looks like they just added the function: "createUnitNoSpacing" in revision 3098 http://megaglest.svn.sourceforge.net/viewvc/megaglest/trunk/source/glest_game/game/script_manager.h?revision=3098&view=markup

So... thnx, I will test it when new release comes out, or I have mood for compiling all day, or somebody posts win binaries.

FIXED

 

anything