0
$\begingroup$

I'm writing some code,to get the year, then check it during my load screen. If it's not 2017,I want the game object to destroy itself.. it will be a version of the game I give to friends for testing..So next year when I'm hopefully selling the game, it wont work for these test builds. Here's my code,somethings wrong, I usually don't code in python. I thought this would work. The object has an int property called dateok. It has another sensor to check dateok and destroy itself if the value is 1;

import datetime   
import bge

cont = bge.logic.getCurrentController()

def main():

    if day.year!=2017:

        owner = cont.owner
        dateok = cont.actuators['dateok']
        value = value.get(dateok.propname) +1
        dateok.value = str(value)
        cont.activate(dateok)
$\endgroup$
1
$\begingroup$

I suggest you check the current date:

from datetime import datetime

if datetime.now().year>2017:
     ...
$\endgroup$
0
$\begingroup$
import datetime

import bge

cont = bge.logic.getcurrentController()

if datetime.datetime.now() > datetime.datetime(2018,1,1,1):

    ownwer = cont.owner
    owner["property"] +=1

I figured it out..thanks anyways guys

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.