check time with os.date in lua

  • #1, by andy-rinaldiSunday, 22. February 2015, 17:28 10 years ago
    Hi guys,
    Can I check the time with os.date? I would count 1 minute from last autosave.
    Something like:
    if timepast < os.date("%X, %d/%m/%y") then do something
    end
    

    Thanks.

    Forum Fan

    160 Posts


  • #2, by afrlmeSunday, 22. February 2015, 18:18 10 years ago
    err... for what?

    Could you explain what you are wanting to do please, as the example code you provided there doesn't really mean a right lot.

    Imperator

    7285 Posts

  • #3, by andy-rinaldiSunday, 22. February 2015, 22:12 10 years ago
    ahah, sorry.
    I don't want execute an autosave if I already execute an autosave within 1 minute. Between 1 autosave and the other has to go at least 1 minute. You know what I mean?
    Thanks.

    Forum Fan

    160 Posts

  • #4, by afrlmeSunday, 22. February 2015, 23:29 10 years ago
    So you want to create an actual autosave system that autosaves every x time? Or do you mean as a prevention mention, to prevent the player from saving the game again, if they have recently saved already?

    If it's the prevention measure then...

    1. create a condition 'can_save' & set to false or true as default (whatever you need it to be).

    2. wrap the autosave actions inside of an if query.
    if condition 'can_save' is true
     execute autosave #?
    end if
    


    3. create a called by other action & name it prevent_save. Inside of this action add these action parts...
    change condition 'can_save' to false
    pause for x time
    change condition 'can_save' to true
    


    4. inside of actions where you execute the autosave, create a call action 'prevent_save' immediately after executing the autosave.

    That should about sort it out methinks. smile

    Imperator

    7285 Posts

  • #5, by andy-rinaldiSunday, 22. February 2015, 23:49 10 years ago
    It's the prevention measure. Your solution works fine. You're the best, Lee!



    Forum Fan

    160 Posts

  • #6, by afrlmeSunday, 22. February 2015, 23:57 10 years ago
    No problem.

    I just sent you a pm (I don't know if it sent or not) my net is being a bit of a bugrit at the minute.

    Imperator

    7285 Posts