Notices

Reply
 
Thread Tools Display Modes
Old 05-25-2012, 09:40 PM   #1
Alex O'kean
ED Team
 
Alex O'kean's Avatar
 
Join Date: Jul 2004
Location: Борисоглебск - Москва
Posts: 573
Reputation power: 25
Alex O'kean is a glorious beacon of lightAlex O'kean is a glorious beacon of lightAlex O'kean is a glorious beacon of lightAlex O'kean is a glorious beacon of lightAlex O'kean is a glorious beacon of lightAlex O'kean is a glorious beacon of lightAlex O'kean is a glorious beacon of lightAlex O'kean is a glorious beacon of lightAlex O'kean is a glorious beacon of lightAlex O'kean is a glorious beacon of light
Send a message via ICQ to Alex O'kean Send a message via Skype™ to Alex O'kean
Default DCS Mods structure : How to create your plugin from scratch

By default DCS scanning two folder : Mods/aircrafts Mods/tech. as aircraft addon and ground vehicles respectively.
scan is recursive ,

for each founded folder system tries execute entry.lua file.

If it exist scanning of this folder is stopped and only entry.lua is executed , otherwise it will execute all founded lua's in folder and doing the same for subfolders.

all files are executed in safe environment with restricted access to database and functions

basic lua functionality available
Code:
table       
pairs  
ipairs 
type  
assert  
print
math 
tostring   
dofile       -- safe enveronment version 
loadfile
current_mod_path  -- path of your plugin 


-- localization  using gettext : 
 _(string)   -- i.e.   localized_string = _("ENGLISH SENTENCE STRING")
  
-- mounting shapes and textures libraries 
mount_vfs_model_path   (current_mod_path..'/Shapes/MyZipOrFolder')
mount_vfs_texture_path (current_mod_path..'/Textures/MyZipOrFolder')
mount_vfs_liveries_path (current_mod_path..'/Liveries')
plugin declaration must be started by calling
Code:
declare_plugin(unique_plugin_id,info_table)
as sample:
Code:
declare_plugin("My Mod maded by Me",
{
installed 	 = true, -- if false that will be place holder , or advertising
dirName	  	 = current_mod_path,
fileMenuName = _("My Mod"), -- for mission editor 
version		 = "1.1.2.0",
state		 = "installed", 
info		 = _("Short info about me and my application"),
--collection of binaries which will be asociated with my plugin
binaries 	 =
{
'FM_plugin',			
'Cockpit_dll_1', 
'Cockpit_dll_2'
},
--collection of input profiles 
InputProfiles =
{
    ["PLANE NAME"]      = current_mod_path .. '/Input/hardcore',
    ["PLANE NAME_easy"] = current_mod_path .. '/Input/easy',  
},
-- skin for mission editor , see sample for P-51 , A-10C etc
Skins	=
	{
		{
			name	= _("My Mod"),
			dir		= "Skins/1"
		},
	},
--missions and campaigns
Missions =
	{
		{
			name		= _("My Mod"),
			dir			= "Missions",
			CLSID		= "{CLSIDCLSIID}",		
		},
	},	
-- options related to my plugin
Options = 
	{
		{
			name		= _("My Mod"),
			nameId		= "My Mod",
			dir			= "Options",
			CLSID		= "{0394EC1E-3C24-4ed5-8F13-CD90FF9091A5}"
		},
	},
-- logbook entry
LogBook =
	{
		{
			name		= _("My Mod"),
			type		= "My Mod",
		},
	},		
-- precache resources 
preload_resources = 
	{
		textures   = {},
		models     = {"tracer_bullet_a-10", "shell_50cal", "tracer_bullet_red", "sled"},
		fonts      = {},
		explosions = {},
	},
})

-- the  body of your plugin must be placed here

-- declaration of plugin finished by calling plugin_done()
plugin_done()

adding new aircraft with cockpit bells and whistles
i attached simple prototype package which will add aircraft named Wunderluft as newly object with cockpit . I will use it to explain basic available at current moment features ( features will be continiously growth i hope )
NOTE : At present moment you only able to create SFM based aicraft, support for third party FM binary packages is planned.

