Jump to content

Recommended Posts

Posted

I am trying to fly a downloaded mission, but the attached LUA script returns an error:

 

String" [--Change the values in the 2 variables low..."]attempt to index global 'os' (nil value)

 

I do not know exactly what this script does in the mission; but I assume the problem lies with the os function in line 17, but I have no knowledge of how to fix it. Anyone wish to help with this?

Posted

by default, scripts can't access the OS. You can desanitize the lua environment by commenting out lines of some DCS lua files but it isn't recommended that you do it, unless it is for your own testing.

 

What is this supposed to achieve? Maybe you can do it another way? Maybe if you post the mission, someone will sort it for you :-)

Posted

Thanks. A token infantryman has this script in the trigger actions. Perhaps this script is intended to randomly activate groups based on OS time. Mission attached. It is one of those interesting missions that was probably broken by subsequent updates. Those updates may have rendered the script obsolete, as well.

Posted

Randomseed is not accessibly within the scripting environment, however it is not needed! math.random() is replaced by the simulations own randomization scripting, so a randomseed is not required to make it truly random.

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Posted

Grimes, I''m curious what the simulation's own randomisation scripting is? I have been using random flag values to set the math.randomseed. Are you saying that the DCS lua environment already randomises it and nothing is necessary?

 

Thanks

Posted

My understanding is that each time the sim loads it is supposed to use a new random seed. In the DCS.log there should be an entry for that, something like:

00008.325 INFO    DCS: Dispatcher: initial random seed = 3531977

 

I mean't to say in my first post that the OS library is not available, randomseed is available and you should be able to use it, but its not needed.

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Posted (edited)

That script is a randomisation script I wrote quite some time ago in an earlier version of DCS when we had access to OS functions. OS functions were taken out of the scripting environment due to obvious security reasons

 

If you delete the line math.randomseed( OS.time() ) it should work fine.

 

It may be worth mentioning that the seeded value is also saved to the .trk file so that the mission plays back correctly.

 

The simulator scripting environment is passed a random seed. As to the code for that seed, it is done within the secure DCS environment and it's content is known only to the Dev. I suspect however that it uses the OS time to create.

Edited by Druid_

i7-7700K : 16Gb DDR4 2800 Mhz : Asus Mobo : 2TB HDD : Intel 520 SSD 240gb : RTX 2080ti: Win10 64pro : Dx10 : TrackiR4 : TM Warthog : ASUS ROG SWIFT PG348Q

Posted

Interesting discussion. After further review, it appears that script was intended only to randomize the activation of 5 sets of SHORAD (or am I wrong?). Much more direct to simply do that within the available trigger functions now.

 

I am using the fixing of these old, but nicely designed, missions as a vehicle to learn the ME functions. I really should post them to ED as they are updated.

  • 2 months later...
Posted

I'm pleased that my mission is deemed worth the effort of fixing scripting elements broken by changes in the way the engine handles randomization. I did indeed consult with Druid -- and, of course, Grimes -- in getting a simple randomization routine to work and, yes, all it does is vary the placement of defensive units by selecting amongst five possible arrangements.

 

Various people have taken it upon themselves to fix my missions post-DCSW, and, as I said, I'm flattered and grateful. Going forward, can anyone guide me re. how to accomplish the kind of randomization I was able to achieve -- via having my hand held by Druid and Grimes because I am a moron with scripting -- in the ME? If all I want to do is get the engine to choose one out of five arrangements of defenses, how would I do this in the ME?

Posted

With triggers:

 

Once> Random x% and Flag 1 is False> Set Flag 1 and Activate Group 1

Once> Random x% and Flag 1 is False> Set Flag 1 and Activate Group 2

etc.

 

Scripting isn't entirely needed for this sort of thing because you are still activating the group via triggers anyways. But you can do it simply with something like this:

 

trigger.action.setUserFlag(tostring(math.random(5)), true) Which will randomly set flag 1-5 true.

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

  • Recently Browsing   0 members

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