Jump to content

Pulling coordinates from another script...


ENO
 Share

Recommended Posts

I've been around the horn trying to get my head around how I can pull the coordinates from the script below and utilize them to deploy a smoke marker in that area when a friendly aircraft enters a zone defined around that area.

 

I think my "man down" thread got too diluted and I wasn't getting any feedback on the issue. I'm going to try and get more specific as to my requirements in hope that I can more clearly define what I'm seeking.

 

An aircraft gets shot down. I am using this script to identify the location of the ejection:

 

customEventHandler = {};

 

function customEventHandler:onEvent(event)

if (world.event.S_EVENT_EJECTION == event.id) then

local _location = event.initiator:getPoint();

local _time = timer.getTime();

 

local _latitude, _longtitude, _ = coord.LOtoLL(_location);

 

trigger.action.outText('Pilot ejected at point: latitude: ' .. string.format("%.3f", _latitude) .. ', longitude: ' .. string.format("%.3f", _longtitude), 10);

 

end

end;

 

world.addEventHandler(customEventHandler);

 

 

 

It works well and I am able to broadcast that location for some time. Ideally I could pull that coordinate and define a zone of a certain diameter around that, then randomly spawn a "soldier" inside it. Once a friendly aircraft arrives in the zone, I can work at sorting out the rest through triggers. But I'm hung up on how to pull that coordinate and I apologize in advance but I'm having a REALLY hard time getting my head around whether or not I can create a zone, and whether or not I can create a unit in that zone.

 

Again, to those of you who are script savvy I'm REALLY sorry I can't seem to apply anything being learned in other threads as I'm struggling to get my head around what each script title is able to accomplish- so I don't know if it's what I want to do.

 

 

Ugh. The curse of ME.

"ENO"

Type in anger and you will make the greatest post you will ever regret.

 

"Sweetest's" Military Aviation Art

Link to comment
Share on other sites

Yeah, we've got a couple threads going :-)

 

All you need to do is remove "local" from the line "local _location = event.initiator:getPoint();" and it's now available in subsequent scripts to spawn a group/unit at that location.

 

Your x coordinates for the spawned group need to be "_location.x" and y is "_location.z"

 

As I mentioned in the other thread, going to share what I've got so far. I am working on trying to spawn the pilot (solider) where the chute lands, rather than at eject point, though having both coordinates will be handy for realistic SAR triggers and radio calls.

Link to comment
Share on other sites

I've been trying to crack the issue of making of a dynamic zone near the pilot location. This morning I came up with the bright idea of making a pilot (solider) unit off to a corner of the map, calling him say, "DownedPilot1" and attaching a moving zone to him. Then after ejection, when a new "DownedPilot1" get spawned, it DOES replace unit made in the ME (and all his attributes), however - it doesn't seem to move the "moving zone" with him when he "respawns", unless I am doing it wrong. Would be a great for this dynamic CSAR concept if that worked.

Link to comment
Share on other sites

  • 4 months later...

I guess there is an easy answer to this but I can't find the error, blind. The script stops if I try to send the result out to display, script itself works I think.

 

local groupname = 'group1' -- specify the group name in mission
local group = Group.getByName(groupname)
group = group:getUnits()[1]
-- get the flights current position
group = group:getPosition().p
trigger.action.outText('position: ' .. group,10)

 

If I comment out the outText line the mission runs so there is something mission in the outText line somwhere.

Link to comment
Share on other sites

group is still a table and you can't concat a table with a string.

 

 

It basically equates to

 

group = {

x = Distance,

y = Distance,

z = Distance

}

 

To use it you can do something like:

 

trigger.action.outText(tostring('position X: ' .. group.x .. ' position Y: ' .. group.Y ..' positionZ: ' .. group.Z),10)

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

Current Projects: Scripting Wiki, Something...

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

The working copy of this script that displays current possition of an unit. I used a F-15C in the testing with groupname "group1". The x/y/z parts needs to be in lowercase letters.

 

local groupname = 'group1' -- specify the group name in mission
local group = Group.getByName(groupname)
group = group:getUnits()[1]
-- get the flights current position
group = group:getPosition().p
trigger.action.outText(tostring('position X: ' .. group.x .. ' position Y: ' .. group.y ..' positionZ: ' .. group.z),10)

 

This mission displays the aircrafts position after 10 seconds. Script defined in TRIGGERS.

Test - Display aircraft position.miz

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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