Jump to content

DCS Mods structure : How to create your plugin from scratch


Recommended Posts

The scale of the pilot looks a wee-bit too small. Could just be me, though.

 

it is, and his face is messed up from the bones rigging. ( remember that Hot Shots scene after landing and pilot took off mask and his face was the shape of the mask, lol, yeah.)

 

Basically I just ported the pilot from a previous aborted project,

 

he will be replaced w/ properly scaled, rigged and Animated pilot after the external model work and scripting is done.

 

I also have to re-vamp the FPU-11 Tanks and ARS Tank, and Finish Animating the ALQ-99 Pods and Integrate them into the base model instead of a separate object.

Windows 10 Pro, Ryzen 2700X @ 4.6Ghz, 32GB DDR4-3200 GSkill (F4-3200C16D-16GTZR x2),

ASRock X470 Taichi Ultimate, XFX RX6800XT Merc 310 (RX-68XTALFD9)

3x ASUS VS248HP + Oculus HMD, Thrustmaster Warthog HOTAS + MFDs

Link to comment
Share on other sites

  • 4 weeks later...

Quick question.

 

We're animating some knobs, like a simple volume knob.

 

I'm using default_axis_limited, with the range limiter set {0,1} which matches the animation of the control.

 

My question is this:

 

When we use this setup in clickabledata.lua, if I grab it with the mouse button and move it, everything works normally.

 

However, if I use the mouse scrollwheel, it'll wrap past 0 and jump to the 1 position. The only thing I've found so far that "works" is to set the range to {-1,1} and issue a dev:performClickableAction() to set it back to 0 or 1 if it exceeds the range.

 

Is this the "correct" way to do this?

 

For reference, here's the current handler:

 

    elseif command == device_commands.tacan_volume then
       tacan_volume = value
       if tacan_volume < -0.5 then
           dev:performClickableAction(device_commands.tacan_volume, 1, false)  -- bound check to fix wrap
       elseif tacan_volume < 0 and tacan_volume > -0.5 then
           dev:performClickableAction(device_commands.tacan_volume, 0, false)  -- bounds check to fix wrap
       end

 

and here's the control definition:

 

elements["PNT_903"] = default_axis_limited("TACAN Volume", devices.NAV, device_commands.tacan_volume, 903, 0.0, 0.3, false, false, {-1,1} )

 

Every other variation of updatable and relative don't seem to behave as expected.

 

Thoughts? (BTW, is there an explanation of exactly what updatable_ and relative_ do?)

 

--gos

Link to comment
Share on other sites

I will check once I get home from work, but in general I use code to enforce the animation state just like you did in your post. It's probably not the most efficient but it works fine.

DCS AJS37 HACKERMAN

 

There will always be bugs. If everything is a priority nothing is.

Link to comment
Share on other sites

I will check once I get home from work, but in general I use code to enforce the animation state just like you did in your post. It's probably not the most efficient but it works fine.

 

Thanks.

 

I guess I am not sure then exactly what _limit = {0,1} is actually limiting, if not the range of values the parameter can receive. It seems to be more of a final filter provided to the code AFTER various engine calculations are done, versus a direct input limiter.

Link to comment
Share on other sites

I only have this:

elements["AltsetL-PTR"] = default_axis_limited(_("Altimeter setting"),devices.FLIGHTDATAUNIT, 3306, 0, 0.001, false, false, 1)

It works both for dragging and mousewheel, but it is unlimited and that's probably not what you are looking for I guess. Try enforcing the animation in code as well... :/

 

Updatable might mean that it accepts enforcment from the code...

 

EDIT:

You might try

function multiposition_switch_limited(hint_,device_,command_,arg_,count_,delta_,inversed_,min_)

with discrete steps. A large enough number of steps might not be noticeable, we humans are not very good at noticing small differences in sound volume.


Edited by RagnarDa

DCS AJS37 HACKERMAN

 

There will always be bugs. If everything is a priority nothing is.

Link to comment
Share on other sites

  • 2 weeks later...

when defining a system and animations.

 

is "get_cockpit_draw_argument_value"

 

A valid string?

 

I'd be nice to set some external animations based off a Cockpit Argument Value.

 