Let's start
each plugin can add several objects at once

Code:
add_aircraft(table_with_aircraft_data_1)
add_aircraft(table_with_aircraft_data_2)
arcraft table should have all data needed for mission editor and simulation
some notes :
if you open Wunderluft.lua you will see WSTYPE_PLACEHOLDER entry , it means that database will automatically change it to first available index for aircraft .
and it means that maximum available aircraft types in simulator is limited to 256 ! this will be fixed in future.
SFM and engine data should match each other in terms of aircraft perfomance , for example you must be targeted to known perfomance data as maximum turn rate , climb rate but simple placing 13000 kg of thrust to Su-27

ASAP i will give you detailed instructions of each aspect , and now i will go to bed , good night for all .
Attached Files
File Type: zip Wunderluft.zip (4.69 MB, 1837 views)
__________________

Last edited by Alex O'kean; 05-29-2012 at 09:07 PM.
Alex O'kean is offline   Reply With Quote
Old 05-26-2012, 12:55 AM   #2
HungaroJET
Senior Member
 
HungaroJET's Avatar
 
Join Date: Jan 2005
Location: Budapest, Hungary
Posts: 1,204
Reputation power: 50
HungaroJET is a splendid one to beholdHungaroJET is a splendid one to beholdHungaroJET is a splendid one to beholdHungaroJET is a splendid one to beholdHungaroJET is a splendid one to beholdHungaroJET is a splendid one to beholdHungaroJET is a splendid one to beholdHungaroJET is a splendid one to beholdHungaroJET is a splendid one to beholdHungaroJET is a splendid one to beholdHungaroJET is a splendid one to beholdHungaroJET is a splendid one to behold
Question

Thank you Alex

I have one question: can we change textures by model arguments and values in liveries//description.lua just like in FC2 .skins files ?
__________________
Atop the midnight tarmac,
a metal beast awaits.
To be flown below the radar,
to bring the enemy his fate.


HAVE A BANDIT DAY !

HungaroJET is offline   Reply With Quote
Old 05-26-2012, 05:28 AM   #3
PeterP
Veteran
 
PeterP's Avatar
 
Join Date: Mar 2009
Location: Germany / UTC+1
Posts: 5,174
Reputation power: 97
PeterP is a splendid one to beholdPeterP is a splendid one to beholdPeterP is a splendid one to beholdPeterP is a splendid one to beholdPeterP is a splendid one to beholdPeterP is a splendid one to beholdPeterP is a splendid one to beholdPeterP is a splendid one to beholdPeterP is a splendid one to beholdPeterP is a splendid one to beholdPeterP is a splendid one to beholdPeterP is a splendid one to behold
Default

Thanks for the in-sight - Bookmarked this thread!
__________________

PeterP is offline   Reply With Quote
Old 05-26-2012, 08:32 AM   #4
Silver_Dragon
Veteran
 
Silver_Dragon's Avatar
 
Join Date: Apr 2005
Location: Arafo, Tenerife, Canary Islands, Spain
Posts: 3,764
Reputation power: 36
Silver_Dragon is a name known to allSilver_Dragon is a name known to allSilver_Dragon is a name known to allSilver_Dragon is a name known to allSilver_Dragon is a name known to allSilver_Dragon is a name known to allSilver_Dragon is a name known to allSilver_Dragon is a name known to allSilver_Dragon is a name known to allSilver_Dragon is a name known to allSilver_Dragon is a name known to all
Send a message via MSN to Silver_Dragon Send a message via Skype™ to Silver_Dragon
Default

great adition.... looking for more
__________________
More news to the front

Spanish 4Th Perrus Squadon Member: http://www.4thperrus.com
Silver_Dragon is offline   Reply With Quote
Old 05-26-2012, 07:21 PM   #5
Alex O'kean
ED Team
 
Alex O'kean's Avatar
 
