Jump to content

Recommended Posts

Posted

I have a script:

trigger.action.markupToAll(7, 2, 1, trigger.misc.getZone('A1').point,trigger.misc.getZone('A2').point, trigger.misc.getZone('A3').point, trigger.misc.getZone('A4').point, {0, 0, 1, 0}, {1, 0, 0, 0.3}, 4)

That is working... However:

trigger.action.markupToAll(7, 2, 1, trigger.misc.getZone('B1').point,trigger.misc.getZone('B2').point, trigger.misc.getZone('B3').point, trigger.misc.getZone('B4').point, {0, 0, 1, 0}, {1, 0, 0, 0.3}, 4)

Does not work if I put any condition on it. It also doesn't work with more than four zones. Anyone able to tell me what I am doing wrong with it? 

 

Thanks!

Posted

The 3rd input value is the markId. It must be unique and cannot be re-used. Best to make a function that adds 1 to generate the value. 

 

local mId = 0
function markId()
  mId = mId + 1
  return mId
end
trigger.action.markupToAll(7, 2, markId(), trigger.misc.getZone('A1').point,trigger.misc.getZone('A2').point, trigger.misc.getZone('A3').point, trigger.misc.getZone('A4').point, {0, 0, 1, 0}, {1, 0, 0, 0.3}, 4)

trigger.action.markupToAll(7, 2, markId(), trigger.misc.getZone('B1').point,trigger.misc.getZone('B2').point, trigger.misc.getZone('B3').point, trigger.misc.getZone('B4').point, {0, 0, 1, 0}, {1, 0, 0, 0.3}, 4)

 

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

  • 2 weeks later...
Posted

Thanks Grimes! 

On 4/19/2023 at 8:03 PM, Grimes said:

The 3rd input value is the markId. It must be unique and cannot be re-used. Best to make a function that adds 1 to generate the value. 

 

local mId = 0
function markId()
  mId = mId + 1
  return mId
end
trigger.action.markupToAll(7, 2, markId(), trigger.misc.getZone('A1').point,trigger.misc.getZone('A2').point, trigger.misc.getZone('A3').point, trigger.misc.getZone('A4').point, {0, 0, 1, 0}, {1, 0, 0, 0.3}, 4)

trigger.action.markupToAll(7, 2, markId(), trigger.misc.getZone('B1').point,trigger.misc.getZone('B2').point, trigger.misc.getZone('B3').point, trigger.misc.getZone('B4').point, {0, 0, 1, 0}, {1, 0, 0, 0.3}, 4)

 

You are a wealth of information. Thanks for taking time to help me out. 

  • 3 months later...
Posted (edited)

@Grimes

Do you have any tips if you want to draw a polygon with many vertices (e.g., over 150), especially if you do not know how many vertices in advance?

I see MOOSE was attempting to do this but ran into issues with unpack():

local vecs={}
vecs[1]=self:GetVec3()
for i,coord in ipairs(Coordinates) do
  vecs[i+1]=coord:GetVec3()
end

if #vecs<3 then
  self:E("ERROR: A free form polygon needs at least three points!")
elseif #vecs==3 then
  trigger.action.markupToAll(7, Coalition, MarkID, vecs[1], vecs[2], vecs[3], Color, FillColor, LineType, ReadOnly, Text or "")
elseif #vecs==4 then
  trigger.action.markupToAll(7, Coalition, MarkID, vecs[1], vecs[2], vecs[3], vecs[4], Color, FillColor, LineType, ReadOnly, Text or "")
elseif #vecs==5 then
  trigger.action.markupToAll(7, Coalition, MarkID, vecs[1], vecs[2], vecs[3], vecs[4], vecs[5], Color, FillColor, LineType, ReadOnly, Text or "")
elseif #vecs==6 then
  trigger.action.markupToAll(7, Coalition, MarkID, vecs[1], vecs[2], vecs[3], vecs[4], vecs[5], vecs[6], Color, FillColor, LineType, ReadOnly, Text or "")
elseif #vecs==7 then
  trigger.action.markupToAll(7, Coalition, MarkID, vecs[1], vecs[2], vecs[3], vecs[4], vecs[5], vecs[6], vecs[7], Color, FillColor, LineType, ReadOnly, Text or "")