ie:

 


local KNOBA_POS = get_cockpit_draw_argument_value(xx)  -- Where XX = Cockpit Rotary Knob
local SWITCHA_POS = get_cockpit_draw_argument_value(xx)  -- Where XX = Cockpit System On/Off Knob

Then Define Options for System

if SWITCHA_POS = 1 and KNOBA_POS > 0 then
Set_Aircraft_Draw_Argument_Value(xx, KNOBA_POS): --Where XX Here is an Aircraft Argument that has a Dynamic Movement based off knob position)
elseif SWITCHA_POS = 0 then
Set_Aircraft_Draw_Argument_Value(xx, 0.0): --Where XX Here is an Aircraft Argument that has a Dynamic Movement based off knob position, But if System is OFF, Knob Has no effect)
end

 

 

edit: nope, doesnt work, the local names arent read and the LUA Reading stops at get_cockpit_draw_value line.

 

Guess that answers that question.


Edited by SkateZilla

Windows 10 Pro, Ryzen 2700X @ 4.6Ghz, 32GB DDR4-3200 GSkill (F4-3200C16D-16GTZR x2),

ASRock X470 Taichi Ultimate, XFX RX6800XT Merc 310 (RX-68XTALFD9)

3x ASUS VS248HP + Oculus HMD, Thrustmaster Warthog HOTAS + MFDs

Link to comment
Share on other sites

when defining a system and animations.

 

is "get_cockpit_draw_argument_value"

 

A valid string?

 

I'd be nice to set some external animations based off a Cockpit Argument Value.

 

Correct. You cannot query the current state of a cockpit control.

 

You map a device controller to the animation, and when it's triggered and parsed in SetCommand(), you have to record the data provided by the animated value.

 

Then, you can update your external argument based on this input.

 

One annoyance of this mechanism is that animated cockpit objects do not register their commands until the animation finishes. With slowed animations for larger cockpit levers, the lag can be a bit annoying as it also throttles keyboard triggering of the same things, depending on how its coded internally.

 

--gos

Link to comment
Share on other sites

You read the options in code and then perform whatever is necessary. No clue how to read the options in lua though.

 

Here is my guide on it:

 

http://pastebin.com/WQ9T5tBS

 

Using SilentEagle's example, I did some digging, and figured out how to extract ME aircraft options in lua.

 

First, create your properties in your base .lua file as needed (I used his example above)

 

Then, you simply query the values directly by name using get_aircraft_property():

 

    mr = get_aircraft_property("CheckboxPlaceholder")
   print("MR CheckboxPlaceholder: "..mr)

   mr = get_aircraft_property("MassChangePlaceholder")
   print("MR MassChangePlaceholder: "..mr)

   mr = get_aircraft_property("CombolistPlaceholder")
   print("MR CombolistPlaceholder: "..mr)

   mr = get_aircraft_property("SliderPlaceholder")
   print("MR SliderPlaceholder: "..mr)

 

The above code was in one of my post initialization functions just for convenience, but I don't think that matters.

 

And it results in output such as:

 

00065.206 DEBUG   C:\Users\xxx\Saved Games\DCS.openalpha\Mods/aircraft/A-4E/C: MR CheckboxPlaceholder: 0
00065.206 DEBUG   C:\Users\xxx\Saved Games\DCS.openalpha\Mods/aircraft/A-4E/C: MR MassChangePlaceholder: 1
00065.206 DEBUG   C:\Users\xxx\Saved Games\DCS.openalpha\Mods/aircraft/A-4E/C: MR CombolistPlaceholder: 1
00065.206 DEBUG   C:\Users\xxx\Saved Games\DCS.openalpha\Mods/aircraft/A-4E/C: MR SliderPlaceholder: 80

 

Note that I had unchecked the first box (0), checked the 2nd box (1), selected 'ITEM2' from the list (2nd item, which would be index 1 in "C" code), and I set the slider to 80.

 

--gos

 

Edit: Apparently gyrovague figured this out too, told me, and I wasn't paying attention haha. Sorry for stealing the karma.


Edited by gospadin
Link to comment
Share on other sites

