Jump to content

Recommended Posts

Posted

Hi everyone!
A quick question.
Is there a more effective way for a trigger to fire exactly when a helicopter lands? So far I have done as usual, using conditions:

Unit's Vertical Speed in limits  min - 1  max 1

Unit's Speed Lower Than 2 Kts

Unit's  AGL  Altitude lower Than 2

but I am not satisfied, in fact it happens that by staying for a few seconds in overing at 4-5 feet on the trigger, it activates and I do not find it very realistic.

Thanks for any advice

Posted

Hey @Facocero!  Use a simple script that uses an EVENT HANDLER like this to achieve what you want.  You can put the script in the actions under "Do Script".  I've attached a sample script and a sample mission for you to check out.

helounit = Unit.getByName('BLACKHAWK 601')     -- Put your unit NAME in where BLACKHAWK 601 is.  Make sure to keep the apostrophe in    
                             
Handler = {}
function Handler:onEvent(event)
    if event.id == world.event.S_EVENT_LAND and event.initiator == helounit then
                trigger.action.outText('The Helicopter has landed.', 10, true)  -- You can put some text here if you'd like
                trigger.action.setUserFlag ('10', 1) -- this sets flag 10 to be on.  Replace the 10 with whatever you want.
                end
                end
world.addEventHandler(Handler)

 

HELO LAND.miz

  • Thanks 1
  • 1 year later...
Posted
10 minutes ago, Sedlo said:

Possible, but I haven't used that before.

 

Are there docs or guidance on this? I've searched on the forum, but most answers are scripts used for "Do Script", while I wish to simply use the script on the condition.

Posted
12 minutes ago, BoundaryLayer said:

Hi, Sedlo. I wonder if there's such a script used to put under Condition - Lua Predicate.

if(Unit.getByName("unitname")) then
if(Unit.getByName("unitname"):inAir() == false) then
return true
else
return false
end
else
return false
end

You'll need another condition for initialization otherwise the condition will return true if the unit starts on the ground, like a flag once the unit takes off.

Posted
7 minutes ago, NeedzWD40 said:
if(Unit.getByName("unitname")) then
if(Unit.getByName("unitname"):inAir() == false) then
return true
else
return false
end
else
return false
end

Thanks, NeedzWD40, this works!

7 minutes ago, NeedzWD40 said:

You'll need another condition for initialization

I get your idea here that the script checks if the unit is still inAir or not. From other answers I see people also use world.event.S_EVENT_LAND. I wonder if this can be combined to your script.

BTW, where can I find docs on this, as I've just started playing with scripts in ME.

Posted
10 minutes ago, BoundaryLayer said:

BTW, where can I find docs on this, as I've just started playing with scripts in ME.

The hoggit wiki is the best place to start as they update the commands frequently.

As for the landing event, it wouldn't help much since the unit would return on the ground on the event's trigger. inAir also works with more than just aircraft, so you could use it to check if a cargo crate is in the air or on the ground for example.

Posted
4 minutes ago, NeedzWD40 said:

The hoggit wiki is the best place to start as they update the commands frequently.

As for the landing event, it wouldn't help much since the unit would return on the ground on the event's trigger. inAir also works with more than just aircraft, so you could use it to check if a cargo crate is in the air or on the ground for example.

Thanks! Will dive into this🫠

  • Recently Browsing   0 members

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