-
Posts
583 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Everything posted by AKA_Clutter
-
Interesting read. I am so fricking far behind the curse it's ridiculous.
-
HI All, I am trying to use the timer.scheduleFunction to call a function, but to call it with multiple arguments, (Group_Name, GRP_Size_Prob). I have tried enclosing the multiple arguments in both () and {}, and it always gives an error when it gets to local Current_Group = Group.getByName(Group_Name) in the called function. The code runs fine if I call it with just one argument, Group_Name. Below is a simplified version, and following that more of the code (not the full listing) Please keep in mind that I am a noob at lua/programing/DCS API. Thanks, Clutter <><><><><><><> timer.scheduleFunction(Adjust_Num_Units_In_Group, {Group_Name, 0.25}, timer.getTime() + Group_Time + 1) function Adjust_Num_Units_In_Group (Group_Name, GRP_Size_Prob) -- Function to determine if the group has 2 of 4 planes, and then delete planes 3 and 4 local Current_Group = Group.getByName(Group_Name) -- CHeck to see if the group exist. if not Current_Group then return end -- no such group local size = Current_Group:getSize() -- how many in group … end timer.scheduleFunction(Adjust_Num_Units_In_Group, {Group_Name, 0.25}, timer.getTime() + Group_Time + 1) -- change (F_A2A_LAG_1 ~= nil) to (LAG1 ~= nil) and retry -2/12/23 still to test function Adjust_Num_Units_In_Group (Group_Name, GRP_Size_Prob) -- Function to determine if the group has 2 of 4 planes, and then delete planes 3 and 4 local Current_Group = Group.getByName(Group_Name) -- CHeck to see if the group exist. if not Current_Group then return end -- no such group local size = Current_Group:getSize() -- how many in group if size >=3 then local Size_Prob_Calc = math.random() if (Size_Prob_Calc > GRP_Size_Prob) then for i= 3, size do local allUnits = Current_Group:getUnits() if not allUnits then return end -- sanity check trigger.action.outText("Group " .. Current_Group:getName() .. " has " .. size .. " units and I will remove unit number " .. i, 30) local unitToRemove = allUnits[i] unitToRemove:destroy() -- remove it from game end else trigger.action.outText("Group " .. Current_Group:getName() .. " has " .. size .. " units and none will be removed", 30) end else trigger.action.outText("Group " .. Current_Group:getName() .. " has " .. size .. " units and none will be removed", 30) end end function Spawn_A2A_LAG (Group_Name, Group_Prob, Group_Time) --[[ Group_Name, A2A_LAG_TBL[1][1] Group_Prob, A2A_LAG_TBL[1][2] Group_Time A2A_LAG_TBL[1][3] --]] local Current_Group = Group.getByName(Group_Name) if (Current_Group ~= nil) then local x= math.random() if (x <= Group_Prob) then -- trigger.action.outTextForCoalition(2,MSG_Header .. "A2A_LAG_1 will be spawned. Probability is " .. x .. MSG_Footer, 15) timer.scheduleFunction(F_A2A_LAG_1, Current_Group, timer.getTime() + Group_Time) -- Activate Enemy CAP flight group 1 -- trigger.action.outTextForCoalition(2,"\n====================\n\n TSS_A2A_LAG_1 is " .. TSS_A2A_LAG_1 .. "!\n\n====================", 10) A2A_Count = A2A_Count +1 -- Increment A2A counter TBL_A2A_LAG_Times[A2A_Count] = math.floor((Group_Time/60)*100)/100 -- Add LAG start time to table - Convert to minutes timer.scheduleFunction(Adjust_Num_Units_In_Group, {Group_Name, 0.25}, timer.getTime() + Group_Time + 1) -- Line to adjust units in A2A_LAG group based on a given probability else trigger.action.outTextForCoalition(2,MSG_Header .. "A2A_LAG_1 will not be spawned, Probability is " .. x .. MSG_Footer, 15) end end end -- End of function Spawn_A2A_LAG for i = 1, 2 do A2A_LAG_Spawn = Spawn_A2A_LAG (A2A_LAG_TBL[i][1], A2A_LAG_TBL[i][2], A2A_LAG_TBL[i][3]) -- A2A_LAG_2 = Spawn_A2A_LAG (A2A_LAG_TBL[2][1], A2A_LAG_TBL[2][2], A2A_LAG_TBL[2][3]) end
-
Just starting to run some test. I call math.random() 20 times in the script I'm developing. In three runs, i got .9 or greater 11 times. 11 out of 60 is 18%. Yes, I only have a small sample set, but that seems a little high. also bothersome is that it appeared 3 or so times in each run. And I may give the local seed = math.random(1,10000000) suggestion a try. More testing to do.
-
I'm sure there is a way to do that. I believe "timer.getTime() gets the mission start time and is static for a mission. I know that os.time will change over the course of time. Since I am running this script at 2 sec into the mission, and it sets everything then, I'm not sure that there is much difference for a specific mission. I would like there to be a noticeable difference between mission ran using this script. For that purpose, what Grimes listed above is probably sufficient. Besides that, it is just a "science" discussion/project, trying to understand what's going on and if there is a better way to do it.
-
@Grimes _ Thanks very much for the response. I did see in Hoggit (I think) that MIST has a function for this. What I want to do is vary the spawn times with in a 10 - 20-minute window., so the numbers aren't huge. I may want to do a range between 30 and 150 minutes. Would that be getting too large with this function?. Also, what is considered a "small range"? TIA
-
Hi, As the to[pic said, I'm looking at the best way to generate random numbers within a lua script without using os.time() (which requires you to deactivate the os sanitation script). I saw a recommendation in a 2016 post to just run math.random() a few times at the start of the script. THis seems to work OK, but also seems to generate the same number on several different runs. That for the suggestions in advance.
-
Is there any 'solution" to this issue? ONe that smooths out the stickiness when moving in the diagonal directions? Sounded very promising.
-
random seeds in DCS Scripts
AKA_Clutter replied to AKA_Clutter's topic in Scripting Tips, Tricks & Issues
Thanks for all the information. And I will consider alternate ways to generate a seed. I did try desanitizing os via commenting out the lines. Although the file looks like it took my changes, I still got the error. EDIT - I just looked at it (MissionScripting.lua) again, and it is back to the sanitized version. So not sure why it keeps changing MissionScripting.lua Again, thanks for the information and the recommendation. -
random seeds in DCS Scripts
AKA_Clutter replied to AKA_Clutter's topic in Scripting Tips, Tricks & Issues
Humm, that doesn't seem to be it. I commented out the three sanitize lines and still get the same error. I use the call in a non-dcs lua file and it works as advertised. Any other guesses? -
random seeds in DCS Scripts
AKA_Clutter replied to AKA_Clutter's topic in Scripting Tips, Tricks & Issues
It may be the desensitized part. Thanks. -
Hi, I want to create some randomness in my missions via scripts. I know that you can use math.random () lua function. I asl oknow that you can use math.randomseed() to set the seed for the random number generator. I also know that in lua I can use math.random(os.time()). However, I have tried using this inside of a script running in DCS and it gives me an erro stating something about trying to concatenate os with a nil value. Anyone know why I might be getting this, and what is a good seed to use for the RNG? Thanks --[[ ========================================================== Define functions to deterime random time ========================================================== --]] math.randomseed(os.time()) local function Random_Time_Window_10 () RTW_10 = math.random (0,10) return (RTW) end
-
hehe - Works like a charm. Unit.getByName('A2A_LAG_1-3'):destroy() Unit.getByName('A2A_LAG_1-4'):destroy() That is a s long as I know the unit name. That shouldn't be a problem with what I'm doing now, but I assume that you get it from just know the group name via a form of getGroup. Is that on the correct track? Thanks for pointing me in the correct direction!
-
Hi, I'm a noob to scripting and the the DCS Scripting Engine. I've looked at the DCS Hoggit DCS Simulator Scripting Engine documentation, but QUICKLY get lost. So, being a little lazy, I thought I would ask here to see if someone could point me in the correct direction. What I would like to do is to change the number of units in a group that I have added via the ME, from 1, to 2, 3, or 4. I know that it is EASILY done in the ME. 1) can that be done via scripting? 2) Is there an existing function to do that with? 3) would it require setting up a unit table(??) for each unit to be added? Again, just looking for pointers on where to start, or a simple "Can't be done". Thanks,
-
1) I put in the delay because I thought I saw somewhere that they needed time to load. None are really dependent on each other or the order. 2) I'm not sure what you mean by "executing asynchronously", and less what impact/importance it may have. I am a newbie when it comes to programing and doing lua scripts. 3) Wouldn't the Do FIle and Set flag execute at the same time? Is that sufficient time that it would overwrite each other. Again, this may be due to my neophyte understanding of how scripts are loaded and work. Thanks for the response.
-
Hi, I have a question about how much delay one should add between "Do Script" and "Do Script FIle". IN general I have been using the Time More () condition to do this. I for those files that I think are large, I have used 4 seconds. For the smaller ones, I have use 2 second intervals. These files are nowhere near as large as MOOSE and such, and I really don't know what "large" is. So, what is a reasonable interval to load script files? TIA
-
Dumb question. Do I need to download and install OpenXR. If so where do I get it?
-
Tried it with and without Steam VR and it hangs at the main menu. Any suggestions?