elseif #vecs==8 then
  trigger.action.markupToAll(7, Coalition, MarkID, vecs[1], vecs[2], vecs[3], vecs[4], vecs[5], vecs[6], vecs[7], vecs[8], Color, FillColor, LineType, ReadOnly, Text or "")
elseif #vecs==9 then
  trigger.action.markupToAll(7, Coalition, MarkID, vecs[1], vecs[2], vecs[3], vecs[4], vecs[5], vecs[6], vecs[7], vecs[8], vecs[9], Color, FillColor, LineType, ReadOnly, Text or "")
elseif #vecs==10 then
  trigger.action.markupToAll(7, Coalition, MarkID, vecs[1], vecs[2], vecs[3], vecs[4], vecs[5], vecs[6], vecs[7], vecs[8], vecs[9], vecs[10], Color, FillColor, LineType, ReadOnly, Text or "")
elseif #vecs==11 then
  trigger.action.markupToAll(7, Coalition, MarkID, vecs[1], vecs[2], vecs[3], vecs[4], vecs[5], vecs[6], vecs[7], vecs[8], vecs[9], vecs[10],
    vecs[11], 
    Color, FillColor, LineType, ReadOnly, Text or "")        
elseif #vecs==12 then
  trigger.action.markupToAll(7, Coalition, MarkID, vecs[1], vecs[2], vecs[3], vecs[4], vecs[5], vecs[6], vecs[7], vecs[8], vecs[9], vecs[10],
    vecs[11], vecs[12],
    Color, FillColor, LineType, ReadOnly, Text or "")
elseif #vecs==13 then
  trigger.action.markupToAll(7, Coalition, MarkID, vecs[1], vecs[2], vecs[3], vecs[4], vecs[5], vecs[6], vecs[7], vecs[8], vecs[9], vecs[10],
    vecs[11], vecs[12], vecs[13],
    Color, FillColor, LineType, ReadOnly, Text or "")
elseif #vecs==14 then
  trigger.action.markupToAll(7, Coalition, MarkID, vecs[1], vecs[2], vecs[3], vecs[4], vecs[5], vecs[6], vecs[7], vecs[8], vecs[9], vecs[10],
    vecs[11], vecs[12], vecs[13], vecs[14],
    Color, FillColor, LineType, ReadOnly, Text or "")                                                                                                                                                                                                           
elseif #vecs==15 then
  trigger.action.markupToAll(7, Coalition, MarkID, vecs[1], vecs[2], vecs[3], vecs[4], vecs[5], vecs[6], vecs[7], vecs[8], vecs[9], vecs[10],
    vecs[11], vecs[12], vecs[13], vecs[14], vecs[15],
    Color, FillColor, LineType, ReadOnly, Text or "")
else
  self:E("ERROR: Currently a free form polygon can only have 15 points in total!")
  -- Unfortunately, unpack(vecs) does not work! So no idea how to generalize this :(
  trigger.action.markupToAll(7, Coalition, MarkID, unpack(vecs), Color, FillColor, LineType, ReadOnly, Text or "")
end
Edited by HawaiianRyan
Posted
4 hours ago, HawaiianRyan said:

Do you have any tips if you want to draw a polygon with many vertices (e.g., over 150), especially if you do not know how many vertices in advance?

I don't know if there is a limit, but I know its not 15 because I just tested it the way mist does it with 23 points and it was fine. The trick is to convert it into a string that you execute. 

This is what mist does. with fCal being a table where all of the entries get inserted into a table in the order that they need to be. 

local s = "trigger.action.markupToAll("
for i = 1, #fCal do
  --log:warn(fCal[i])
  if type(fCal[i]) == 'table' or type(fCal[i]) == 'boolean' then
    s = s .. mist.utils.oneLineSerialize(fCal[i])
  else
    s = s .. fCal[i]
  end
  if i < #fCal then 
    s = s .. ','
  end
end
s = s .. ')'
local f, err = loadstring(s)
if f then
	return true, f()
else
	return false, err
end

Really wish they made a function for this that just accepts a table of points or a table of every parameters. Having a function with over 150 input variables seems non optimal. 

  • Thanks 2

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

  • Recently Browsing   0 members

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