Using SilentEagle's example, I did some digging, and figured out how to extract ME aircraft options in lua.

 

First, create your properties in your base .lua file as needed (I used his example above)

 

Then, you simply query the values directly by name using get_aircraft_property():

 

    mr = get_aircraft_property("CheckboxPlaceholder")
   print("MR CheckboxPlaceholder: "..mr)

   mr = get_aircraft_property("MassChangePlaceholder")
   print("MR MassChangePlaceholder: "..mr)

   mr = get_aircraft_property("CombolistPlaceholder")
   print("MR CombolistPlaceholder: "..mr)

   mr = get_aircraft_property("SliderPlaceholder")
   print("MR SliderPlaceholder: "..mr)

 

The above code was in one of my post initialization functions just for convenience, but I don't think that matters.

 

And it results in output such as:

 

00065.206 DEBUG   C:\Users\xxx\Saved Games\DCS.openalpha\Mods/aircraft/A-4E/C: MR CheckboxPlaceholder: 0
00065.206 DEBUG   C:\Users\xxx\Saved Games\DCS.openalpha\Mods/aircraft/A-4E/C: MR MassChangePlaceholder: 1
00065.206 DEBUG   C:\Users\xxx\Saved Games\DCS.openalpha\Mods/aircraft/A-4E/C: MR CombolistPlaceholder: 1
00065.206 DEBUG   C:\Users\xxx\Saved Games\DCS.openalpha\Mods/aircraft/A-4E/C: MR SliderPlaceholder: 80

 

Note that I had unchecked the first box (0), checked the 2nd box (1), selected 'ITEM2' from the list (2nd item, which would be index 1 in "C" code), and I set the slider to 80.

 

--gos

 

Edit: Apparently gyrovague figured this out too, told me, and I wasn't paying attention haha. Sorry for stealing the karma.

 

 

So for items like Solo Flight or Remove hardpoints you'd have a line for set_argument as well?

(Well the hardpoints use a different function, but for animation / setting sake.).

 

ie:

    mr = get_aircraft_property("CheckboxPlaceholder")
   set_aircraft_draw_argument_value(xx, value)
   print("MR CheckboxPlaceholder: "..mr)

 

 

 

I placed the:

    mr = get_aircraft_property("CheckboxPlaceholder")
   print("MR CheckboxPlaceholder: "..mr)

 

Outside of the Make_Aircraft in the Aircraft Data

And Got this:

00007.941 ALERT DCS: Error running Scripts/Database/db_scan.lua: [string "./CoreMods/aircraft/TEST_AIRCRAFT/Entry/TEST_AIRCRAFT.lua"]:750: attempt to call global 'get_aircraft_property' (a nil value)

 

 

 

On Another Note:

The one thing I'm still trying to do is define custom animations in a separate LUA for the AI to use.

 

ie,

-Custom Surface Deflections for based on Speed, AoA, Airbrakes Deploy, Landing Gear, Flaps etc.

-Custom Door Animations for AUX ECS Intake doors based on Speed and Landing Gear Status

-RAT RPM Based on Speed

 

Etc etc

 

I have some scripted for when I use the support cockpit, but trying to link to AI use is not working out, lol.

 

Seems defining local <command> anything in the aircraft's data lua causes it to stop at that line.,

 

That and trying to define a local category for the loadout menu.. lol.


Edited by SkateZilla

Windows 10 Pro, Ryzen 2700X @ 4.6Ghz, 32GB DDR4-3200 GSkill (F4-3200C16D-16GTZR x2),

ASRock X470 Taichi Ultimate, XFX RX6800XT Merc 310 (RX-68XTALFD9)

3x ASUS VS248HP + Oculus HMD, Thrustmaster Warthog HOTAS + MFDs

Link to comment
Share on other sites

I placed the:

    mr = get_aircraft_property("CheckboxPlaceholder")
   print("MR CheckboxPlaceholder: "..mr)

 

Outside of the Make_Aircraft in the Aircraft Data

And Got this:

00007.941 ALERT DCS: Error running Scripts/Database/db_scan.lua: [string "./CoreMods/aircraft/TEST_AIRCRAFT/Entry/TEST_AIRCRAFT.lua"]:750: attempt to call global 'get_aircraft_property' (a nil value)

 

