Jump to content

DCS: World Scripting Engine


Recommended Posts

Thanks for the input! I feel like if you are developing a Doppler-shift simulation maybe I should put my (limited) efforts in that direction on hold and use your implementation instead once it's done. The rotor-thing is news to me, but it does make sense, although I thought that one of the things attack-choppers where especially suited for was radar-killing as they where used for in the start of the gulf war. Maybe they emulated civilian traffic I don't know...

DCS AJS37 HACKERMAN

 

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

Link to comment
Share on other sites

  • 1 month later...
  • Replies 148
  • Created
  • Last Reply

Top Posters In This Topic

Is it possible to spawn and distruct(not destory it, delete from a running mission) an object by stript engine ?

I7-6700K OC 4.9G, 896G SSD, 32G RAM @ 2400MHz, NH-D15 cooling system,TM Hotas Warthog,Saitek Pro Flight Rudder Pedals,TrackIr 5, BOSE M2

Link to comment
Share on other sites

Is it possible to spawn and distruct(not destory it, delete from a running mission) an object by stript engine ?

 

Not officially, but there are undocumented functions in the scripting engine that might or might not work. To see them, use Mist to do a _G dump.

 

Anyway, there used to be a Unit.destroy function, and I think it is still in there. It basically did what you wanted- removed a unit without any fanfare or messages or anything.

 

HOWEVER....

 

Keep in mind that, as it is an undocumented function (you only tell it exists by doing a _G dump), it might not work correctly and is liable to be changed or removed at any time! ED is in no obligation to support it, and you can't blame them if you use it in a mission and the next patch breaks it. Also, over a year ago, I was trying to use Unit.destroy in Slmod to attempt to make restricted aircraft slots- turned out, Unit.destroy did not work correctly in multiplayer. I can't remember the full details though. I think it might fine if you were only going to make a single player mission though.

 

So basically:

Yes, but it's undocumented, unsupported, probably only works for single player/host, could be removed at any time, could cause CTDs, etc. Use it at your own risk!

 

Anyway, IMO, for now at least, just use GROUP DEACTIVATE if at all possible.


Edited by Speed

Intelligent discourse can only begin with the honest admission of your own fallibility.

Member of the Virtual Tactical Air Group: http://vtacticalairgroup.com/

Lua scripts and mods:

MIssion Scripting Tools (Mist): http://forums.eagle.ru/showthread.php?t=98616

Slmod version 7.0 for DCS: World: http://forums.eagle.ru/showthread.php?t=80979

Now includes remote server administration tools for kicking, banning, loading missions, etc.

Link to comment
Share on other sites

Not officially, but there are undocumented functions in the scripting engine that might or might not work. To see them, use Mist to do a _G dump.

 

Anyway, there used to be a Unit.destroy function, and I think it is still in there. It basically did what you wanted- removed a unit without any fanfare or messages or anything.

 

HOWEVER....

 

Keep in mind that, as it is an undocumented function (you only tell it exists by doing a _G dump), it might not work correctly and is liable to be changed or removed at any time! ED is in no obligation to support it, and you can't blame them if you use it in a mission and the next patch breaks it. Also, over a year ago, I was trying to use Unit.destroy in Slmod to attempt to make restricted aircraft slots- turned out, Unit.destroy did not work correctly in multiplayer. I can't remember the full details though. I think it might fine if you were only going to make a single player mission though.

 

So basically:

Yes, but it's undocumented, unsupported, probably only works for single player/host, could be removed at any time, could cause CTDs, etc. Use it at your own risk!

 

Anyway, IMO, for now at least, just use GROUP DEACTIVATE if at all possible.

 

Thanks,I will try this :thumbup:

I7-6700K OC 4.9G, 896G SSD, 32G RAM @ 2400MHz, NH-D15 cooling system,TM Hotas Warthog,Saitek Pro Flight Rudder Pedals,TrackIr 5, BOSE M2

Link to comment
Share on other sites

@Speed... I wondered if we should start a github repository for MIST?

 

I also worked over the weekend to make updates to messaging, creating simple, error-checking functions that make it easy to send messages with correct data to coalition, country, group, or everyone.

 

Just thinking that there are a few people who like to contribute and if we could have a centralized spot for everything, may be handy.

