Jump to content

Recommended Posts

Posted

TL;DR: Is there an init.lua file that is called when an object spawns in game?

 

I wonder if someone could point me in the right direction...

 

I see all these examples about adding aircraft and such to DCS but I am looking for something both a little simpler and more complex. I think I can see how to add custom ground objects, and if I look at some of the downloadable mods for DCS I get good examples of just that. Shape files, Texttures, and a lua file to describe the object.

 

Can someone give me a hint on how I can add a custom script to a ground object that will allow me to set up some in-game behaviour. I don't mean like how an object moves, or such, but how an object can feed into game events.

 

I see the entry.lua and how that should interface with the game but where would I put my initialization call that would easily set up the event handler? Something tells me I can put an init.lua script somewhere in the directory structure and I want it called when the game starts.

 

Example: I would like add a command building (with shape and texture) and have this show up in the mission editor and in game, have it (the code) listen for eject events. How can I add an initialization call to that structure so that it can set up an event handler and listen for events?

Fridge

----------

Things which do you no good in aviation:

1) Altitude above you;

2) Runway behind you;

3) Fuel in the truck;

4) The airspeed you don't have.

Posted

I've tried placing init.lua and device_init.lia files around the mod directory structure hoping to see one of them get executed. Of course, I might be missing something or missed something in my tests.

 

Do any aircraft builders know of a script run when the game starts and your unit is spawned in?

 

Any answer is better than no answer :-)

Fridge

----------

Things which do you no good in aviation:

1) Altitude above you;

2) Runway behind you;

3) Fuel in the truck;

4) The airspeed you don't have.

Posted
I've tried placing init.lua and device_init.lia files around the mod directory structure hoping to see one of them get executed. Of course, I might be missing something or missed something in my tests.

 

Do any aircraft builders know of a script run when the game starts and your unit is spawned in?

 

Any answer is better than no answer :-)

 

 

Yes, entry.lua is run when the game starts aswell as the scripts in the directory defined in the "make_flyable" call within it. You can have a look at the structure in a mod directory and then start a game with the player controlling the aircraft and look into dcs.log to see what gets run and doesn't.

DCS AJS37 HACKERMAN

 

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

Posted

Thanks! I actually started my journey by learning most of the lua scripting from the mission builders forums. At my current stage, I was wondering if it might be beneficial to turn my set of scripts into something more mode like, which would allow easier integration into multiplayer missions - instead of having to require mission builders to modify/update their missions.

 

Yes, entry.lua is run when the game starts aswell as the scripts in the directory defined in the "make_flyable" call within it. You can have a look at the structure in a mod directory and then start a game with the player controlling the aircraft and look into dcs.log to see what gets run and doesn't.

 

I will take a look at this. My concern though is that what I am attempting to do is have a non-player controlled custom unit hook into the event handler cycle by registering it's own event handler and then processing events.

 

Example: I create a custom pilot model to represent a pilot on the ground without an aircraft. Allow this unit to be placed in the mission editor and then, on mission start, have an initialization script run that hooks into the event system. What I would like, is to not have the mission designer have to put the initialization script in (and the code, because I am not sure how the mission designer could call code in the mod/unit directory structure).

 

So, from looking at the various units in DCS World (A-10A, etc), I can see make_flyable calls that contain links to a comm.lua script call that I could potentially hack into .. assuming make_flyable is called when the unit is placed as an AI unit. But then when I look at the Combined Arms mod, I don't see anything similar.

Fridge

----------

Things which do you no good in aviation:

1) Altitude above you;

2) Runway behind you;

3) Fuel in the truck;

4) The airspeed you don't have.

Posted

Any chance of a response from ED? I am getting to the point in my code that I either need to take advantage of the opportunities offered by being a module or making more work for mission designers.

 

I will soon have to shelve my ideas for others.

Fridge

----------

Things which do you no good in aviation:

1) Altitude above you;

2) Runway behind you;

3) Fuel in the truck;

4) The airspeed you don't have.

Posted

Example of another cool thing you could potentially do with this: Windsocks

Fridge

----------

Things which do you no good in aviation:

1) Altitude above you;

2) Runway behind you;

3) Fuel in the truck;

4) The airspeed you don't have.

  • Recently Browsing   0 members

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