Join Date: Jul 2004
Location: Борисоглебск - Москва
Posts: 573
Reputation power: 25
Alex O'kean is a glorious beacon of lightAlex O'kean is a glorious beacon of lightAlex O'kean is a glorious beacon of lightAlex O'kean is a glorious beacon of lightAlex O'kean is a glorious beacon of lightAlex O'kean is a glorious beacon of lightAlex O'kean is a glorious beacon of lightAlex O'kean is a glorious beacon of lightAlex O'kean is a glorious beacon of lightAlex O'kean is a glorious beacon of light
Send a message via ICQ to Alex O'kean Send a message via Skype™ to Alex O'kean
Default

Quote:
Originally Posted by HungaroJET View Post
Thank you Alex

I have one question: can we change textures by model arguments and values in liveries//description.lua just like in FC2 .skins files ?
if you about extending skin amount for old models , (which was limited by number of 10)

so we have example of it

"Bazar\Liveries\f-16a mlu\CMD extended skins"
__________________
Alex O'kean is offline   Reply With Quote
Old 05-26-2012, 09:14 PM   #6
HungaroJET
Senior Member
 
HungaroJET's Avatar
 
Join Date: Jan 2005
Location: Budapest, Hungary
Posts: 1,204
Reputation power: 50
HungaroJET is a splendid one to beholdHungaroJET is a splendid one to beholdHungaroJET is a splendid one to beholdHungaroJET is a splendid one to beholdHungaroJET is a splendid one to beholdHungaroJET is a splendid one to beholdHungaroJET is a splendid one to beholdHungaroJET is a splendid one to beholdHungaroJET is a splendid one to beholdHungaroJET is a splendid one to beholdHungaroJET is a splendid one to beholdHungaroJET is a splendid one to behold
Lightbulb

Quote:
Originally Posted by Alex O'kean View Post
if you about extending skin amount for old models , (which was limited by number of 10)

so we have example of it

"Bazar\Liveries\f-16a mlu\CMD extended skins"
im about bringing back the F-18 afterburners 1+5 stages textures and correcting old F-4, F-5, F-16, F-14, MiG-29s, Su-27 etc. idle (fully opened) nozzles without the "flame" textures

so this "feature" really need variable textures by values of arguments
__________________
Atop the midnight tarmac,
a metal beast awaits.
To be flown below the radar,
to bring the enemy his fate.


HAVE A BANDIT DAY !


Last edited by HungaroJET; 05-26-2012 at 09:29 PM.
HungaroJET is offline   Reply With Quote
Old 05-26-2012, 11:28 PM   #7
joey45
Veteran
 
joey45's Avatar
 
Join Date: Jul 2006
Location: FunKyTOwn aka North London UK
Posts: 8,203
Reputation power: 162
joey45 has much to be proud ofjoey45 has much to be proud ofjoey45 has much to be proud ofjoey45 has much to be proud ofjoey45 has much to be proud ofjoey45 has much to be proud ofjoey45 has much to be proud ofjoey45 has much to be proud ofjoey45 has much to be proud ofjoey45 has much to be proud ofjoey45 has much to be proud ofjoey45 has much to be proud ofjoey45 has much to be proud of
Send a message via MSN to joey45 Send a message via Skype™ to joey45
Default

Interesting.

How would I go about adding a Naval ship?
__________________
General 3D modeling thread and reference sites
159th_joey Bomber boi
new UK liveries for planes, ships and MODS.
New gazelle liveries are up..
If you've repainted my ship I would love to see it.
"Fine, we'll make our own world with blackjack and hookers"..
joey45 is offline   Reply With Quote
Old 05-28-2012, 09:51 PM   #8
Pikey
Senior Member
 
Pikey's Avatar
 
Join Date: Sep 2009
Location: Reading, UK (GMT)
Posts: 1,505
Reputation power: 20
Pikey is a glorious beacon of lightPikey is a glorious beacon of lightPikey is a glorious beacon of lightPikey is a glorious beacon of lightPikey is a glorious beacon of lightPikey is a glorious beacon of lightPikey is a glorious beacon of lightPikey is a glorious beacon of lightPikey is a glorious beacon of lightPikey is a glorious beacon of light
Default

