Jump to content

Recommended Posts

Posted

1.jpg

 

I want to know how to create a box that can be made with the Draw Tool with a script I want to create multiple boxes like the trigger zone in the image, but only a script error occurs Could you please explain about this?

If it is difficult to explain, I have uploaded the miz file in the as an attachment.
If you make even one box, I will study the script you wrote.

 

 

123.miz

Posted

well, this is your code:

local point2 = trigger.misc.getZone("CS58").point2

trigger.action.circleToAll(-1 , 3 , point2 , 5000 , {1,0,0,1} , {1,0,0,0.2} , 4)

So your point2 definition has an error (the trailing "2" when accessing the zone's point attribute), and you are invoking circleToAll, not rect to all. I'll see if I can get something better for you to work with

 

Posted (edited)

The easy way would be to draw the rectangle with a trigger zone similar to what you have done and to use the points created to define the shape. Though you should probably check for a specific zone name. The following code will draw every quad trigger zone. 

local mId = 0
local function id()
  mId = mId + 1
  return mId
end
for iter, zData in pairs(env.mission.triggers.zones) do
    if zData.verticies then
        local tbl = {-1, id()}
        
        for i = 1, #zData.verticies do
            table.insert(tbl, {x = zData.verticies[i].x, y = 0, z = zData.verticies[i].y})
        end
        table.insert(tbl, {0, 1, 0, .7} )   
        table.insert(tbl, {1, .5, 1, .3} )
        table.insert(tbl,  math.random(0, 6))
        trigger.action.quadToAll(unpack(tbl))

    end
end

A more precise way would be to feed coord.MGRStoLL the coordinates for each corner of the grid and convert those from LLtoLO via that function to get the exact point. 

Edited by Grimes

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

Posted (edited)

OK, this works. 

local theZone = trigger.misc.getZone("CS58")
local theCenter = theZone.point

-- calculate the edge points 
local radius = 5000
local upperLeft = {x=theCenter.x-radius, 0, z=theCenter.z-radius}
local lowerRight = {x=theCenter.x+radius, 0, z=theCenter.z+radius}

trigger.action.rectToAll(-1 , 123456 , upperLeft , lowerRight , {1,0,0,1} , {1,0,0,0.2} , 1, true, "hi there")

And I know what you mean: rectToAll seems to be somewhat borked. I found out that it can't always accept an empty string, so it's not optional at all. If you simply invoke rectToAll without readOnly and message, or with an empty message, you'll get a REALLY STRANGE error indeed 🙂 

 

Here's the mission, working.

 

123.miz

image.png

Edited by cfrag
Posted

I should probably mention that MGRS grids aren't perfectly aligned with the map origin and rectToAll cannot be rotated. The further away from map origin the more rotated the grids become as they are oriented to true north, while the maps are a "flat projection". As a result the two points would generate a shape similar to the screenshot. Which is why my example used quadToAll instead. 

I'll be adding an example of the MGRStoLL on the hoggit wiki shortly. 

rect_shape_offset_map_origin.png

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

Posted
1시간 전 cfrag는 다음과 같이 말했습니다.

알겠습니다. 작동합니다. 

그리고 나는 당신이 의미하는 바를 압니다. rectToAll이 다소 지루한 것 같습니다. 항상 빈 문자열을 허용할 수는 없으므로 선택 사항이 아닙니다. readOnly 및 메시지 없이 또는 빈 메시지와 함께 rectToAll을 단순히 호출하면 실제로 REALLY STRANGE 오류가 발생합니다. 🙂 

 

여기 미션이 있습니다.

 

123.miz 34.51 kB · 1 다운로드

이미지.png

 

{1,0,0,0.2}
Even if you change this fill part, you can't change the inner color
Is this a DCS problem?

  • Recently Browsing   0 members

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