Jump to content

DCS Mods structure : How to create your plugin from scratch


Alex Okean
 Share

Recommended Posts

Hopefully that changes.

 

Ive searched and searched for the predefined parameters and came up empty.

 

ie theres likely a tankers table somewhere with world id, position and min/max rotation.

 

even then the AI connects to the pre defined point regardless of basket drift.

 

So if plane is in race track turn and basked drifts inward/left, AI will connect to the right of the basket.

 

Id rather define a table for position and simply use a connector name instead of coordinates.

Windows 10 Pro, Ryzen 2700X @ 4.6Ghz, 32GB DDR4-3200 GSkill,

X470 Taichi Ultimate, 2x R7970 Lightnings Crossfired @ 1.1/6.0GHz,

3x ASUS VS248HP + Hanns·G HZ201HPB + Oculus HMD,

Thrustmaster Warthog HOTAS + MFDs, CH Fighterstick+Pro Throttle+Pro Pedals

Link to comment
Share on other sites

  • Replies 487
  • Created
  • Last Reply

Top Posters In This Topic

Having Some issues defining new WeaponTypes..

 

Im Basically taking the -E Specs and Warhead and Giving it the -D Head..

 

But it's not showing up in the Loadout, and yes I've added it to the Pylon Data.


Edited by SkateZilla

Windows 10 Pro, Ryzen 2700X @ 4.6Ghz, 32GB DDR4-3200 GSkill,

X470 Taichi Ultimate, 2x R7970 Lightnings Crossfired @ 1.1/6.0GHz,

3x ASUS VS248HP + Hanns·G HZ201HPB + Oculus HMD,

Thrustmaster Warthog HOTAS + MFDs, CH Fighterstick+Pro Throttle+Pro Pedals

Link to comment
Share on other sites

Edit:

Nevermind I found the Problem,

 

Missing "," after:

category = CAT_MISSILES

 

 

And:

warhead = warheads["AGM_65E"],

 

Should have been:

warhead = predefined_warhead("AGM_65E"),

 

 

All good and Working now :-)

Windows 10 Pro, Ryzen 2700X @ 4.6Ghz, 32GB DDR4-3200 GSkill,

X470 Taichi Ultimate, 2x R7970 Lightnings Crossfired @ 1.1/6.0GHz,

3x ASUS VS248HP + Hanns·G HZ201HPB + Oculus HMD,

Thrustmaster Warthog HOTAS + MFDs, CH Fighterstick+Pro Throttle+Pro Pedals

Link to comment
Share on other sites

Too many times I would spend an embarrassingly large amount of time wondering why DCS wouldn't start or a script wasn't working because of missing punctuation or grouping. At least the log will point you in the right path.

i7 7700K | 32GB RAM | GTX 1080Ti | Rift CV1 | TM Warthog | Win 10

 

"There will always be people with a false sense of entitlement.

You can want it, you can ask for it, but you don't automatically deserve it. "

Link to comment
Share on other sites

Too many times I would spend an embarrassingly large amount of time wondering why DCS wouldn't start or a script wasn't working because of missing punctuation or grouping. At least the log will point you in the right path.

 

Yeah,

Would Launch DCS, No Store in Aircraft,

Close, Scan quickly, Relaunch,

 

then when I pasted here, I noticed no Comma,

So I added a Comma, Launched DCS, DCS Process Terminates,

Check Logs, and Noticed that the warhead = line is scanning DB_Mods for the wrong warheads_table,

So I scroll db mods file to get the correct table/command which was not warhead = warheads["Name"], but warhead = predefined_warhead("name")

 

After that everything was gravy and the AI spams the Mavericks w/ no problems at ground targets.

 

Now I can remove all the Redundant versions from other Branches (-Ds, -E's and -Hs)

And Script the TGM and CATM versions of the -F

 

attachment.php?attachmentid=148219&stc=1&d=1473778126

 

attachment.php?attachmentid=148220&stc=1&d=1473778126


Edited by SkateZilla

Windows 10 Pro, Ryzen 2700X @ 4.6Ghz, 32GB DDR4-3200 GSkill,

X470 Taichi Ultimate, 2x R7970 Lightnings Crossfired @ 1.1/6.0GHz,

3x ASUS VS248HP + Hanns·G HZ201HPB + Oculus HMD,

Thrustmaster Warthog HOTAS + MFDs, CH Fighterstick+Pro Throttle+Pro Pedals

Link to comment
Share on other sites

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

i7 7700K | 32GB RAM | GTX 1080Ti | Rift CV1 | TM Warthog | Win 10

 

"There will always be people with a false sense of entitlement.

You can want it, you can ask for it, but you don't automatically deserve it. "

Link to comment
Share on other sites

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,

X470 Taichi Ultimate, 2x R7970 Lightnings Crossfired @ 1.1/6.0GHz,

3x ASUS VS248HP + Hanns·G HZ201HPB + Oculus HMD,

Thrustmaster Warthog HOTAS + MFDs, CH Fighterstick+Pro Throttle+Pro Pedals

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,

X470 Taichi Ultimate, 2x R7970 Lightnings Crossfired @ 1.1/6.0GHz,

3x ASUS VS248HP + Hanns·G HZ201HPB + Oculus HMD,

Thrustmaster Warthog HOTAS + MFDs, CH Fighterstick+Pro Throttle+Pro Pedals

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,

X470 Taichi Ultimate, 2x R7970 Lightnings Crossfired @ 1.1/6.0GHz,

3x ASUS VS248HP + Hanns·G HZ201HPB + Oculus HMD,

Thrustmaster Warthog HOTAS + MFDs, CH Fighterstick+Pro Throttle+Pro Pedals

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,

X470 Taichi Ultimate, 2x R7970 Lightnings Crossfired @ 1.1/6.0GHz,

3x ASUS VS248HP + Hanns·G HZ201HPB + Oculus HMD,

Thrustmaster Warthog HOTAS + MFDs, CH Fighterstick+Pro Throttle+Pro Pedals

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,

X470 Taichi Ultimate, 2x R7970 Lightnings Crossfired @ 1.1/6.0GHz,

3x ASUS VS248HP + Hanns·G HZ201HPB + Oculus HMD,

Thrustmaster Warthog HOTAS + MFDs, CH Fighterstick+Pro Throttle+Pro Pedals

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,

X470 Taichi Ultimate, 2x R7970 Lightnings Crossfired @ 1.1/6.0GHz,

3x ASUS VS248HP + Hanns·G HZ201HPB + Oculus HMD,

Thrustmaster Warthog HOTAS + MFDs, CH Fighterstick+Pro Throttle+Pro Pedals

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,

X470 Taichi Ultimate, 2x R7970 Lightnings Crossfired @ 1.1/6.0GHz,

3x ASUS VS248HP + Hanns·G HZ201HPB + Oculus HMD,

Thrustmaster Warthog HOTAS + MFDs, CH Fighterstick+Pro Throttle+Pro Pedals

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...