Oh this post is fantastic! So much creativity and such a bright future ahead Bookmarked.
Pikey is offline   Reply With Quote
Old 05-30-2012, 08:17 PM   #9
Alex O'kean
ED Team
 
Alex O'kean's Avatar
 
Join Date: Jul 2004
Location: Борисоглебск - Москва
Posts: 573
Reputation power: 25
Alex O'kean is a glorious beacon of lightAlex O'kean is a glorious beacon of lightAlex O'kean is a glorious beacon of lightAlex O'kean is a glorious beacon of lightAlex O'kean is a glorious beacon of lightAlex O'kean is a glorious beacon of lightAlex O'kean is a glorious beacon of lightAlex O'kean is a glorious beacon of lightAlex O'kean is a glorious beacon of lightAlex O'kean is a glorious beacon of light
Send a message via ICQ to Alex O'kean Send a message via Skype™ to Alex O'kean
Default Cockpit from scratch

what you need to make cockpit package : 3d model of cockpit (we will not discuss about aspects of creation 3d models here), lua skills , C/C++ skills (optionally ),patience !

Each time when you take control over aircraft ,DCS will try to load package from HumanCockpitPath entry of database for this aircraft type, it can be added for existed aircraft (ie F-16 in DCS )
by calling
Code:
make_flyable("F-16",current_mod_path..'/Cockpit/Scripts') -- for example
if such path exist DCS will start loading it by executing two files at the root of this folder
Code:
clickabledata.lua
device_init.lua
clickabledata contain info about clickable elements of your cockpit 3d model and commands which will be raised to targeted device on click.

devices are declared in file device_init

first device which you always need is MainPanel
it is always declared in form of
Code:
MainPanel = {"ccMainPanel",LockOn_Options.script_path.."mainpanel_init.lua"}
where ccMainPanel is command to factory to create object of type ccMaiPanel
next is init script for your device
MainPanel will hold and render your 3d model and animate gauges by "arguments"

after main panel declaration
you are can declare up to 255 devices for different purposes
Code:
creators    = {}
creators[devices.TEST]			 = {"avLuaDevice"		    ,LockOn_Options.script_path.."test_device.lua"}
creators[devices.WEAPON_SYSTEM]	 = {"avSimpleWeaponSystem"  ,LockOn_Options.script_path.."Systems/weapon_system.lua"}
creators[devices.CLOCK]			 = {"avAChS_1"			    ,LockOn_Options.script_path.."clock.lua"}
creators[devices.ADI]			 = {"avBaseIKP"			    ,LockOn_Options.script_path.."adi.lua"}
creators[devices.ELECTRIC_SYSTEM]= {"avSimpleElectricSystem",LockOn_Options.script_path.."Systems/electric_system.lua"}
creators[devices.RADAR]			 = {"avSimpleRadar"			,LockOn_Options.script_path.."RADAR/Device/init.lua"}
table devices is just named index
Code:
local count = 0
local function counter()
	count = count + 1
	return count
end
-------DEVICE ID-------
devices = {}
devices["TEST"]						= counter()--1
devices["WEAPON_SYSTEM"]			= counter()--2
devices["ELECTRIC_SYSTEM"]			= counter()--3
devices["CLOCK"]					= counter()--4
devices["ADI"]						= counter()--5
devices["RADAR"]					= counter()--6
all devices except TEST store their base functionality inside our libraries and used just as entry point to core data of FM and other objects

avLuaDevice is device which functionality completely driven by lua
for example content of test_device.lua
Code:
local dev 	    = GetSelf()
local my_param  = get_param_handle("TEST_PARAM") -- obtain shared parameter (created if not exist ), i.e. databus

my_param:set(0.1) -- set to 0.1


local update_time_step = 0.1


make_default_activity(update_time_step)
--update will be called 10 times per second

local sensor_data = get_base_data()

local DC_BUS_V  = get_param_handle("DC_BUS_V")
DC_BUS_V:set(0)

