Jump to content

TUTORIAL - Running and editing scripts without restarting the game


Pikey

Recommended Posts

I had some requests for this. I think it's fair to say we all use our own workflows when designing missions with script files and know how long it takes. One major hurdle is the time it takes to edit a script file that's in a mission file.

 

This is because the ME doesn't check if a file has changed, just it's name. The solutions are many, you can use FSF_Ian's LUA interpreter, you can write the script into a "DO SCRIPT", you can even try opening the file directly and swapping the new scripts in via 7zip. But none of these are simple, or as simple as the following. If you haven't come across this, it will save you a lot of time. And I know at least some of you haven't, so saving a few of you hours across the years coming, is well worth the two hours it took to get this up there.

 

The following video will show you how to:

1) Edit scripts on the fly and run them in the game without restarting the mission.

2) Give you some ideas on how to shorten your troubleshooting workflow with scripting

3) Demonstrate live, running a script, editing it, chasing an error and re-running it, all in the same mission

4) Give a new scripter a way of testing out LUA directly in game and it's effects and perhaps encourage them to learn more

 

This example uses MOOSE, but it's applicable to standalone scripts, snippets, ATME and of course MIST.

 

 

I'm thinking of doing some follow ups if this generates interest. I'd like to say, I've had no formal development background whatsoever! I'm a techie. If any of it makes you shudder, remember people have to learn this without formal education!

  • Like 6

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Link to comment
Share on other sites

can you post the missile trainer?

AWAITING ED NEW DAMAGE MODEL IMPLEMENTATION FOR WW2 BIRDS

 

Fat T is above, thin T is below. Long T is faster, Short T is slower. Open triangle is AWACS, closed triangle is your own sensors. Double dash is friendly, Single dash is enemy. Circle is friendly. Strobe is jammer. Strobe to dash is under 35 km. HDD is 7 times range key. Radar to 160 km, IRST to 10 km. Stay low, but never slow.

Link to comment
Share on other sites

Do you mean the moose test mission with it in or how to use it?

 

 

 

yes the mission as a youtube video. I want to see how it looks like.

 

 

Sent from my iPhone using Tapatalk

AWAITING ED NEW DAMAGE MODEL IMPLEMENTATION FOR WW2 BIRDS

 

Fat T is above, thin T is below. Long T is faster, Short T is slower. Open triangle is AWACS, closed triangle is your own sensors. Double dash is friendly, Single dash is enemy. Circle is friendly. Strobe is jammer. Strobe to dash is under 35 km. HDD is 7 times range key. Radar to 160 km, IRST to 10 km. Stay low, but never slow.

Link to comment
Share on other sites

Great video! This is definitely the way to go if you are developing a mission script.

 

The Lua console in DCS Witchcraft was not designed for larger scripts (it does not even have a save function). It works well with small, ephemeral code snippets, for example to inspect the contents of global variables without running your script again or to interactively figure out how to use a single function in the DCS: World API.

 

I'd like to say, I've had no formal development background whatsoever! I'm a techie. If any of it makes you shudder, remember people have to learn this without formal education!

 

Don't worry about formal training, it does not matter. I have a BSc in Computer Science, but that does not mean I know how to program anything more complex than a reference implementation of an algorithm without any error handling. (Maybe I should have studied Software Engineering instead.)

 

I did not learn much about error handling, debugging, using a version control system, and writing maintainable software in lectures. I learned about these things because I was programming in my student jobs and as a hobby.

 

For most software, the hard part in creating it is not figuring out new algorithms. It's managing complexity. It's structuring the code in a way that will be maintainable in the future.

 

I wrote my first lines of code 20 years ago and have been programming as a hobby ever since. I still feel like I don't know what I am doing. I also think that no amount of formal training will help with that; I'll just have to get a job and gain more experience, one mistake at a time.

Link to comment
Share on other sites

Oh sure, not knowing things doesn't worry me (did in my 20's) but then experience tells me I can learn things the hard way. :) I'll have a go at anything, I love experiences!

Reminds me of the saying, "Experience is a hard teacher. She gives you the test first and the lesson after."

I'm doing some scripts now that are quite hard to pick up and read if i'm not constantly at them and i'm learning why people write with good spacing and tab discipline for their loops and so. But painfully coming to this realisation now...