"Snipe"

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

OS => Win7 64-bit Ultimate | MOBO => ASUS M2N-SLI Deluxe | RAM => 8GB | VIDEO CARD => XFX ATI 4850 | CONTROLLER => Saitek X52 | DISPLAY => ASUS 25.5" 1600x1280 | HDD => 150GB WD Raptor (10K RPM)

Link to comment
Share on other sites

Quoting the first post by Speed in the MiST thread:

Community Contributions

The purpose of Mist is to provide a set of scripts for the DCS community, by the DCS community. We are open to people contributing their own scripts into Mist, but we reserve the right to edit your script in any way we see fit before “officially” including it into Mist. Also, feel free to contribute ideas as for what scripts to develop next.

 

As we haven't exactly included scripts made by other DCS uses into Mist yet, we don't really have a process set in stone of how to go about doing that. I think the initial idea was for released scripts to be looked at it, decide if it would be useful, and then contact the scripts creator for permission to include it. For unpublished scripts, its probably a matter of PM'ing either of us to get it included and for the discussion to go from there.

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

@Grimes, when will you and @Speed be releasing the next "official" release of MIST?

"Snipe"

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

OS => Win7 64-bit Ultimate | MOBO => ASUS M2N-SLI Deluxe | RAM => 8GB | VIDEO CARD => XFX ATI 4850 | CONTROLLER => Saitek X52 | DISPLAY => ASUS 25.5" 1600x1280 | HDD => 150GB WD Raptor (10K RPM)

Link to comment
Share on other sites

@Grimes, when will you and @Speed be releasing the next "official" release of MIST?

 

Hopefully soon. I've been tied up with multiple different DCS projects, plus what I have to do for work. I will be trying to focus on Mist in the coming days and get what I need to get completed done.

Intelligent discourse can only begin with the honest admission of your own fallibility.

Member of the Virtual Tactical Air Group: http://vtacticalairgroup.com/

Lua scripts and mods:

MIssion Scripting Tools (Mist): http://forums.eagle.ru/showthread.php?t=98616

Slmod version 7.0 for DCS: World: http://forums.eagle.ru/showthread.php?t=80979

Now includes remote server administration tools for kicking, banning, loading missions, etc.

Link to comment
Share on other sites

First, awesome! Glad to hear it. Wouldn't it be great if you didn't have to worry about that annoying "work" thing!?

 

Couple questions @Speed / @Grimes:

1.) Because you're on the ED Testers Team, does this mean you have a little more certainty that Sim updates won't break Slmod / Mist? How do you battle this? I've seen a lot of posts indicating a lot of folks have given up mod'ing for DCSW because every release means they have to go refactor their mod again.

 

2.) Where do you get a comprehensive list (or how do I find one) of all the LUA functionality exposed? Would be very nice to be able to have a complete reference, or at least know which files to look at to figure it all out. It's very difficult to just hand sort through all the folders / files and try to make sense of what does what when, etc. There's gotta be a rhyme or reason right?

 

Thanks again!

"Snipe"

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

OS => Win7 64-bit Ultimate | MOBO => ASUS M2N-SLI Deluxe | RAM => 8GB | VIDEO CARD => XFX ATI 4850 | CONTROLLER => Saitek X52 | DISPLAY => ASUS 25.5" 1600x1280 | HDD => 150GB WD Raptor (10K RPM)

Link to comment
Share on other sites

1. Pretty much yes. Building missions or scripts are one of the more efficient ways to find bugs with our scripts or something with the scripting engine. That said the simulator scripting engine is continuously evolving, so there will be some things that need to change out of necessity, but its code so find/replace makes that process of updating easier.

 

 

2. The wiki is pretty up to date and is mostly maintained by Saint, the ED dev making the scripting engine and made this thread. http://en.wiki.eagle.ru/wiki/Simulator_Scripting_Engine_(DCS:_World_1.2.1)

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

Hi to all, I have a couple of questions:

 

Question 1, subject: triggered actions for ground groups.

is there a script to be put in the “SHOW CONDITION” square to bypass the 1-99 flag limit in the “IS USER” field?

 

Reason:

I’m going to have hundreds of groups x coalition and to each one I need two triggered actions one for turn alert red on and one for go green for any specific group, and I do not want to do it by trigger (other scripted conditions makes the work to turn flag on or off).

 

Question 2, subject: turning on & off flag by LOS condition + timer delay.

Ok about this I’m entirely rely on you… by using MIST and Lua, can you please help me creating two function that makes this work:

 

1: turn a particular flag on for 3 seconds and then immediately off anytime any enemy plane/helicopter is in LOS within a specific range. The flag must be turned on with “n” seconds of delay, and the function must check the conditions to became true every “m” seconds.

 

2: returns “true” anytime any enemy plane/helicopter is in LOS within a specific range (to be used in “show condition box as descripted above).

 

Reason

The main idea is to recreate a IADS network without going crazy with triggers and obviously being capable to copy the entire network from a mission to another just by CTRL-C and CTRL-V… this require to recreate the flagwork by script. Obviously I’ll share the mission file with templates if it works as intended :).

ChromiumDis.png

Author of DSMC, mod to enable scenario persistency and save updated miz file

Stable version & site: https://dsmcfordcs.wordpress.com/

Openbeta: https://github.com/Chromium18/DSMC

 

The thing is, helicopters are different from planes. An airplane by it's nature wants to fly, and if not interfered with too strongly by unusual events or by a deliberately incompetent pilot, it will fly. A helicopter does not want to fly. It is maintained in the air by a variety of forces in opposition to each other, and if there is any disturbance in this delicate balance the helicopter stops flying; immediately and disastrously.

Link to comment
Share on other sites

Answer 1:

Yes! If its a true/false flag simply using the following should work:

return trigger.misc.getUserFlag(string userFlagName)

 

if it needs to equal something:

if trigger.misc.getUserFlag(string userFlagName) == (whatever) then

return true

end

 

 

Answer 2:

It is possible, but building an IADS with flags and scripting isn't really a great way to go about doing it. By that I mean it should rely entirely on scripting as it is capable of doing all of the necessary functions to make an IADS work. For example setting the options ROE and Alarm State work with ground groups. Manipulation of these two options can create alternative sam behavior.

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

For example setting the options ROE and Alarm State work with ground groups. Manipulation of these two options can create alternative sam behavior.

 

First: thanks.

Second: i missed that. In this case it could be far more efficient to bypass the flag role... at most to cut out the off-ME work with excel table to create reliability mapping.

 

Than, whitout the use of flags, I can implement those two logics:

 

