Jump to content

Recommended Posts

Posted

First post here. Hello everyone!

 

So I have been messing around with the M.E. for the past few weeks and trying to teach myself how to create increasingly complex missions. My goal is to eventually create a nice story driven campaign for myself and my buddies who I fly with.

 

So with that said, I'm obviously learning a lot every time I open up M.E., and I am starting to bump into obstacles requiring scripting, which I am completely in the dark on. I know I am asking a lot but I would really appreciate any help I can get!!

 

I made a Reddit post as well a couple days ago but I realized I'd probably have better luck here, although I've had a couple of very helpful responses over on Reddit!

 

 

My main issue at this moment is with this scenario:

 

Myself and a wingman, in F-14's, are A2A refueling. I am wanting a trigger/flag when the fuel reaches 10,000 lbs. This flag would set off subsequent actions (mainly messages). I did try messing around with a trigger upon "Refuel Stop" but the problem with that is that it gets triggered if you disconnect accidentally while refueling. So instead I would like the mission to ignore fuel stoppages and instead view 10,000lbs of fuel as the "we're done" point, at which time the mission would begin the next phase.

 

As I learned over on Reddit, this can be done with LUA scripting (again, LUA is completely new to me), and I got a little bit of help with that but I am having trouble implementing the script as I am not sure how to execute it correctly.

 

Someone on Reddit explained:

 

Easiest would be in a trigger. Have the condition be "flag X false" and lua predicate. Then for that lua text box have this code:

 

if Unit.getByName('someUnit') and Unit.getByName('someUnit'):getFuel() < 0.6 then

return true

else

return false

end

Then the action would be set flag X to true and display your message. Just replace someUnit with whatever the unit name is. However! It is important that there is an apostrophe at the start and end of the unit name. In lua that is how you define a string and must match the units name exactly.

 

I have put it into M.E. as follows:

 

20190317110949_1.jpg?psid=1

 

I had a feeling this wasn't correct - most likely both in the use of the script itself and the use of the flags.

 

I was right.... Launching the mission, I get the following repeat error (pops up every time I "OK" out of it):

 

Desktop%20Screenshot%202019.03.17%20-%2011.39.02.49%20%282%29.png?psid=1

 

So that's where I'm at currently. Can someone take me by the hand and walk me through this? :doh:

 

Many thanks in advance for any help!

Posted (edited)

I dont think lua predicate is functional. You have to use the do script action. Something like that:

 

Continous - Flag 2 is False - Do script

 

if Unit.getByName('someUnit') and
if Unit.getByName('someUnit'):getFuel() < 0.6 then
	trigger.action.setUserFlag(2, true)
end
end

Edited by Majinbot

PC: i7-13700K - Gigabyte RTX 5080 GAMING OC - 64GB DDR5 6400 - VPC MongoosT-50CM3 - VKB GF pro - MFG Crosswind - Msi MPG321UR-QD + LG OLED 32GS95UE - TrackIR5 - Quest 3

Posted

Tipo

if Unit.getByName('someUnit') then
if Unit.getByName('someUnit'):getFuel() < 0.6 then
	trigger.action.setUserFlag('2', true)
end
end

PC: i7-13700K - Gigabyte RTX 5080 GAMING OC - 64GB DDR5 6400 - VPC MongoosT-50CM3 - VKB GF pro - MFG Crosswind - Msi MPG321UR-QD + LG OLED 32GS95UE - TrackIR5 - Quest 3

Posted (edited)

Okay so I fussed around with it for like 6 hours today and this is the best I can do. It will not trigger correctly. I have tried multiple combinations and variations of trigger types, conditions, etc and most of them throw errors. Conditions only change when the message will be displayed but it never displays based on fuel load. If I have no conditions, it'll give me the triggered message at the beginning of the mission, If I have a condition of Unit Inside Moving Zone (the tanker), it triggers as soon as I enter the zone. If I try the Flag 3 False, it throws an error.

 

I'm pretty much ready to just give up on being able to have this part of the mission working right. I just don't have the scripting skill for it. I've uploaded my MIZ file for anyone who wants to see give it a try... All I want is for "more than" a fuel load to trigger a message. That's it.

 

***HYPERLINK DELETED - READ BELOW***

Edited by deafaviator
Updated MIZ file link
Posted

Got it working! Thank you for all your help!!

 

Turns out the "greater than" symbol was the wrong way. That's why the script kept triggering. It was reading it correctly as "if fuel less than 0.3...". I swapped the > around, and voila, it works as intended.

 

Corrected and latest mission file if anyone wants to try it. It's intended for a buddy and I to fly it together so there's comms for a wingman that isn't there.

 

https://1drv.ms/u/s!Ao1GdPnFY9bnw3oiOCPdfc0e96Le

 

Mission file if anyone wants to try it out.

 

https://1drv.ms/u/s!Ao1GdPnFY9bnw3sa58C_hbJr0abk

 

Link to a short video of the script triggering as intended.

 

Thanks again for your help!

Posted

Thanks for sharing the mission, and I’m glad you got it working :) ... will try it out tonight.

 

For work: iMac mid-2010 of 27" - Core i7 870 - 6 GB DDR3 1333 MHz - ATI HD5670 - SSD 256 GB - HDD 2 TB - macOS High Sierra

For Gaming: 34" Monitor - Ryzen 3600 - 32 GB DDR4 2400 - nVidia RTX2080 - SSD 1.25 TB - HDD 10 TB - Win10 Pro - TM HOTAS Cougar

Mobile: iPad Pro 12.9" of 256 GB

Posted
Thanks for sharing the mission, and I’m glad you got it working :) ... will try it out tonight.

 

Would appreciate any thoughts and feedback. There’s still a lot I want to do but for the most part it’s complete and functional from beginning to end and works correctly. Now I just need to tweak the timing of the messages, adjust a couple of them for errors (I believe the very first message has the distance wrong), I’d like to add some more chatter during the quiet portions of the flight, and do the briefing. I’d also eventually like to add voice to the comms - need to play around with that. My main concern is I’m looking at at least 5 different voices and there’s only myself.

 

Anyways, any feedback would be appreciated. I’m intending to make a story driven campaign stemming from this.

  • Recently Browsing   0 members

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