J900 Posted July 30, 2019 Share Posted July 30, 2019 Hi, new to scripting & trying to get the airbrakes.lua to operate either on/off before trying to add parameters for extend time/effect etc bot so far no luck.. Command defs.lua PlaneAirBrake = 73, PlaneAirBrakeOn = 147 PlaneAirBrakeOff = 148, device.init.lua creators[devices.AIRBRAKES] = {"avLuaDevice" ,LockOn_Options.script_path.."Systems/airbrakes.lua"} airbrakes.lua dofile(LockOn_Options.script_path.."command_defs.lua") local dev = GetSelf() local update_time_step = 0.1 make_default_activity(update_time_step) local sensor_data = get_base_data() local Airbrake = 73 local AirbrakeOn = 147 local AirbrakeOff = 148 dev:listen_command(Airbrake) dev:listen_command(AirbrakeOn) dev:listen_command(AirbrakeOff) function SetCommand(command,value) if (command == AirbrakeOn) then dispatch_action(nil,iPlaneAirBrakeOn) elseif (command == AirbrakeOff) then dispatch_action(nil,iPlaneAirBrakeOff) end end need_to_be_closed = false -- close lua state after initialization Thanks. Link to comment Share on other sites More sharing options...
fl0w Posted July 31, 2019 Share Posted July 31, 2019 From what I have been able to observe, the state of a system like the airbrakes, landing gears, etc. are dependent on the animation position value. Try this: dofile(LockOn_Options.script_path.."command_defs.lua") local dev = GetSelf() local update_time_step = 0.1 make_default_activity(update_time_step) local sensor_data = get_base_data() local Airbrake = 73 local AirbrakeOn = 147 local AirbrakeOff = 148 local airbrake_command = 0 local airbrake_state = 0 dev:listen_command(Airbrake) function SetCommand(command,value) if command == Airbrake then airbrake_command = 1 else airbrake_command = 0 end end function update() if (airbrake_command == 1 and airbrake_state ~= 1) then airbrake_state = 1 end if (airbrake_command == 0 and airbrake_state ~= 0) then airbrake_state = 0 end end need_to_be_closed = false -- close lua state after initialization A basic script that will set it at maximum animation position, no transitional movement. Hope that helps. Link to comment Share on other sites More sharing options...
J900 Posted July 31, 2019 Author Share Posted July 31, 2019 Hi Sirius, thanks for your help. no luck yet! Checked the air brake animation on the model by dropping into the su25t and works ok and created an externalanimations.lua which now has the contol surfaces working well. The hold up now seems to be getting an initial control response to the main systems. Wouldn't have thought it would make a difference but i wonder if making a clickeable control lever would help? Link to comment Share on other sites More sharing options...
fl0w Posted August 1, 2019 Share Posted August 1, 2019 I assume you did this, but just to make sure: did you place your code from command_defs.lua in a Keys dictionary variable? ie. Keys = {}. A clickable control lever would just control the ability to allow interpretation in the SetCommand() function with the element's value. You would be using whatever number you assigned to your element value along with the command Airbrake check. Doing that would be "if command == Airbrake or 3001 then" instead. For your control surfaces, if you're modeling just linkage and no hydraulics you are best with getting the base data from stick roll and pitch positions, along of rudder and dividing by a number like 100 or higher and actively drawing it with calculations in an update() function. Link to comment Share on other sites More sharing options...
J900 Posted August 1, 2019 Author Share Posted August 1, 2019 Ok thanks, this is how command_defs is currently. Have got the airbrakes, gear and flap levers working as clickeable in cockpit, just need to try figure out a basic working code and go from there. Keys = { PlanePickleOn = 350, PlanePickleOff = 351, PlaneFireOn = 84, PlaneFireOff = 85, PlaneFlaps = 72, PlaneFlapsOn = 145, PlaneFlapsOff = 146, PlaneGear = 68, PlaneGearUp = 430, PlaneGearDown = 431, PlaneAirbrake = 73, PlaneAirbrakeOn = 147, PlaneAirbrakeOff = 148, } start_command = 3000 device_commands = { flaps = start_command + 1; Gear = start_command + 2; Airbrake = start_command + 3; Button_4 = start_command + 4; Button_5 = start_command + 5; Button_6 = start_command + 6; Button_7 = start_command + 7; Button_8 = start_command + 8; Button_9 = start_command + 9; Button_10 = start_command + 10; Button_11 = start_command + 11; Button_12 = start_command + 12; Button_13 = start_command + 13; Button_14 = start_command + 14; Button_15 = start_command + 15; Button_16 = start_command + 16; Button_17 = start_command + 17; Button_18 = start_command + 18; Button_19 = start_command + 19; Button_20 = start_command + 20; Button_21 = start_command + 21; Button_22 = start_command + 22; Button_23 = start_command + 23; Button_24 = start_command + 24; Button_25 = start_command + 25; Button_26 = start_command + 26; Button_27 = start_command + 27; Button_28 = start_command + 28; Button_29 = start_command + 29; Button_30 = start_command + 30; Button_31 = start_command + 31; Button_32 = start_command + 32; Button_33 = start_command + 33; Button_34 = start_command + 34; Button_35 = start_command + 35; Button_36 = start_command + 36; Button_37 = start_command + 37; Button_38 = start_command + 38; Button_39 = start_command + 39; Button_40 = start_command + 40; Button_41 = start_command + 41; Button_42 = start_command + 42; Button_43 = start_command + 43; Button_44 = start_command + 44; Button_45 = start_command + 45; Button_46 = start_command + 46; Button_47 = start_command + 47; Button_48 = start_command + 48; Button_49 = start_command + 49; Button_50 = start_command + 50; Button_51 = start_command + 51; Button_52 = start_command + 52; Button_53 = start_command + 53; Button_54 = start_command + 54; Button_55 = start_command + 55; Button_56 = start_command + 56; Button_57 = start_command + 57; Button_58 = start_command + 58; Button_59 = start_command + 59; Button_60 = start_command + 60; Button_61 = start_command + 61; Button_62 = start_command + 62; Button_63 = start_command + 63; Button_64 = start_command + 64; Button_65 = start_command + 65; Button_66 = start_command + 66; Button_67 = start_command + 67; Button_68 = start_command + 68; Button_69 = start_command + 69; Button_70 = start_command + 70; Button_81 = start_command + 81; Button_82 = start_command + 82; Button_83 = start_command + 83; Button_84 = start_command + 84; Button_85 = start_command + 85; Button_86 = start_command + 86; Button_87 = start_command + 87; Button_88 = start_command + 88; Button_89 = start_command + 89; Button_90 = start_command + 90; Button_91 = start_command + 91; Button_92 = start_command + 92; Button_93 = start_command + 93; Button_94 = start_command + 94; Button_95 = start_command + 95; Button_96 = start_command + 96; Button_97 = start_command + 97; Button_98 = start_command + 98; Button_99 = start_command + 99; Button_100 = start_command + 100; Button_100 = start_command + 100; Button_101 = start_command + 101; Button_102 = start_command + 102; Button_103 = start_command + 103; Button_104 = start_command + 104; Button_105 = start_command + 105; Button_106 = start_command + 106; Button_107 = start_command + 107; Button_108 = start_command + 108; Button_109 = start_command + 109; Button_110 = start_command + 110; Button_111 = start_command + 111; Button_112 = start_command + 112; Button_113 = start_command + 113; Button_114 = start_command + 114; Button_115 = start_command + 115; Button_116 = start_command + 116; Button_117 = start_command + 117; Button_118 = start_command + 118; Button_119 = start_command + 119; Button_120 = start_command + 120; Button_121 = start_command + 121; Button_122 = start_command + 122; Button_123 = start_command + 123; Button_124 = start_command + 124; Button_125 = start_command + 125; Button_126 = start_command + 126; Button_127 = start_command + 127; Button_128 = start_command + 128; Button_129 = start_command + 129; Button_130 = start_command + 130; Button_131 = start_command + 131; Button_132 = start_command + 132; Button_133 = start_command + 133; Button_134 = start_command + 134; Button_135 = start_command + 135; Button_136 = start_command + 136; Button_137 = start_command + 137; Button_138 = start_command + 138; Button_139 = start_command + 139; Button_140 = start_command + 140; Button_141 = start_command + 141; Button_142 = start_command + 142; Button_143 = start_command + 143; Button_144 = start_command + 144; Button_145 = start_command + 145; Button_146 = start_command + 146; Button_147 = start_command + 147; Button_148 = start_command + 148; Button_149 = start_command + 149; Button_150 = start_command + 150; Button_151 = start_command + 151; Button_152 = start_command + 152; Button_153 = start_command + 153; Button_154 = start_command + 154; Button_155 = start_command + 155; Button_156 = start_command + 156; Button_157 = start_command + 157; Button_158 = start_command + 158; Button_159 = start_command + 159; Button_160 = start_command + 160; Button_161 = start_command + 161; Button_162 = start_command + 162; Button_163 = start_command + 163; Button_164 = start_command + 164; Button_165 = start_command + 165; Button_166 = start_command + 166; Button_167 = start_command + 167; Button_168 = start_command + 168; Button_169 = start_command + 169; Button_170 = start_command + 170; Button_171 = start_command + 171; Button_172 = start_command + 172; Button_173 = start_command + 173; Button_174 = start_command + 174; Button_175 = start_command + 175; Button_176 = start_command + 176; Button_177 = start_command + 177; Button_178 = start_command + 178; Button_179 = start_command + 179; Button_180 = start_command + 180; Button_181 = start_command + 181; Button_182 = start_command + 182; Button_183 = start_command + 183; Button_184 = start_command + 184; Button_185 = start_command + 185; Button_186 = start_command + 186; Button_187 = start_command + 187; Button_188 = start_command + 188; Button_189 = start_command + 189; Button_190 = start_command + 190; Button_191 = start_command + 191; Button_192 = start_command + 192; Button_193 = start_command + 193; Button_194 = start_command + 194; Button_195 = start_command + 195; Button_196 = start_command + 196; Button_197 = start_command + 197; Button_198 = start_command + 198; Button_199 = start_command + 199; Button_200 = start_command + 200; } Link to comment Share on other sites More sharing options...
fl0w Posted August 1, 2019 Share Posted August 1, 2019 This may interest you for a basic animation script on systems like the flaps, gears, airbrake and etc. You would have to change the ID for the system event (ie. PlaneGear, PlaneAirbake, etc.) according to the system you would like to model and develop some additional rules to each system the more advanced you make it, but this should help. Check this for control systems if you have direct linkage controls: https://pastebin.com/fAHHGp53 Link to comment Share on other sites More sharing options...
J900 Posted August 1, 2019 Author Share Posted August 1, 2019 Thanks will get studying...:book: Link to comment Share on other sites More sharing options...
J900 Posted August 1, 2019 Author Share Posted August 1, 2019 The guide is brilliant thank you!:thumbup: Link to comment Share on other sites More sharing options...
fl0w Posted August 1, 2019 Share Posted August 1, 2019 Glad that I was able to help! :D Feel free to pop any more questions at me to be answered. Link to comment Share on other sites More sharing options...
J900 Posted August 2, 2019 Author Share Posted August 2, 2019 Got landing gear working at last :beer: now to get the remaining systems working and tailor them to the aircraft...:book: Link to comment Share on other sites More sharing options...
J900 Posted August 3, 2019 Author Share Posted August 3, 2019 Link to comment Share on other sites More sharing options...
fl0w Posted August 3, 2019 Share Posted August 3, 2019 Looking good! Link to comment Share on other sites More sharing options...
Recommended Posts