MIssion Scripting Tools (Mist)- enhancing mission scripting Lua - Page 5 - ED Forums
 


Notices

Reply
 
Thread Tools Display Modes
Old 12-07-2012, 10:48 AM   #41
Grimes
ED Testers Team
 
Grimes's Avatar
 
Join Date: Jan 2006
Location: Black Mesa
Posts: 7,659
Default

Can't force system failures on client aircraft with LUA either. However blowing up units is kind of easy, although I'm not sure how big of a performance impact there will be with the following method.

Use mist.getUnitsinZones to populate a table of units within the zone radius. Once you have the table of units within the zone iterate through each unit and get the units position. Then generate an explosion at each position using this trigger.action.explosion(vec 3, power).
__________________
You can only tie the world record for lowest flight.
Current Projects: Scripting Wiki, Something...
Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD for DCS 1.5/2.0, IADScript, Mission Editing Wiki!, Mission Building Forum
Grimes is offline   Reply With Quote
Old 12-09-2012, 07:57 PM   #42
Speed
Veteran
 
Speed's Avatar
 
Join Date: Nov 2008
Location: Auburn, AL
Posts: 4,079
Default

How to un-protect the mission scripting environment so you can write files, load modules, etc.

To ensure your safety, several "dangerous" Lua modules are removed, aka "sanitized", from the mission scripting Lua environment. These modules are the io library (read/write files), the os library (command prompt access), the lfs library (Lua File System- creation of folders, folder location, files in folders, etc.) and the require and loadlib functions. This prevents someone from making a mission that will install viruses/format your C: drive, etc when you run it.

Several patches back, "Saint" (Святой) helpfully moved this "sanitization" code from C++ into the ./Scripts/MissionScripting.lua file. This allows you to optionally un-protect the mission scripting Lua environment and have access to the FULL set of Lua libraries. So, you could for example, output mission data to a file for use in Excel, load Lua socket and send mission data over the network- whatever you desire!

So, to un-protect the mission scripting Lua environment, you simply need to comment out lines 33 through 39 of ./Scripts/MissionScripting.lua:


I would not recommend this as a permanent mod, not if you ever run missions/tracks from untrustworthy sources, but this SURE comes in useful from time to time!
Attached Thumbnails
Click image for larger version

Name:	unprotected.jpg
Views:	931
Size:	60.6 KB
ID:	74701  
__________________
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.

Last edited by Speed; 12-09-2012 at 08:02 PM.
Speed is offline   Reply With Quote
Old 12-12-2012, 11:34 PM   #43
Ripcord
Member
 
Ripcord's Avatar
 
Join Date: Mar 2010
Location: Houston TX
Posts: 657
Default

Quote:
This allows you to optionally un-protect the mission scripting Lua environment and have access to the FULL set of Lua libraries. So, you could for example, output mission data to a file for use in Excel, load Lua socket and send mission data over the network- whatever you desire!
Interesting... So a fellow could create database of flags and write that data to an excel file, and then have another mission read that same database of flags?

My thought is that this would enable a mission designer to do some rudimentary version of damage tracking for SAM/AAA and EW units/ groups, as well as for artillery and really any number of 'front line' combatants. So you could have a semi-dynamic moving FLOT from mission to mission.

Suddenly building a proper ground-war campaign gets a helluva lot more interesting.

EDIT: Let me understand this better -- if one were to build a mission that wrote data to a third file, as well as read data from the same file, what would that require in terms of this mod, Speed? Would it mean that that each user would need to have this same mod set up, as you have shown us here, with the lines commented out? Surely that would be heading a bit too far in the direction of a permanent mod, and ED might intervene and break this feature, should they perceive that it puts users too much at risk -- nothing prevents someone from making a mission that will install viruses/format your C: drive, etc when you run it.