Ian;3128505']Great video! This is definitely the way to go if you are developing a mission script.

 

The Lua console in DCS Witchcraft was not designed for larger scripts (it does not even have a save function). It works well with small, ephemeral code snippets, for example to inspect the contents of global variables without running your script again or to interactively figure out how to use a single function in the DCS: World API.

 

 

 

Don't worry about formal training, it does not matter. I have a BSc in Computer Science, but that does not mean I know how to program anything more complex than a reference implementation of an algorithm without any error handling. (Maybe I should have studied Software Engineering instead.)

 

I did not learn much about error handling, debugging, using a version control system, and writing maintainable software in lectures. I learned about these things because I was programming in my student jobs and as a hobby.

 

For most software, the hard part in creating it is not figuring out new algorithms. It's managing complexity. It's structuring the code in a way that will be maintainable in the future.

 

I wrote my first lines of code 20 years ago and have been programming as a hobby ever since. I still feel like I don't know what I am doing. I also think that no amount of formal training will help with that; I'll just have to get a job and gain more experience, one mistake at a time.

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Link to comment
Share on other sites

can you post the missile trainer?

 

You can use it immediately! What do you mean with "post?"

A video?

[TABLE][sIGPIC][/sIGPIC]|

[/TABLE]

Link to comment
Share on other sites

You can use it immediately! What do you mean with "post?"

 

A video?

 

 

 

yes please

 

 

Sent from my iPhone using Tapatalk

AWAITING ED NEW DAMAGE MODEL IMPLEMENTATION FOR WW2 BIRDS

 

Fat T is above, thin T is below. Long T is faster, Short T is slower. Open triangle is AWACS, closed triangle is your own sensors. Double dash is friendly, Single dash is enemy. Circle is friendly. Strobe is jammer. Strobe to dash is under 35 km. HDD is 7 times range key. Radar to 160 km, IRST to 10 km. Stay low, but never slow.

Link to comment
Share on other sites

Noob question... Maybe I've missed it in the video...

 

Where do I put the loader script called with the do script assert?

 

Thanks

 

Inviato dal mio ALE-L21 utilizzando Tapatalk

 

It is in the video, look closely, right panel of the trigger system, inside a Do Once trigger.

Link to comment
Share on other sites

  • 3 weeks later...

Hi, Pikey,

I would appreciate any more info you can give on Lua Projects and editing simple scripts while the game is running. I've watched the video a few times and set up the MOOSE_Framework and MOOSE_Missions, as well as a mission development folder. Using the Eclipse Lua LDT, I made Lua Projects for these, but I did not see a way to edit a Lua Project or delete them to rebuild them, so now I am downloading and starting over.

 

As an example of my immediate goal, I want to edit a script that detects aircraft clients and be able to test changes as I go. This script is already in the mission in a Do Script. I want to make improvements to detect clients in any blue plane, and make changes in an If line to eliminate the '-- do nothing' line that follows. This is an example of my script:

[size="1"]-- script.appendAircraftClientNames
do
aircraftUnitTypes = {'F-15C', 'AJS37', 'M-2000C', 'MiG-21Bis'}
-- aircraftUnitTypes = {'[blue][plane]'}
local function contains(tbl, val)
 for _,v in ipairs(tbl) do
  if v == val then return true end
 end
 return false
end
for uName, uData in pairs(mist.DBs.humansByName) do
 -- if uData.type == 'F-15C' or uData.type == 'AJS37' or uData.type == 'M-2000C' or uData.type == 'MiG-21Bis' then
 if(contains(aircraftUnitTypes, uData.type)) then
  if(contains(aircraftClientNames, uName)) then
   -- do nothing
  else
   table.insert(aircraftClientNames, uName)
  end
 end
end
end[/size]

 

Also, that log viewer looked pretty nice, plus any tips you have to pass along - like your mention of restarting the mission to see if changes work.

Visit the Hollo Pointe DCS World server -- an open server with a variety of COOP & H2H missions including Combined Arms. All released missions are available for free download, modification and public hosting, from my Wrecking Crew Projects site.

Link to comment
Share on other sites

LDT is my blind spot. I just broke mine again. However, I don't do anything not covered by the video, I just create a new lua file in the an existing project space and load dynamically in game. Nothing else. Literally. I use LDT as a notepad ++ +.

