No457_Squog Posted January 19, 2016 Posted January 19, 2016 Hey folks! Just wondering if any of you lua adventurers have been able to generate random integers inside the description.lua ? The model viewer doesn't load the skin when I use either math.random() or os.time()My thinking is that the livery luas must be restricted to what calls they can make... Thanks in advance! [sIGPIC][/sIGPIC]
ajax Posted January 19, 2016 Posted January 19, 2016 If the module hasn't been sanitized, maybe you can try something like: base.os.time() base.math.random() or even _G.os.time() _G.math.random() I have no idea if this will work.
No457_Squog Posted January 19, 2016 Author Posted January 19, 2016 Thanks for the tips ajax! Unfortunately none of those have worked (at least in the model viewer). Can we assume that there is sanitization going on then? [sIGPIC][/sIGPIC]
ajax Posted January 20, 2016 Posted January 20, 2016 I believe the model viewer loads the default skins, which are in dcs\bazar\world\textures\ unless the model viewer autoexec file in dcs\config\modelviewer\ specifies otherwise. You may want to take a look at the config file rather than the skin description file to change the behavior.
No457_Squog Posted January 20, 2016 Author Posted January 20, 2016 Perhaps I'm not understanding what you mean when you say:I believe the model viewer loads the default skins[...]The model viewer is capable of loading a custom livery via View>Dialogs>Show Liveries Dialog - when testing my livery with experimental lua it fails to load the livery. Otherwise it loads fine - see screenshot below of custom livery: [sIGPIC][/sIGPIC]
No457_Squog Posted January 20, 2016 Author Posted January 20, 2016 Also - the autoexec cfg didn't have anything in it regarding sanitization - it only has ~50 lines. [sIGPIC][/sIGPIC]
ajax Posted January 21, 2016 Posted January 21, 2016 I guess I don't really understand what you are trying to do. My first response was generic -- just something to try if the standard functions are inaccessible. Then I re-read your post and saw you were talking about the model viewer. My second response was based on a (probably erroneous) assumption that you were trying to get the model viewer to cycle through skins automatically on startup. I was thinking that you would need to modify the model viewer autoexec.cfg file to do this -- that is all I meant. Even though the autoexc file does not have an explicit sanitation statement, its calling module might. If it fails to load the livery then my guess is that it's either: 1) there is a syntax error or 2) the compiler balks at one or both of those two functions.
Stonehouse Posted January 21, 2016 Posted January 21, 2016 (edited) He's trying to create a skin that is changeable on the fly. So if for instance you used the skin on 4 different aircraft you might be able to use a random number to end up with say a slightly different weathering texture on each one. It does kind of work at a basic level. We have a squadron skin that comes in two flavours western front and desert - by setting a local var at the top of the description lua you switch between the two texture sets but the weathering etc is the same. He came up with the idea of trying to go to the next step to attempt to make the skins more dynamic. Not talking about tail numbers etc as that's handled by the game already. Edited January 21, 2016 by Stonehouse
No457_Squog Posted January 21, 2016 Author Posted January 21, 2016 Right - all I want at the end of the day is a string or integer that is randomised; whether it is randomised per instance of the livery in-game or whether it is randomised once when the livery is initialised is beyond my control. Does anyone know of any randomisation function that is internal to the DCS engine? perhaps the calling module will allow the livery script to reference DCS internal classes? [sIGPIC][/sIGPIC]
Wrench Posted April 18, 2021 Posted April 18, 2021 I'm gonna necrobump this instead of starting a new topic on the same subejct. To be clear: I have a livery which includes textures for some of the weapons. Let's take the case of the MK-82. I'd like to have sayings painted on the bombs like 'Free candy', '1 dose freedom: administer daily', and my personal favorite, 'as per my last email' among others from google searches/made up by my vSqn. I can load a texture with something like that easily enough, but the problem is every Mk-82 on every aircraft is always the same. I'd really like DCS to 'pick' a random texture file for each bomb loaded on each aircraft. If this can be done in description.lua, that would be my first choice. If not, can someone point the way to a DCS mod I could make that would do it whenever a Mk-82 is spawned in the sim or something? Carrier Script.
Recommended Posts