An ideal scenario would be to work with ED a little bit here and ask for a set up whereby ANY novice mission builder would have the ability to WRITE ALL FLAG VALUES (from Flag 1 to 9999) to a file, whenever triggered in the mission editor, as well as allowing the same novice mission builder the ability to READ ALL FLAG VALUES, again from 1 to 9999, from the same said file -- and to allow us the ability to do this NOT AS A MOD that opens the door to God-knows-what, but within the framework of the ME and the sim. Essentially WRITE ALL FLAG VALUES and READ ALL FLAG VALUES should be Actions that can be selected in the trigger menu. Wags will recognize the value in this, as they allowed for this in Janes F/A-18 years ago (campaign variables) as well as allowing for damage tracking.

If I have derailed the thread I apologize -- but this is potentially HUGE.
__________________
<a href=http://forums.eagle.ru/signaturepics/sigpic65507_1.gif target=_blank>http://forums.eagle.ru/signaturepics/sigpic65507_1.gif</a>

Last edited by Ripcord; 12-12-2012 at 11:51 PM.
Ripcord is offline   Reply With Quote
Old 12-13-2012, 12:36 AM   #44
Grimes
ED Testers Team
 
Grimes's Avatar
 
Join Date: Jan 2006
Location: Black Mesa
Posts: 7,659
Default

You can certainly write files. That is how we created the DB examples and I often output tables for bug testing missions. Opening files is a different issue that Speed could better answer. However as your edited posts notes, these lua environments have been sanitized by default for a very good reason.
__________________
You can only tie the world record for lowest flight.
Current Projects: Scripting Wiki, Something...
Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD for DCS 1.5/2.0, IADScript, Mission Editing Wiki!, Mission Building Forum
Grimes is offline   Reply With Quote
Old 12-13-2012, 02:30 AM   #45
Ripcord
Member
 
Ripcord's Avatar
 
Join Date: Mar 2010
Location: Houston TX
Posts: 657
Default

Do you think it is a reasonable request, then, to ask that we have an 'in-game' trigger action to write/read flag values? Certainly we cannot demand it, or even expect it, but what an improvement it would be.
__________________
<a href=http://forums.eagle.ru/signaturepics/sigpic65507_1.gif target=_blank>http://forums.eagle.ru/signaturepics/sigpic65507_1.gif</a>
Ripcord is offline   Reply With Quote
Old 12-13-2012, 06:48 AM   #46
Speed
Veteran
 
Speed's Avatar
 
Join Date: Nov 2008
Location: Auburn, AL
Posts: 4,079
Default

Quote:
Originally Posted by Ripcord View Post
Interesting... So a fellow could create database of flags and write that data to an excel file, and then have another mission read that same database of flags?

My thought is that this would enable a mission designer to do some rudimentary version of damage tracking for SAM/AAA and EW units/ groups, as well as for artillery and really any number of 'front line' combatants. So you could have a semi-dynamic moving FLOT from mission to mission.

Suddenly building a proper ground-war campaign gets a helluva lot more interesting.

EDIT: Let me understand this better -- if one were to build a mission that wrote data to a third file, as well as read data from the same file, what would that require in terms of this mod, Speed? Would it mean that that each user would need to have this same mod set up, as you have shown us here, with the lines commented out? Surely that would be heading a bit too far in the direction of a permanent mod, and ED might intervene and break this feature, should they perceive that it puts users too much at risk -- nothing prevents someone from making a mission that will install viruses/format your C: drive, etc when you run it.
You're worrying too much. If I'm writing a MissionScripting.lua mod, it is quite simple to create a "sandbox" for all mission scripts so that only MY functions can access the dangerous Lua libraries (io/lfs/os), but nothing else can. If we want a function that can read/write flags, but we don't want the io/lfs/os libraries to be usable by mission scripts, we can have it.