function post_initialize()
	electric_system = GetDevice(3) --devices["ELECTRIC_SYSTEM"]
	print("post_initialize called")
end

function update()
	local v = my_param:get()
	print(v)
	my_param:set(sensor_data.getMachNumber())
	if electric_system ~= nil then
	   local DC_V     =  electric_system:get_DC_Bus_1_voltage()
	   local prev_val =  DC_BUS_V:get()
	   -- add some dynamic: 
	   DC_V = prev_val + (DC_V - prev_val) * update_time_step   
	   DC_BUS_V:set(DC_V)
	end	
end

function SetCommand(command,value)
     if command == 3001 then
       print("user click")
     end
end
most important thing of that is
Code:
local my_param  = get_param_handle("TEST_PARAM")
get_param_handle create named databus entry which can be accessed by any other device, indication element , panel gauge , trigger event by name

this code inside mainpanel_init.lua will animate value of TEST_PARAM as argument 113 of 3d model
Code:
TEST_PARAM_GAUGE      			  = CreateGauge("parameter")
TEST_PARAM_GAUGE.parameter_name   = "TEST_PARAM"
TEST_PARAM_GAUGE.arg_number    	  = 113
TEST_PARAM_GAUGE.input    		  = {0,100} 
TEST_PARAM_GAUGE.output    		  = {0,1}
this code inside indicator's script will add text to HUD with this value

Code:
local test_output           = CreateElement "ceStringPoly"
test_output.name            = create_guid_string()
test_output.material        = FONT_
test_output.init_pos        = {0,-1}
test_output.alignment       = "CenterCenter"
test_output.stringdefs      = {0.01,0.75 * 0.01, 0, 0}
test_output.formats         = {"%.2f","%s"} 
test_output.element_params  = {"TEST_PARAM"}
test_output.controllers     = {{"text_using_parameter",0,0}} --first index is for element_params (starting with 0) , second for formats ( starting with 0)
test_output.additive_alpha  = true
test_output.collimated     = true
AddElement(test_output)
as more usefull sample

Code:
gun_sight_mark 					= create_textured_box(0,0,32,32) -- this is create_textured_box function call with parameters
gun_sight_mark.material       	= PIPER_	
gun_sight_mark.name 			= BASE_COLOR_MAT
gun_sight_mark.collimated	  	= true
gun_sight_mark.element_params   = {"WS_GUN_PIPER_AVAILABLE",
								   "WS_GUN_PIPER_AZIMUTH",
								   "WS_GUN_PIPER_ELEVATION"} 
								   
gun_sight_mark.controllers 	   = {{"parameter_in_range"				,0,0.9,1.1},--check that piper available using WS_GUN_PIPER_AVAILABLE
								  {"move_left_right_using_parameter",1, 0.73 },	--azimuth move by WS_GUN_PIPER_AZIMUTH , 0.73 is default collimator distance (from eye to HUD plane)
								  {"move_up_down_using_parameter"   ,2, 0.73 }, --elevation move by WS_GUN_PIPER_ELEVATION
								 }
AddElement(gun_sight_mark)
use three named params to control gun piper mark position on HUD

to be continued...
__________________

Last edited by Alex O'kean; 05-30-2012 at 08:48 PM.
Alex O'kean is offline   Reply With Quote
Old 05-30-2012, 11:44 PM   #10
SilentEagle
Member
 
Join Date: Nov 2004
Posts: 523
Reputation power: 24
SilentEagle is a glorious beacon of lightSilentEagle is a glorious beacon of lightSilentEagle is a glorious beacon of lightSilentEagle is a glorious beacon of lightSilentEagle is a glorious beacon of lightSilentEagle is a glorious beacon of lightSilentEagle is a glorious beacon of lightSilentEagle is a glorious beacon of lightSilentEagle is a glorious beacon of lightSilentEagle is a glorious beacon of light
Default

Excellent! Keep the info coming! It will takes some time to go through these functions and see just how much functionality is available.
SilentEagle 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 02:02 PM. vBulletin Skin by ForumMonkeys. Powered by vBulletin®.
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.