Jump to content

Noob needing basic help on script running


Dangerzone

Recommended Posts

I'm sorry for asking such a stupid question but I've spent over an hour trying to do the most basic thing and I'm going around in circles.

 

I've created a mission. In the mission directory I have:

 

launcher.lua

moose.lua

test.lua

mymission.miz

 

On the mission I have a trigger - Run once - Time more than 1, to do script file (launcher.lua)

 

launcher contains the following:

dofile(".\\Moose.lua")
MESSAGE:NEW("Moose Loaded",10):ToAll()

 

I never get the message to appear.

 

If on the other hand I actually call moose.lua in the mission editor instead, and then run test.lua which contains the single line:

MESSAGE:NEW("Moose Loaded",10):ToAll()

I get the message to display successfully.

 

I'm guessing that dofile is not working correctly.

 

I have also tried the following without success:

 

dofile('c:\users\myname\Saved Games\DCS\Missions\MyMission\Moose.lua")

and

dofile(Moose.lua)

and

dofile(lfs.writedir() .."Missions\MyMission\Moose.lua")

 

all unsuccessful.

 

All I'm trying to achieve is to get my launcher.lua script file to launch another script file (aka moose.lua) and then display a message so I can have everything within a single file instead of the mission editor.

 

Can someone please tell me the stupid thing I'm doing wrong? 😏

Link to comment
Share on other sites

Check out this tutorial:

 

Also, I may be wrong but MESSAGE:New() is a MOOSE command. Loading MOOSE while simultaneously calling a MOOSE class doesn't work because MOOSE takes a second or two to load. If you want to display a message when loading in MOOSE you'll need to use SSE commands like:

trigger.action.outText("Test Test Test", 10, true)


Edited by TMacDeezy
Link to comment
Share on other sites

Thank you. That has indeed helped. Looks like the issue I had was the backslashes needed to be doubled up. 

 

dofile("C:\\Users\\myname\\Saved Games\\DCS\\Missions\\MyMission\\Moose.lua")
MESSAGE:NEW("Moose Loaded 101",10):ToAll()

I would much prefer for it to be able to just find the same directory I've launched my .miz file from - but at this stage I'll work with hardcoding a full path. 

 

Edit: 

 

Ended up creating a new file to call from the mission log:

 

env.info("XDEBUG: Launching Loader.lua")
missionpath = "C:\\Users\\User\\Saved Games\\DCS\\Missions\\MyMissions\\"
dofile(missionpath .."loader2.lua")

 

This way I just call loader.lua from the mission editor, and in loader2.lua I can do all my loading of moose, ctld, mist, etc by using the missionpath variable as such. It means if I copy or move the mission there's only one location I need to update to make it work.


Edited by Dangerzone
Link to comment
Share on other sites

  • Recently Browsing   0 members

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