Quote:
An ideal scenario would be to work with ED a little bit here and ask for a set up whereby ANY novice mission builder would have the ability to WRITE ALL FLAG VALUES (from Flag 1 to 9999) to a file, whenever triggered in the mission editor, as well as allowing the same novice mission builder the ability to READ ALL FLAG VALUES, again from 1 to 9999, from the same said file -- and to allow us the ability to do this NOT AS A MOD that opens the door to God-knows-what, but within the framework of the ME and the sim. Essentially WRITE ALL FLAG VALUES and READ ALL FLAG VALUES should be Actions that can be selected in the trigger menu. Wags will recognize the value in this, as they allowed for this in Janes F/A-18 years ago (campaign variables) as well as allowing for damage tracking.

If I have derailed the thread I apologize -- but this is potentially HUGE.
Hmm... but could it be exploited to make a mission that fills up your hard drive? Maybe the risk would be worth it... after all, from 1.1.0.5 to 1.1.0.8 we had a completely unsecured and open mission scripting environment, and there were no malicious missions passed around that I know of.
__________________
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.

Last edited by Speed; 12-13-2012 at 07:29 AM.
Speed is offline   Reply With Quote
Old 12-13-2012, 07:30 AM   #47
Grimes
ED Testers Team
 
Grimes's Avatar
 
Join Date: Jan 2006
Location: Black Mesa
Posts: 7,659
Default

Not sure people knew much about the mission scripting environment at that time.
__________________
You can only tie the world record for lowest flight.
Current Projects: Scripting Wiki, Something...
Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD for DCS 1.5/2.0, IADScript, Mission Editing Wiki!, Mission Building Forum
Grimes is offline   Reply With Quote
Old 12-17-2012, 02:26 AM   #48
gunterlund21
Member
 
Join Date: Mar 2012
Location: Napa, Ca
Posts: 667
Default

ok so I copied and pasted Mistv1_1 into a do script trigger. Then I created another do script trigger with mist.flagFunc.mapobjs_dead_zones{ zones = {'Kurta Bridge'}, flag = 51 } in the do script. I placed the zone called Kurta Bridge over a bridge. I have another trigger that messages if flag 51 is true. Im not getting the message when the bridge is destroyed. Am I missing anything?
gunterlund21 is offline   Reply With Quote
Old 12-17-2012, 03:59 AM   #49
Speed
Veteran
 
Speed's Avatar
 
Join Date: Nov 2008
Location: Auburn, AL
Posts: 4,079
Default

Quote:
Originally Posted by gunterlund21 View Post
ok so I copied and pasted Mistv1_1 into a do script trigger. Then I created another do script trigger with mist.flagFunc.mapobjs_dead_zones{ zones = {'Kurta Bridge'}, flag = 51 } in the do script. I placed the zone called Kurta Bridge over a bridge. I have another trigger that messages if flag 51 is true. Im not getting the message when the bridge is destroyed. Am I missing anything?
Doesn't sound like there is anything wrong. Please upload the mission. I'll also double-check that the function is operating correctly. I just looked over its code, and I realized that the Mist manual is wrong about it- I believe that in the Mist manual, I state that mist.flagFunc.mapobjs_dead_zones counts up all map objects ever destroyed in that zone, but that's wrong- it only counts dead map objects that were killed AFTER the function/process began operating (so it works just like the similar Slmod function).
__________________
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.
Speed is offline   Reply With Quote
Old 12-17-2012, 05:35 PM   #50
Speed
Veteran
 
Speed's Avatar
 
Join Date: Nov 2008
Location: Auburn, AL
Posts: 4,079
Default

Ok, and I just doubled-checked mist.flagFuncs.mapobjs_dead_zones in 1.2.2.7286. The function still works successfully. I used a script almost identical to yours:

Code:
mist.flagFunc.mapobjs_dead_zones{zones = {'bridge'}, flag = 10}
Flag 10 is set true when the bridge map object within the zone named "bridge" dies.

Test mission is attached.
Attached Files
File Type: miz test of mapobjs_dead_zones.miz (39.1 KB, 89 views)
__________________
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.

Last edited by Speed; 12-17-2012 at 05:39 PM.
Speed is offline   Reply With Quote
Reply

Tags
mist

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 12:43 AM. vBulletin Skin by ForumMonkeys. Powered by vBulletin®.
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.