Jump to content

Recommended Posts

Posted

Given the name of a trigger zone how do you get the position?

 

If my variable _aaaZone contains the name of the zone then is it:

 

local _zonepos = {x=_aaaZone.point.x, y=_aaaZone.point.y, z=_aaaZone.point.z}

 

?

 

Passing this and the targets current position to get3DDist fails with the error that I'm trying to an arithmetic operation on a nil value in x.

 

Code snippet below:

 

local _zonepos = {x=_aaaZone.point.x, y=_aaaZone.point.y, z=_aaaZone.point.z}

local _curpos = {x=_targetpos.x, y=_targetpos.y, z=_targetpos.z}

local _range = mist.utils.get3DDist(_curpos, _zonepos)

 

What's my dumb mistake please someone as I can't see it for the life of me. (With a bit of hindsight now I think I probably don't need _curpos and could probably just pass _targetpos which has been populated with inZoneUnits:getPosition().p)

 

Thanks,

Stonehouse

Posted

I might be wrong, but If I remember correctly zones has a Vec2 coordinate system in use.

 

So, maybe, it could be:

 

local _zonepos = {x=_aaaZone.pos.x, y= 0, z=_aaaZone.pos.y}

 

if you need the point on the ground you may use land.getHeight function passing the same x and y variable of the zone.

 

Sorry if I'm wrong, can't check before a couple of days...

Author of DSMC, mod to enable scenario persistency and save updated miz file

Stable version & site: https://dsmcfordcs.wordpress.com/

Github for latest version: https://github.com/Chromium18/DSMC

Posted

Found this by searching in this forum -

 

function SignalTarget()
   Aimpoint = trigger.misc.getZone(target2)
   Aimpointpos = {}
   Aimpointposx = Aimpoint.point.x 
   Aimpointposz = Aimpoint.point.z
   Aimpointposy = land.getHeight({x = Aimpoint.point.x, y = Aimpoint.point.z})
   Aimpt3 = {x=Aimpointposx, y=Aimpointposy, z=Aimpointposz}
   trigger.action.smoke({x=Aimpointposx, y=Aimpointposy, z=Aimpointposz}, trigger.smokeColor.Red, 0)
   return timer.getTime() + 5
end

 

Code by SNAFU.

Posted

Thanks Chromium, but it is vec 2 with land height giving the 3rd dimension and point appears to work ok. Anyway getting past that section of code now with people's help from this thread and getting stuck on some table issues lol.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...