I restart the mission with LShift-R, if the script needs it, since you will load the orignal script twice and all the global variables will be overwritten but not the local ones and things get messy fast. But for snippets it's awesome. Not sure what else I can add? Two popular log trailers - LogExpert and Glogg.

Hi, Pikey,

I would appreciate any more info you can give on Lua Projects and editing simple scripts while the game is running. I've watched the video a few times and set up the MOOSE_Framework and MOOSE_Missions, as well as a mission development folder. Using the Eclipse Lua LDT, I made Lua Projects for these, but I did not see a way to edit a Lua Project or delete them to rebuild them, so now I am downloading and starting over.

 

As an example of my immediate goal, I want to edit a script that detects aircraft clients and be able to test changes as I go. This script is already in the mission in a Do Script. I want to make improvements to detect clients in any blue plane, and make changes in an If line to eliminate the '-- do nothing' line that follows. This is an example of my script:

[size=1]-- script.appendAircraftClientNames
do
aircraftUnitTypes = {'F-15C', 'AJS37', 'M-2000C', 'MiG-21Bis'}
-- aircraftUnitTypes = {'[blue][plane]'}
local function contains(tbl, val)
 for _,v in ipairs(tbl) do
  if v == val then return true end
 end
 return false
end
for uName, uData in pairs(mist.DBs.humansByName) do
 -- if uData.type == 'F-15C' or uData.type == 'AJS37' or uData.type == 'M-2000C' or uData.type == 'MiG-21Bis' then
 if(contains(aircraftUnitTypes, uData.type)) then
  if(contains(aircraftClientNames, uName)) then
   -- do nothing
  else
   table.insert(aircraftClientNames, uName)
  end
 end
end
end[/size]

Also, that log viewer looked pretty nice, plus any tips you have to pass along - like your mention of restarting the mission to see if changes work.

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Link to comment
Share on other sites

Your script above is a perfect example of where the MOOSE function "SET" becomes awesome. Names those client groups with a "C-" and you can target them.

MySet = SET_GROUP:New():FilterPrefixes("C-"):FilterStart()

 

It tracks and updates clients, groups, units by name, coalition, a prefix or manually adding and other ways and then you can manipulate or target them as a single object without managing a table. Then you can target your SET and iterate a function on them to your hearts content.

http://flightcontrol-master.github.io/MOOSE/Documentation/Set.html##(SET_CLIENT).ForEachClient

 

Also on re-reading your comments on restarting the mission, i'm not sure if you were seeing me launch the script from in the game and doing it yet again without restarting the mission. Let me know if you missed this, as it was the entire point! ;)

Hi, Pikey,

I would appreciate any more info you can give on Lua Projects and editing simple scripts while the game is running. I've watched the video a few times and set up the MOOSE_Framework and MOOSE_Missions, as well as a mission development folder. Using the Eclipse Lua LDT, I made Lua Projects for these, but I did not see a way to edit a Lua Project or delete them to rebuild them, so now I am downloading and starting over.

 

As an example of my immediate goal, I want to edit a script that detects aircraft clients and be able to test changes as I go. This script is already in the mission in a Do Script. I want to make improvements to detect clients in any blue plane, and make changes in an If line to eliminate the '-- do nothing' line that follows. This is an example of my script:

[size=1]-- script.appendAircraftClientNames
do
aircraftUnitTypes = {'F-15C', 'AJS37', 'M-2000C', 'MiG-21Bis'}
-- aircraftUnitTypes = {'[blue][plane]'}
local function contains(tbl, val)
 for _,v in ipairs(tbl) do
  if v == val then return true end
 end
 return false
end
for uName, uData in pairs(mist.DBs.humansByName) do
 -- if uData.type == 'F-15C' or uData.type == 'AJS37' or uData.type == 'M-2000C' or uData.type == 'MiG-21Bis' then
 if(contains(aircraftUnitTypes, uData.type)) then
  if(contains(aircraftClientNames, uName)) then
   -- do nothing
  else
   table.insert(aircraftClientNames, uName)
  end
 end
end
end[/size]

Also, that log viewer looked pretty nice, plus any tips you have to pass along - like your mention of restarting the mission to see if changes work.

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Link to comment
Share on other sites

  • 5 months later...
  • Recently Browsing   0 members

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