Various LUA Script Examples [indexed]

  • #20, di afrlmeFriday, 30. November 2012, 18:38 horas 12 years ago
    ok dokie I scrapped the original createScreenshot() method for a much improved version which checks if a file already exists before saving as opposed to the previous script which counted the amount of screenshots that exist on game launch.

    the problem with the previous script was that it didn't take into account that if someone deleted a random screen_x.png file that it stopped looping the check_cond() function as soon as it returned a file does not exist!

    the new method runs when you hit the create screenshot key - "F12" in this case & continues to loop until it returns a file does not exist!

    this method prevents you from accidentally overwriting existing files & on the whole the amount of code needed is significantly much less than the first script wink

    I have left the original script link on the thread & have also added a project file for the new script version!

    P.S don't forget to comment out the 2 print statements on the file exists part - you'll know which they are as I added a "-- comment this out ..." after both of them, otherwise each time you press screenshot it will print a load of "screen_x.png already exists!" into the log file (messages.txt) - which I only added to check if the script was working correctly smile

    if you have noticed I have recently started adding extra "print('-- * --')" to my scripts before certain print statements ... I have been adding these to create a line break (separation line) between various log messages so we don't end up with a ton of clumped together randomness!

    Imperatore

    7278 Posts


  • #21, di afrlmeSaturday, 01. December 2012, 16:34 horas 12 years ago
    Marvel has enabled the Wiki thingy so I have started adding the various LUA scripts to that too wink

    hopefully they'll install the GitHub system David mentioned to me in a pm as that would be a really nice feature for the forum, scripting, bug finding, to do lists & much more - all color coded & so on too which will be nice - there used to be a similar tool on a smf forum I used to be active on & it was a really good feature! smile

    Imperatore

    7278 Posts

  • #22, di afrlmeThursday, 03. January 2013, 03:40 horas 12 years ago
    ok seeing as I've added all my lua examples & loads of other stuff to the wiki - I am no longer updating this thread so bookmark this link!

    it's the sticky topics page I have created which contains links to loads of useful threads, information & external resources; all compiled into various categories for ease of use wink

    all my lua scripts as well as other peoples can be found in the linked wiki page, sorted into categories of how complicated the scripts are.

    there's also a general FAQ explaining the various license options for Visionaire Studio & the recommended audio/video formats & so on.

    safe smile

    Imperatore

    7278 Posts

  • #23, di brut69Monday, 14. January 2013, 12:45 horas 12 years ago
    Any samples or ideas on how to create a 4 digit randomizer?

    Basically I want each time the player clicks on button (action) I made to randomly generate a 4 digit code which is stored as an integer so I can use it later on.

    Any ideas?

    Gran Messaggero

    266 Posts

  • #24, di afrlmeMonday, 14. January 2013, 13:42 horas 12 years ago
    you can use the values inside of the editor ... (1 value per each digit) they have an option to randomly generate a value between the min/max numbers you set.

    there's also a "set random value" action inside of select action part > condition, if, value ...

    values will be saved on game save / quick save.

    you could also use lua to write the value(s) to an external file if you liked?

    may I ask what it is for?

    Imperatore

    7278 Posts

  • #25, di brut69Tuesday, 15. January 2013, 09:56 horas 12 years ago
    I will be randomly generating 4 digit codes which I will later then use as a key so I can generate different answers each time a player clicks on an item.

    Gran Messaggero

    266 Posts