Rookie Mission Editor: First try at scripting... - ED Forums
 


Notices

Reply
 
Thread Tools Display Modes
Old 03-17-2019, 05:59 PM   #1
deafaviator
Junior Member
 
Join Date: Mar 2019
Posts: 5
Default Rookie Mission Editor: First try at scripting...

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!

https://www.reddit.com/r/hoggit/comm...tor_questions/

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:

Quote:
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:



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):



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

Many thanks in advance for any help!
deafaviator is offline   Reply With Quote
Old 03-17-2019, 07:01 PM   #2
Majinbot
Member
 
Majinbot's Avatar
 
Join Date: May 2011
Location: Close to 51º Wing
Posts: 651
Default

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

Code:
if Unit.getByName('someUnit') and
	if Unit.getByName('someUnit'):getFuel() < 0.6 then
		trigger.action.setUserFlag(2, true)
	end
end
__________________
PC: i7-8700K@4.8 - RTX 2080ti - 16GB RAM PC3200 - 970 evo 1tb - Warthog Throttle - VKB GF pro - Saitek Pro Pedals - Acer XB271HU + Dell 2713H - TrackIR5 - Oculus CV1

Last edited by Majinbot; 03-17-2019 at 07:04 PM.
Majinbot is offline   Reply With Quote
Old 03-17-2019, 07:33 PM   #3
deafaviator
Junior Member
 
Join Date: Mar 2019
Posts: 5
Default

Thanks for your help. This does make a bit more sense but I still get an error - albeit a different one.

deafaviator is offline   Reply With Quote
Old 03-17-2019, 08:02 PM   #4
Majinbot
Member
 
Majinbot's Avatar
 
Join Date: May 2011
Location: Close to 51º Wing
Posts: 651
Default

Tipo
Code:
if Unit.getByName('someUnit') then
	if Unit.getByName('someUnit'):getFuel() < 0.6 then
		trigger.action.setUserFlag('2', true)
	end
end
__________________
PC: i7-8700K@4.8 - RTX 2080ti - 16GB RAM PC3200 - 970 evo 1tb - Warthog Throttle - VKB GF pro - Saitek Pro Pedals - Acer XB271HU + Dell 2713H - TrackIR5 - Oculus CV1
Majinbot is offline   Reply With Quote
Old 03-17-2019, 10:42 PM   #5
deafaviator
Junior Member
 
Join Date: Mar 2019
Posts: 5
Default

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***

Last edited by deafaviator; 03-18-2019 at 03:41 AM. Reason: Updated MIZ file link
deafaviator is offline   Reply With Quote
Old 03-18-2019, 03:49 AM   #6
deafaviator
Junior Member
 
Join Date: Mar 2019
Posts: 5
Default

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!
deafaviator is offline   Reply With Quote
Old 03-18-2019, 07:50 AM   #7
Rudel_chw
Veteran
 
Join Date: Nov 2013
Location: Antofagasta, Chile
Posts: 3,229
Default

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: 27" Monitor - Ryzen 1500X - 32 GB DDR4 2400 - MSI GTX970 - SSD 384 GB - HDD 8 TB - Windows 8.1 Pro - Thrustmaster HOTAS Cougar - Oculus Rift CV1
Mobile: iPad Pro 12.9" of 128 GB
Rudel_chw is offline   Reply With Quote
Old 03-18-2019, 12:58 PM   #8
deafaviator
Junior Member
 
Join Date: Mar 2019
Posts: 5
Default

Quote:
Originally Posted by Rudel_chw View Post
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.
deafaviator is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 01:34 PM. vBulletin Skin by ForumMonkeys. Powered by vBulletin®.
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.