As I mentioned, I had done it in one of the systems quanta post_initialize() functions and it was in scope there. The scope at module creation vs execution I don't know.

 

Which means I don't know how to get AI to use the data you setup there. It only works for players in the way I figured it out.

Link to comment
Share on other sites

ahh, Gotcha.

 

Will continue looking for AI then, since the AddProps all work for Aircraft even when not Installed, so parameters must be stored something in the core of DCS

 

I did figure out the external hardpoints checkbox and that works now for AI, but the rest, not so much.


Edited by SkateZilla

Windows 10 Pro, Ryzen 2700X @ 4.6Ghz, 32GB DDR4-3200 GSkill (F4-3200C16D-16GTZR x2),

ASRock X470 Taichi Ultimate, XFX RX6800XT Merc 310 (RX-68XTALFD9)

3x ASUS VS248HP + Oculus HMD, Thrustmaster Warthog HOTAS + MFDs

Link to comment
Share on other sites

AddPropAircraft = {
	{ id = "SoloFlight",    	 control = 'checkbox' , label = _('Solo Flight')			   , defValue = false, weightWhenOn = -80},
	},

 

 

This Property will when Checked:

-Subtract 80KG from Aircraft Weight

-Remove Instructor Pilot Body from Cockpit

 

Instructor Body Argument is in the LUA, Under the Pilot/Co Pilot Crew Data String:

pilot_body_arg		= xx,

 

 

So Far I have gotten Hardpoints Edit Checkbox and Solo Pilot to Work fine without scripting additional commands/code.

 

Hardpoints Checkbox will reset all hardpoint arguments to 0.0 (Pylons Off). Those Arguments are defined in the Pylon Data Strings.

 

Still working on other things (Exhaust Suppressor, etc) But I'm Pretty sure they are tied to an Arg the same way the Hardpoints and Pilot are.

Windows 10 Pro, Ryzen 2700X @ 4.6Ghz, 32GB DDR4-3200 GSkill (F4-3200C16D-16GTZR x2),

ASRock X470 Taichi Ultimate, XFX RX6800XT Merc 310 (RX-68XTALFD9)

3x ASUS VS248HP + Oculus HMD, Thrustmaster Warthog HOTAS + MFDs

Link to comment
Share on other sites

Vehicle question for anyone who might know - top speed and acceleration and gear ratios - how does it work? Any clues?

 

Some obvious ones -

 

max_road_velocity = 72.2222, --260kph

max_acceleration = 4, --about 0-100kph in approx. 4-5secs

 

But then the gear ratios

 

X_gear_1 = 3.636,

Y_gear_1 = 0,

Z_gear_1 = 0.842,

X_gear_2 = -1.215,

Y_gear_2 = 0,

Z_gear_2 = 0.769,

 

I assume gear_1 are forward gears and X is probably first and Z is top and gear_2 is reverse???

 

Can anyone explain these parameters at all?

 

Does r_max affect top speed and how fast you get there?

 

 

Best I seem to be able to get is about 130 kph and it takes quite a while to get there.

 

Thanks,

Stonehouse


Edited by Stonehouse
Link to comment
Share on other sites

theres 2 gears, 1st is forward, 2nd is backwards,

 

X,Y,Z are the axes of movement and/or rotation, and the value is likely torque or some form of power transfer.

Windows 10 Pro, Ryzen 2700X @ 4.6Ghz, 32GB DDR4-3200 GSkill (F4-3200C16D-16GTZR x2),

ASRock X470 Taichi Ultimate, XFX RX6800XT Merc 310 (RX-68XTALFD9)

3x ASUS VS248HP + Oculus HMD, Thrustmaster Warthog HOTAS + MFDs

Link to comment
Share on other sites

Does anyone know how to adjust line width when using ceSimpleLineObject? I'm trying to use lines with my HUD experiment. I tried .width and .offset without luck. All I get is 1px width for a line.

System:

Windows 10 | i7-7700K @ 4.5 Ghz | 32GB of RAM | Nvidia GTX 1080, 3440x1440 | DELL Ultrawide U3415W | Samsung 960 Evo M.2 and 2 TB Seagate Barracuda | TM Warthog Hotas | SLAW F-16 Pedals | Oculus Rift CV1 and HTC Vive PRO VR

 

+ High fidelity F/A-18C simpit :)

Link to comment
Share on other sites

  • 2 weeks later...

Hello, there are lines in "Wunderluft.lua" :

has_afteburner 				= true, -- AFB yes/no
has_speedbrake 				= true, -- Speedbrake yes/no

 

They activate "afteburner" and "speedbrake".

 

What lines need to write in "Wunderluft.lua" in order to activate functions: (tail hook, folding wing, sweep wing)? My model is animated, and working in "ModelViewer" but tail hook is not working in the game.

Flying is for droids.

Полёты - это для дроидов.

Link to comment
Share on other sites

Hello, there are lines in "Wunderluft.lua" :

has_afteburner 				= true, -- AFB yes/no
has_speedbrake 				= true, -- Speedbrake yes/no

 

They activate "afteburner" and "speedbrake".

 

What lines need to write in "Wunderluft.lua" in order to activate functions: (tail hook, folding wing, sweep wing)? My model is animated, and working in "ModelViewer" but tail hook is not working in the game.

 

For the Tail Hook:

You have to script the systems for it, and make it carrier capable:

For Example:

	--[[ Define Runway Categories ]]--
	LandRWCategories = 
       {[1] = {Name = "AircraftCarrier",},},
	TakeOffRWCategories = 
       {[1] = {Name = "AircraftCarrier With Catapult",},},

 

 

For the Wings, you have to set the Correct Type:

wing_type = 1

 

FIXED_WING = 0

VARIABLE_GEOMETRY = 1

FOLDED_WING = 2

VARIABLE_GEOMETRY_FOLDED = 3


Edited by SkateZilla
  • Like 1

Windows 10 Pro, Ryzen 2700X @ 4.6Ghz, 32GB DDR4-3200 GSkill (F4-3200C16D-16GTZR x2),

ASRock X470 Taichi Ultimate, XFX RX6800XT Merc 310 (RX-68XTALFD9)

3x ASUS VS248HP + Oculus HMD, Thrustmaster Warthog HOTAS + MFDs

Link to comment
Share on other sites

  • 2 weeks later...

ok I know I'm overlooking it here, but Where's the mech timing line for the Landing gear / AI Draws?

 

 

I have MechTiming for the CanopySet using:

			mech_timing = 	{{0.0, 1 / 6.5}, -- CANOPY_OPEN_TIMES
						{0.0, 1 / 6.700}, -- CANOPY_CLOSE_TIMES
						},

 

But I need to set timings for other animations...

ie

mech_timing[LandingGearDeploy]= 

 

 

the DefaultLUA Lists:

-- Default timing data for mechanical parts animation.

 

-- Entries with non-default indexes are deprecated,

-- please add any custom mech data into 'mech_timing' section of the aircraft db entry.

 

DefMechTimeIdx = 0

 

--------------------------------------------------------

-- The format:

-- the each end-table consists of pairs of values - animation stage and

-- animation speed (units - arg values, [0..1] as a rule)

 

mech_timing = {}

mech_timing[DefMechTimeIdx] = {{0.0, 1 / 9}, -- CANOPY_OPEN_TIMES

{0.0, 1 / 6} -- CANOPY_CLOSE_TIMES

}

 

 

I also need to define some custom animation parameters for the AI (ie Speedbrake/Gear etc).

Is there a way to do that?


Edited by SkateZilla

Windows 10 Pro, Ryzen 2700X @ 4.6Ghz, 32GB DDR4-3200 GSkill (F4-3200C16D-16GTZR x2),

ASRock X470 Taichi Ultimate, XFX RX6800XT Merc 310 (RX-68XTALFD9)

3x ASUS VS248HP + Oculus HMD, Thrustmaster Warthog HOTAS + MFDs

Link to comment
Share on other sites

If can be of any help, function from:

local sensor_data = get_base_data()

