Jump to content

Recommended Posts

Posted (edited)

Hi everyone,

 

I am just doing basic testing of scripting at a waypoint.

So at Wpt 1 I have added a simple :

do script --> trigger.action.outText("SCRIPT : F16 passing Wpt1" , 10)

and

do script file --> testDoScript.lua (with just one line : trigger.action.outText("FILE : F16 passing Wpt1" , 10))

 

When I run the mission

- I see the "SCRIPT : F16 passing Wpt1" message

- but I do NOT see the "FILE : F16 passing Wpt1" message

 

What am I doing wrong ?

Must the lua instructions in the file enbeded in a lua function or whatever ?

 

Thanks

Edited by CougarFFW04
Posted
28 minutes ago, =475FG= Dawger said:

Upload the mission so someone can look at it. Likely a syntax error. 
 

If you are trying to run a file containing lua, you must use DO SCRIPT FILE

 

 

OK will upload this evening

DO SCRIPT FILE => what I am speaking about

Posted (edited)
7 minutes ago, dark_wood said:

place your Lua line between do and end statements:

 

do

    trigger.action.outText("SCRIPT : F16 passing Wpt1" , 10)

end

Pretty sure I tried this as well but didn't work.

Will try again and report

Edited by CougarFFW04
Posted

Maybe is an issue with the waypoint approach.

Try to call the script file as usual (not on waypoint): ONCE > Time more 10 > Do Script File

If this is working, then you must use something else to achieve your goal - place small zones around waypoint, and use unit in zone, for example.

Posted
6 minutes ago, dark_wood said:

Maybe is an issue with the waypoint approach.

Try to call the script file as usual (not on waypoint): ONCE > Time more 10 > Do Script File

If this is working, then you must use something else to achieve your goal - place small zones around waypoint, and use unit in zone, for example.

I will try but would be surprise that it could be the issue because the script is executed properly

Posted (edited)

That mission has no triggers.

 

1 hour ago, CougarFFW04 said:

So here it is.

 

Oh, wait. You attached the scripts to waypoints. Silly me. 

Edited by cfrag
Posted

I tested this. It does not appear that Script File in Advanced Waypoint Actions works. What I would suggest is that you set a flag at waypoint passage and have the flag = true fire off the script via a mission trigger.

 

 

 

 

EDsignaturefleet.jpg

Posted
28 minutes ago, CougarFFW04 said:

Yes it's what I want to test : scripting things at waypoint via lua file

 

Can't get it to work either. Strange indeed.

 

Posted
23 minutes ago, =475FG= Dawger said:

I tested this. It does not appear that Script File in Advanced Waypoint Actions works. What I would suggest is that you set a flag at waypoint passage and have the flag = true fire off the script via a mission trigger.

That's a workaround

BUT should'nt this work...

Posted
33 minutes ago, CougarFFW04 said:

That's a workaround

BUT should'nt this work...

Welcome to scripting in DCS.
 

Don’t beat your head against the “it should work” wall.

 

Find a different path to get to your goal and keep moving forward. 

 

 

 

 

EDsignaturefleet.jpg

Posted (edited)

Something else that always trips up DCS scripting newbies is that DCS doesn't automatically reload LUA files that are loaded via the Run Script or Do Script File commands. This means you can find yourself making a ton of changes to a file... and then seeing absolutely no change in the mission. The brute force way of addressing this is by going back to the Run Script or Do Script File commands and reselecting the LUA file via the file browser... but that's really horrible, and really error prone. 

 

The better solution is to use the Do Script command and just insert the following line of LUA:

 

dofile("C:/<...path to the folder...>/MyLuaFile.lua")

 

This ensures that the LUA file is always reloaded and refreshed every time you run the mission. Hope that helps.

 

 

Loading.PNG

 

Edited by Pizzicato
  • Like 1
  • Thanks 1

i7-7700K @ 4.9Ghz | 16Gb DDR4 @ 3200Mhz | MSI Z270 Gaming M7 | MSI GeForce GTX 1080ti Gaming X | Win 10 Home | Thrustmaster Warthog | MFG Crosswind pedals | Oculus Rift S

Posted
On 10/12/2021 at 5:24 PM, Pizzicato said:

Something else that always trips up DCS scripting newbies is that DCS doesn't automatically reload LUA files that are loaded via the Run Script or Do Script File commands. This means you can find yourself making a ton of changes to a file... and then seeing absolutely no change in the mission. The brute force way of addressing this is by going back to the Run Script or Do Script File commands and reselecting the LUA file via the file browser... but that's really horrible, and really error prone. 

 

The better solution is to use the Do Script command and just insert the following line of LUA:

 

dofile("C:/<...path to the folder...>/MyLuaFile.lua")

 

This ensures that the LUA file is always reloaded and refreshed every time you run the mission. Hope that helps.

 

 

Loading.PNG

 

 

This works for mission testing.  Just remember when you make your mission available to others, that you need to load the actual lua into the mission.

-Wraith

  • Like 1
Posted
On 10/12/2021 at 12:42 PM, =475FG= Dawger said:

Welcome to scripting in DCS.
 

Don’t beat your head against the “it should work” wall.

 

Find a different path to get to your goal and keep moving forward. 

 

Which of us hasn't left a dent in that damn wall?  🙃

 

Banner EDForum2020.jpg

Have fun. Don't suck. Kill bad guys. 👍

https://discord.gg/blacksharkden/

  • Recently Browsing   0 members

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