CougarFFW04 Posted October 12, 2021 Posted October 12, 2021 (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 October 12, 2021 by CougarFFW04
=475FG= Dawger Posted October 12, 2021 Posted October 12, 2021 (edited) 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 Edited October 12, 2021 by =475FG= Dawger
CougarFFW04 Posted October 12, 2021 Author Posted October 12, 2021 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
dark_wood Posted October 12, 2021 Posted October 12, 2021 place your Lua line between do and end statements: do trigger.action.outText("SCRIPT : F16 passing Wpt1" , 10) end
CougarFFW04 Posted October 12, 2021 Author Posted October 12, 2021 (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 October 12, 2021 by CougarFFW04
=475FG= Dawger Posted October 12, 2021 Posted October 12, 2021 Your DCS log will tell you if there is an issue loading the lua file. That is the first place to look.
dark_wood Posted October 12, 2021 Posted October 12, 2021 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.
CougarFFW04 Posted October 12, 2021 Author Posted October 12, 2021 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
CougarFFW04 Posted October 12, 2021 Author Posted October 12, 2021 Hi, Definitively doesn't work. Certainly something went wrong Didn't see anything in DCS log So here it is. Thanks ScriptTest.miz
cfrag Posted October 12, 2021 Posted October 12, 2021 (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 October 12, 2021 by cfrag
CougarFFW04 Posted October 12, 2021 Author Posted October 12, 2021 Yes it's what I want to test : scripting things at waypoint via lua file
=475FG= Dawger Posted October 12, 2021 Posted October 12, 2021 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.
cfrag Posted October 12, 2021 Posted October 12, 2021 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.
CougarFFW04 Posted October 12, 2021 Author Posted October 12, 2021 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...
=475FG= Dawger Posted October 12, 2021 Posted October 12, 2021 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.
CougarFFW04 Posted October 12, 2021 Author Posted October 12, 2021 What a peine to have such simple things to work... Will report as a bug Thanks anyway
Pizzicato Posted October 12, 2021 Posted October 12, 2021 (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. Edited October 12, 2021 by Pizzicato 1 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
CougarFFW04 Posted October 12, 2021 Author Posted October 12, 2021 Hi Pizzcato, I am already aware of this and always use the dofile things. Thanks anyway 1
wraith70 Posted October 14, 2021 Posted October 14, 2021 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. 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 1
fargo007 Posted October 14, 2021 Posted October 14, 2021 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? Have fun. Don't suck. Kill bad guys. https://discord.gg/blacksharkden/
Recommended Posts