getAngleOfAttack
getAngleOfSlide
getBarometricAltitude
getCanopyPos
getCanopyState
getEngineLeftFuelConsumption
getEngineLeftRPM
getEngineLeftTemperatureBeforeTurbine
getEngineRightFuelConsumption
getEngineRightRPM
getEngineRightTemperatureBeforeTurbine
getFlapsPos
getFlapsRetracted
getHeading
getHelicopterCollective
getHelicopterCorrection
getHorizontalAcceleration
getIndicatedAirSpeed
getLandingGearHandlePos
getLateralAcceleration
getLeftMainLandingGearDown
getLeftMainLandingGearUp
getMachNumber
getMagneticHeading
getNoseLandingGearDown
getNoseLandingGearUp
getPitch
getRadarAltitude
getRateOfPitch
getRateOfRoll
getRateOfYaw
getRightMainLandingGearDown
getRightMainLandingGearUp
getRoll
getRudderPosition
getSpeedBrakePos
getStickPitchPosition
getStickRollPosition
getThrottleLeftPosition
getThrottleRightPosition
getTotalFuelWeight
getTrueAirSpeed
getVerticalAcceleration
getVerticalVelocity
getWOW_LeftMainLandingGear
getWOW_NoseLandingGear
getWOW_RightMainLandingGear

 

 

Has This been expanded since 2012? there are Parameters I'd like to load, but arent on that list

Windows 10 Pro, Ryzen 2700X @ 4.6Ghz, 32GB DDR4-3200 GSkill (F4-3200C16D-16GTZR x2),

ASRock X470 Taichi Ultimate, XFX RX6800XT Merc 310 (RX-68XTALFD9)

3x ASUS VS248HP + Oculus HMD, Thrustmaster Warthog HOTAS + MFDs

Link to comment
Share on other sites

  • 1 month later...
when defining a system and animations.

 

is "get_cockpit_draw_argument_value"

 

A valid string?

 

I'd be nice to set some external animations based off a Cockpit Argument Value.

 

 

get_cockpit_draw_argument_value works fine for me (at least inside an avLuaDevice instance), I use it to do exactly what you describe above (update another draw argument based on the position of a cockpit draw argument).

 

AFAICT, these are all valid functions:

get_aircraft_draw_argument_value
set_aircraft_draw_argument_value
get_cockpit_draw_argument_value

Note that there is no set_cockpit_draw_argument_value, AFAIK you can only set them indirectly via parameter gauges.

____________

Heatblur Simulations

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

Has This been expanded since 2012? there are Parameters I'd like to load, but arent on that list

 

Just duplicating what I said on discord on 2016-11-23:

If I dump the functions from get_base_data in DCS, I get the following:

getAngleOfAttack
getAngleOfSlide
getBarometricAltitude
getCanopyPos
getCanopyState
getEngineLeftFuelConsumption
getEngineLeftRPM
getEngineLeftTemperatureBeforeTurbine
getEngineRightFuelConsumption
getEngineRightRPM
getEngineRightTemperatureBeforeTurbine
getFlapsPos
getFlapsRetracted
getHeading
getHelicopterCollective
getHelicopterCorrection
getHorizontalAcceleration
getIndicatedAirSpeed
getLandingGearHandlePos
getLateralAcceleration
getLeftMainLandingGearDown
getLeftMainLandingGearUp
getMachNumber
getMagneticHeading
getNoseLandingGearDown
getNoseLandingGearUp
getPitch
getRadarAltitude
getRateOfPitch
getRateOfRoll
getRateOfYaw
getRightMainLandingGearDown
getRightMainLandingGearUp
getRoll
getRudderPosition
getSelfAirspeed
getSelfCoordinates
getSelfVelocity
getSpeedBrakePos
getStickPitchPosition
getStickRollPosition
getThrottleLeftPosition
getThrottleRightPosition
getTotalFuelWeight
getTrueAirSpeed
getVerticalAcceleration
getVerticalVelocity
getWOW_LeftMainLandingGear
getWOW_NoseLandingGear
getWOW_RightMainLandingGear

 

I think the only new ones compared to the list you gave are:

getSelfAirspeed
getSelfCoordinates
getSelfVelocity

____________

Heatblur Simulations

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

  • 2 weeks later...
  • Recently Browsing   0 members

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