johnv2pt0 Posted March 11, 2013 Share Posted March 11, 2013 Is it possible to check the state of an engine (on / off) and make a trigger based off that check? What I want to do is simply have a troop in front of my ka-50 simulating the ground crew. Once I have my engine started with no fire I want him to move off the FARP. I'm not a programmer and don't understand the SSE or MIST yet, so I'm not sure if this is possible. Thanks for any help ~ Link to comment Share on other sites More sharing options...
johnv2pt0 Posted March 11, 2013 Author Share Posted March 11, 2013 If the answer to this is obvious I'd appreciate someone telling me so. The manual doesn't really explain half of what's wrapped up in the ME since all the updates. Clear skies ~ Link to comment Share on other sites More sharing options...
alfredo_laredo Posted March 11, 2013 Share Posted March 11, 2013 I dont know if it can be done as you wanted, I would try a much more simple way, Just estimate the time it takes to startup, Make the Troops "Late activation" and set the time you estimated. Ex.. If its 12 pm... and you take 4 minutes to get ready, ser the time at 12:4.00 And you can also send a message as "CLeared for takeoff" or something Remember to set the troops also "Visible before start" 1 A.K.A. Timon -117th- in game Link to comment Share on other sites More sharing options...
EvilBivol-1 Posted March 11, 2013 Share Posted March 11, 2013 You can do this by using cockpit triggers in the ME to check the status of the engine RPM gauges, for example. It can be a little daunting at first if you're completely unfamiliar with the cockpit trigger system, but not that complicated once you understand the basic principles. http://forums.eagle.ru/showthread.php?t=81376 1 - EB [sIGPIC][/sIGPIC] Nothing is easy. Everything takes much longer. The Parable of Jane's A-10 Forum Rules Link to comment Share on other sites More sharing options...
johnv2pt0 Posted March 11, 2013 Author Share Posted March 11, 2013 I dont know if it can be done as you wanted, I would try a much more simple way, Just estimate the time it takes to startup, Make the Troops "Late activation" and set the time you estimated. Ex.. If its 12 pm... and you take 4 minutes to get ready, ser the time at 12:4.00 And you can also send a message as "CLeared for takeoff" or something Remember to set the troops also "Visible before start" That's actually what I'm doing now but it just annoys me that it's not as precise. Helps the immersion a lot if it can trigger at different times based on what's actually happening. You can do this by using cockpit triggers in the ME to check the status of the engine RPM gauges, for example. It can be a little daunting at first if you're completely unfamiliar with the cockpit trigger system, but not that complicated once you understand the basic principles. http://forums.eagle.ru/showthread.php?t=81376 Great! I'll read up on it. Thanks guys...much appreciated! Link to comment Share on other sites More sharing options...
Bushmanni Posted March 12, 2013 Share Posted March 12, 2013 You can also use fuelflow as an indicator of engine operation. With 1.2.3 it's possible to get the amount of fuel of any unit with a script and with that you can calculate fuel flow by taking two samples of fuel amount and calculating the difference and dividing it with the time interval between samples. 2 DCS Finland: Suomalainen DCS yhteisö -- Finnish DCS community -------------------------------------------------- SF Squadron Link to comment Share on other sites More sharing options...
Speed Posted March 12, 2013 Share Posted March 12, 2013 (edited) You can also use fuelflow as an indicator of engine operation. With 1.2.3 it's possible to get the amount of fuel of any unit with a script and with that you can calculate fuel flow by taking two samples of fuel amount and calculating the difference and dividing it with the time interval between samples. :doh: Great thinking! I was going to say the cockpit argument trigger method, but of course, 1.2.3. adds the Unit.getFuel Lua function. I haven't tested Unit.getFuel on multiplayer clients though. I wonder if it works for them? Regardless, cockpit argument triggers will not work on multiplayer clients either, so Unit.getFuel remains the best, and easiest method to do this. Unfortunately, you cannot do this with just one time sample, and you cannot tell the difference between deliberate defueling and actual engine operation, unless you want watch a few samples of fuel flow to determine if it is normal fuel flow or ground crew removing fuel, and that increases the complexity of the script and requires you to determine what the normal fuel flow actually is. Anyway, building on Bushmanni's idea, I think this script will work (though, like I said, I don't know if it operates correctly on MP clients): Run this script on mission start: function getEngineStartedFunc(unitName) local unit = Unit.getByName(unitName) if unit then local startingFuel = unit:getFuel() return function() if unit:isExist() if unit:getFuel() < startingFuel then return true end end end end end This makes the global function, "getEngineStartedFunc". Now, every time a unit whose engine start you want to detect is spawned, do this script: Hawg11Started = getEngineStartedFunc('Hawg11') Where in this case, the unit's name is "Hawg11". Now, in a Lua expression trigger condition, do this script: return Hawg11Started() Your Lua Expression trigger condition should go true when the unit named "Hawg11" starts its engines. Edited March 12, 2013 by Speed Intelligent discourse can only begin with the honest admission of your own fallibility. Member of the Virtual Tactical Air Group: http://vtacticalairgroup.com/ Lua scripts and mods: MIssion Scripting Tools (Mist): http://forums.eagle.ru/showthread.php?t=98616 Slmod version 7.0 for DCS: World: http://forums.eagle.ru/showthread.php?t=80979 Now includes remote server administration tools for kicking, banning, loading missions, etc. Link to comment Share on other sites More sharing options...
johnv2pt0 Posted March 13, 2013 Author Share Posted March 13, 2013 (edited) Awesome! Thanks gents...I thought I was hosed when I realized the cockpit arguments wouldn't work for MP. After trying this, I receive this error: [string "return Shark1Started()":]:1:attempt to call global 'Shark1Started' (a nil value) My triggers in this test mission: MissionStart > time more 1 > doscript Once > Group Alive > doscript time more 5 Once > Expression > sound to all time more 6 Edited March 13, 2013 by johnv2pt0 Link to comment Share on other sites More sharing options...
Grimes Posted March 13, 2013 Share Posted March 13, 2013 Change it to Mission Start>Time LESS 1> Do Script. The mission start trigger type simply checks if the conditions are true at time index "0". A trigger using the condition "time more" with mission start will simply never work. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum Link to comment Share on other sites More sharing options...
johnv2pt0 Posted March 13, 2013 Author Share Posted March 13, 2013 Change it to Mission Start>Time LESS 1> Do Script. The mission start trigger type simply checks if the conditions are true at time index "0". A trigger using the condition "time more" with mission start will simply never work. I receive a different error where lua is expecting a "then" near the "if". Doesn't make sense to me because those statements are in the code. Also, the other error about a nil value doesn't make sense to me because I DID assign the function to the string "Shark1Started". If you could take a peek at my .miz I'd appreciate it. I bought a lua programming book on my kindle just now! lol Link to comment Share on other sites More sharing options...
Speed Posted March 13, 2013 Share Posted March 13, 2013 (edited) I receive a different error where lua is expecting a "then" near the "if". Doesn't make sense to me because those statements are in the code. Also, the other error about a nil value doesn't make sense to me because I DID assign the function to the string "Shark1Started". It makes perfect sense if you drop the assumption that I write perfect code. I wrote that code at work and never had a chance to test it, so it was easy for me to miss a mistake. function getEngineStartedFunc(unitName) local unit = Unit.getByName(unitName) if unit then local startingFuel = unit:getFuel() return function() if unit:isExist() then if unit:getFuel() < startingFuel then return true end end end end end Try the above code- I had forgotten a "then" after one of the "if"s. Edited March 13, 2013 by Speed Intelligent discourse can only begin with the honest admission of your own fallibility. Member of the Virtual Tactical Air Group: http://vtacticalairgroup.com/ Lua scripts and mods: MIssion Scripting Tools (Mist): http://forums.eagle.ru/showthread.php?t=98616 Slmod version 7.0 for DCS: World: http://forums.eagle.ru/showthread.php?t=80979 Now includes remote server administration tools for kicking, banning, loading missions, etc. Link to comment Share on other sites More sharing options...
Speed Posted March 13, 2013 Share Posted March 13, 2013 Ok, just tested the fixed code, it does in fact work- at least for the single player/host. (I am kinda doubtful of it working in multiplayer, but at least there's a chance.) However, it works so well that it detects what must be some infinitesimal amount of fuel used when I switch on the fuel pumps :doh: So I might suggest the following modification: function getEngineStartedFunc(unitName) local unit = Unit.getByName(unitName) if unit then local startingFuel = unit:getFuel() return function() if unit:isExist() then if unit:getFuel() < startingFuel - 0.005 then return true end end end end end By adjusting that 0.005 to be a smaller number, you can make the engine started condition come true earlier in the startup sequence. However, in the attached test mission, it seems just about perfectly timed- when I tested it, the "engines started" message popped up right as the 2nd engine of my Ka-50 finished spooling up.Engine started test.miz Intelligent discourse can only begin with the honest admission of your own fallibility. Member of the Virtual Tactical Air Group: http://vtacticalairgroup.com/ Lua scripts and mods: MIssion Scripting Tools (Mist): http://forums.eagle.ru/showthread.php?t=98616 Slmod version 7.0 for DCS: World: http://forums.eagle.ru/showthread.php?t=80979 Now includes remote server administration tools for kicking, banning, loading missions, etc. Link to comment Share on other sites More sharing options...
johnv2pt0 Posted March 13, 2013 Author Share Posted March 13, 2013 Awesome, I'll check it out when I get home today. On a side note, one last question. I thought in an if then statement there has to be an "else." Am I correct in assuming if no "else" exists then it's assumed the "else" is to do nothing? Just asking cause I want to make sure I'm not missing something in the way DCS lua works. Thanks for the help ~ Link to comment Share on other sites More sharing options...
Speed Posted March 13, 2013 Share Posted March 13, 2013 Awesome, I'll check it out when I get home today. On a side note, one last question. I thought in an if then statement there has to be an "else." Am I correct in assuming if no "else" exists then it's assumed the "else" is to do nothing? Just asking cause I want to make sure I'm not missing something in the way DCS lua works. Thanks for the help ~ There is an else and and elseif in Lua, but they are not necessary. They are frequently used, but in this case, I gave you just about as simple of a script as I could think of. 1 Intelligent discourse can only begin with the honest admission of your own fallibility. Member of the Virtual Tactical Air Group: http://vtacticalairgroup.com/ Lua scripts and mods: MIssion Scripting Tools (Mist): http://forums.eagle.ru/showthread.php?t=98616 Slmod version 7.0 for DCS: World: http://forums.eagle.ru/showthread.php?t=80979 Now includes remote server administration tools for kicking, banning, loading missions, etc. Link to comment Share on other sites More sharing options...
johnv2pt0 Posted March 14, 2013 Author Share Posted March 14, 2013 Tested this tonight hosting a server. Works for host but not clients. Bummer. Link to comment Share on other sites More sharing options...
Grimes Posted March 14, 2013 Share Posted March 14, 2013 Oh yeah. Unit.getFuel() doesn't work on clients in 1.2.3. It might be fixed on the tester version, but I haven't checked lately. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum Link to comment Share on other sites More sharing options...
Speed Posted March 14, 2013 Share Posted March 14, 2013 No real surprise there. Clients must be in charge of all the computations involving their own aircraft. What are you supposed to do- expect the host to run like 8 or more realistic flight models simultaneously? Clients would have to wait 150 milliseconds after they apply an input for the server to tell them how much they are allowed to roll? You'd need to be connected over a local network to a Cray supercomputer to make that work. So anyway, in order to optimize the network code, clients just don't send the server data that is unnecessary for the server to know. Since the amount of fuel a client has does not affect anything in the outside world (at least, by default), then it is simply not sent over the network. We'll need ED to make it so client fuel is sent over the network for Unit.getFuel to work on clients. I can't say whether or not this will happen. Intelligent discourse can only begin with the honest admission of your own fallibility. Member of the Virtual Tactical Air Group: http://vtacticalairgroup.com/ Lua scripts and mods: MIssion Scripting Tools (Mist): http://forums.eagle.ru/showthread.php?t=98616 Slmod version 7.0 for DCS: World: http://forums.eagle.ru/showthread.php?t=80979 Now includes remote server administration tools for kicking, banning, loading missions, etc. Link to comment Share on other sites More sharing options...
Recommended Posts