COOKIES!!!!

COOKIES!!!!

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

Moderator: Moderators

Post Reply
User avatar
kiki
Posts: 859
Joined: 05 Nov 2007, 03:06

COOKIES!!!!

Post by kiki »

Whoever can figure out how to correctly find the range of a nanotower with lua gets a cookie. I am using BA to test, and UnitDefs[unitID].buildDistance and UnitDefs[unitID].buildDistance + Spring.GetUnitDefDimensions(unitID).radius both do not give full range, but only about half. Also, if you succeed you will get my pretty lua widget.
User avatar
TheFatController
Balanced Annihilation Developer
Posts: 1177
Joined: 10 Dec 2006, 18:46

Re: COOKIES!!!!

Post by TheFatController »

buildDistance is correct I'm not sure what you're doing, try this function to test:

Code: Select all

function widget:UnitFinished(unitID, unitDefID, unitTeam)

  local x,_,z = Spring.GetUnitPosition(unitID)
      
  for angle=0,360,40 do
    local xp = (x + (math.sin(math.rad(angle)) * UnitDefs[unitDefID].buildDistance))
    local zp = (z + (math.cos(math.rad(angle)) * UnitDefs[unitDefID].buildDistance))
    Spring.MarkerAddPoint(xp,0,zp)
  end

end
Edit: OH you're using UnitDefs[unitID] instead of UnitDefs[unitDefID] that would be why - it's reading another unit :p i'll leave my code in for its leet point spamming and geometry skills
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: COOKIES!!!!

Post by CarRepairer »

TheFatController does not need anymore cookies. I'll take them instead.
User avatar
kiki
Posts: 859
Joined: 05 Nov 2007, 03:06

Re: COOKIES!!!!

Post by kiki »

Oh! no wonder! I was thinking that that may be a possibility as i was in the car. Cookies for you!!! That also explains why with a different build order the value was different.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: COOKIES!!!!

Post by AF »

The cookie king throwns upon sales of counterfeit cookies
User avatar
kiki
Posts: 859
Joined: 05 Nov 2007, 03:06

Re: COOKIES!!!!

Post by kiki »

sale? Counterfeit? AF?
Post Reply

Return to “Lua Scripts”