-Shorad: indipendent sensors state green and roe "return fire" since enemy is in LOS whitin firing range. (please note that sensors come back to green after 3 minutes... but if enemy it's still in range, they shoud activate another time. that is confirmed even not using flags?)

 

-LR: when enemy are detected in EWR whithin a certain range, a timer of 120 secs is started.

 

Since that timer, some (not all) Radar SAMs turn on sensors. They will turn off them if enemy gets closer.

 

Other Radar SAMs stay green until them have enemy in LOS at firing range, ONLY if EWR is still active.

 

 

To do this, I believe that for shorad could be pretty simple... but I don't know where to start for the Radar SAMs logic.

 

(PS: IADS groups names in the editor will be fixed and stable, but I would like to take into account, if possible, something like "any group that cotain the 'IADS-' or 'IADS-' prefixes"... that should allow me to add some Radar SAMs group whitout having to check the entire EWR-Radar logic... but... it's a non-necessary addition :D )

ChromiumDis.png

Author of DSMC, mod to enable scenario persistency and save updated miz file

Stable version & site: https://dsmcfordcs.wordpress.com/

Openbeta: https://github.com/Chromium18/DSMC

 

The thing is, helicopters are different from planes. An airplane by it's nature wants to fly, and if not interfered with too strongly by unusual events or by a deliberately incompetent pilot, it will fly. A helicopter does not want to fly. It is maintained in the air by a variety of forces in opposition to each other, and if there is any disturbance in this delicate balance the helicopter stops flying; immediately and disastrously.

Link to comment
Share on other sites

Hi to all, I have a couple of questions:

 

Question 1, subject: triggered actions for ground groups.

is there a script to be put in the “SHOW CONDITION” square to bypass the 1-99 flag limit in the “IS USER” field?

 

Don't use IS USER, use the Lua expression start/stop condition. Hell, the Lua expression start/stop condition has been in the game since A-10C beta 1. It works just like the new Lua expression trigger condition. Do your logic (if there is any), and just use

return <value>

Where <value> is a Lua value. If this Lua value is false or nil, it will evaluate to logical false; otherwise, it will evaluate to logical true.

 

See here: http://forums.eagle.ru/showpost.php?p=1688844&postcount=7

for examples of me using the Lua expression trigger condition- which like I said, works just like the Lua expression start/stop condition.

Intelligent discourse can only begin with the honest admission of your own fallibility.

Member of the Virtual Tactical Air Group: http://vtacticalairgroup.com/

Lua scripts and mods:

MIssion Scripting Tools (Mist): http://forums.eagle.ru/showthread.php?t=98616

Slmod version 7.0 for DCS: World: http://forums.eagle.ru/showthread.php?t=80979

Now includes remote server administration tools for kicking, banning, loading missions, etc.

Link to comment
Share on other sites

Don't use IS USER, use the Lua expression start/stop condition. Hell, the Lua expression start/stop condition has been in the game since A-10C beta 1. It works just like the new Lua expression trigger condition. Do your logic (if there is any), and just use

return <value>

Where <value> is a Lua value. If this Lua value is false or nil, it will evaluate to logical false; otherwise, it will evaluate to logical true.

 

See here: http://forums.eagle.ru/showpost.php?p=1688844&postcount=7

for examples of me using the Lua expression trigger condition- which like I said, works just like the Lua expression start/stop condition.

 

Ehm.. I don't understand: I exactly said that I do not want to use IS USER: as said in the later post, I'm trying to do not use any trigger except of a single one that would run the IADS logic and/or using as much as possible the script window in the show condition.

 

My problem is that I don't know how to make those script :(... I'll try to learn them.

ChromiumDis.png

Author of DSMC, mod to enable scenario persistency and save updated miz file

Stable version & site: https://dsmcfordcs.wordpress.com/

Openbeta: https://github.com/Chromium18/DSMC

 

The thing is, helicopters are different from planes. An airplane by it's nature wants to fly, and if not interfered with too strongly by unusual events or by a deliberately incompetent pilot, it will fly. A helicopter does not want to fly. It is maintained in the air by a variety of forces in opposition to each other, and if there is any disturbance in this delicate balance the helicopter stops flying; immediately and disastrously.

Link to comment
Share on other sites

  • 1 month later...

DCS World 1.2.4

 

In DCS: World 1.2.4 Simulator Scripting Engine was extended with multiple new functions, namespaces and classes.

 

Here is the changelist from 1.2.3 to 1.2.4

 

Object.getCategory() function was added

Multiple functions were moved from Unit to Object

Object.destroy() function was added

Object.getDesc() function was added

CoalitionObject intermediate class was added

StaticObject.getByName static function was added

Unit.getPlayerName() function was added

Unit.getAmmo() function was added

Airbase class was added

Weapon.getLauncher() and Weapon.getTarget() functions were added.

Descriptors for Unit, Weapon, Airbase, StaticObject and SceneryObject

Group.isExist() function was added

Group.getCategory() and Group.getCoalition() functions were added

Group.activate() and Group.destroy() functions were added

coalition.getPlayers() function was added

coalition.getGroups() function was added

coalition.getStaticObjects() function was added

coalition.addGroup() function was added

coalition.addStaticObject() function was added

world.getAirbases() and coalition.getAirbases() functions were added

land.getSurfaceType function was added

trigger.action.setAITask() and trigger.action.pushAITask() functions was added

Some new main tasks for airborne units / groups are now available: Land, Follow, Escort

FAC tasks are now available: FAC_AttackGroup, FAC_EngageGroup, FAC

missionCommands singletone was added

AI namespace added. It contains constants used in Controller functions

 

Please read the updated document.

Link to comment
Share on other sites

About the new addGroup-function: It seems the units only show on the server-machine and only if it is triggered by the server... Any solutions?

DCS AJS37 HACKERMAN

 

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

Link to comment
Share on other sites

  • 3 months later...

I have an aircraft being late activated in-air with no task.

In the same ME DoScript, I am attempting to create what will ultimately be a dynamic task for it.

 

Examples in threads vs wiki vs non updated example by RagnarDa on page 11 on this thread - all use different notation so I am struggling to know if it's my formatting that is incorrect, or I am totally missing a mandatory step.

 

At the moment, the aircraft simply goes and lands at nearest airbase...instead of flying off to 0,0 as my code is suggesting it should do.

 

Tried single and double quotes around each Enum/string, tried eliminating the irrelevant items (airdrome/helipad etc), tried writing the enums as TURNING_POINT (rather than Turning Point). Also tried with default waypoint set in mission editor, and without.

 

What else do I need to do (thanks):

 

 

GPmig29a=Group.getByName('mig29a')

Group.activate(GPmig29a)

 

SimpleMission = {

id = 'Mission',

params = {

route = {

points = {

[1] = {

["type"] = "Turning Point",

["airdromeId"] = nil,

["helipadId"] = nil,

["action"] = "Turning Point",

["x"] = 0,

["y"] = 0,

["alt"] = 3000,

["alt_type"] = "BARO",

["speed"] = 100,

["speed_locked"] = false,

["ETA"] = 100,

["ETA_locked"] = false,

["name"] = "mywp1",

["task"] = nil

}

}

}

}

}

 

GCmig29a=GPmig29a:getController()

GCmig29a:setTask(SimpleMission)

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

I recommend setting multiple waypoints, possibly even having the first one occur where the unit is currently at and the 2nd one at the destination. However it is entirely possible that the aircraft does not have enough fuel to make it to the map origin in the middle of the Crimea and it decides to ignore the order.


Edited by Grimes

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

yeh I spent most of the day with a 4waypoint mission, all 10km radius of aircraft start position. The values for wp1x etc looked fine in the log.

Just posted the previous one for simplicity.

 

Is it necessary to state anything for ETA, if ETA_locked = false ?

Is the comma necessary on the 3rd to last closing bracket (per http://en.wiki.eagle.ru/wiki/Part_2#Tasks )?

 

 

 

SimpleMission = {

id = 'Mission',

params = {

route = {

points = {

[1] = {

type = "Turning Point",

airdromeId = nil,

helipadId = nil,

action = "Turning Point",

x = wp1x,

y = wp1y,

alt = 3000,

alt_type = "RADIO",

speed = 50,

speed_locked = false,

ETA_locked = false,

name = "wp1",

task = nil

},

[2] = {

type = "Turning Point",

airdromeId = nil,

helipadId = nil,

action = "Turning Point",

x = wp2x,

y = wp2y,

alt = 3000,

alt_type = "RADIO",

speed = 50,

speed_locked = false,

ETA_locked = false,

name = "wp2",

task = nil

},

[3] = {

type = "Turning Point",

airdromeId = nil,

helipadId = nil,

action = "Turning Point",

x = wp3x,

y = wp3y,

alt = 3000,

alt_type = "RADIO",

speed = 50,

speed_locked = false,

ETA_locked = false,

name = "wp3",

task = nil

},

[4] = {

type = "Turning Point",

airdromeId = nil,

helipadId = nil,

action = "Turning Point",

x = wp4x,

y = wp4y,

alt = 3000,

alt_type = "RADIO",

speed = 50,

speed_locked = false,

ETA_locked = false,

name = "wp4",

task = nil

}

}

}

}

}

 

 

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

I can't remember exactly what is required as a minimum for aircraft waypoints. At least for ground groups you can get away with just using the x, y, speed, and formation. Aircraft probably additionally require alt and alt_type.

 

The thing is in the mission editor either speed locked or time lock must be true. Both cannot be false and both cannot be true. I'm not sure what happens if you fail to specify which to use, but use speed lock = true for the sake of simplicity.

 

I'm not sure which time format is used with ETA. If its like the mission editor then it'd be the mission time, which would be quite a large number of seconds unless you start at day 0, hour 0, minute 0, and second 0.

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

Let me just go ahead and say that setting tasks with script is tricky and not super-robust. For example I noticed that infantry refuses to move unless you set formation to "Line".

DCS AJS37 HACKERMAN

 

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

Link to comment
Share on other sites

  • Recently Browsing   0 members

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