What I’m trying to do is pass a variable that is contained in a class in one file to another.
import direct.directbase.DirectStart
from pandac.PandaModules import *
from direct.task.Task import *
from direct.showbase.DirectObject import *
import sys, random, os, math
from direct.interval.FunctionInterval import *
class Input(DirectObject):
def __init__(self):
self.keyMap = {"Left":0}
self.accept("arrow_left",self.setKey, ["Left",1])
self.accept("arrow_left-up",self.setKey,["Left",0])
self.Left = True
taskMgr.add(self.UInput,"UInput")
def setKey(self, key, value):
self.keyMap[key] = value
def UInput(self, task):
if(self.keyMap["Left"]!=0):
self.Left = False
return Task.cont
import direct.directbase.DirectStart
from pandac.PandaModules import *
from direct.task.Task import *
from direct.showbase.DirectObject import *
import sys, random, os, math
from direct.interval.FunctionInterval import *
import UserInput
import Test
class World(DirectObject):
def __init__(self):
self.UserInput = UserInput.Input()
taskMgr.add(Test.Tester,"Tester")
w = World()
run()
import direct.directbase.DirectStart
from pandac.PandaModules import *
from direct.task.Task import *
from direct.showbase.DirectObject import *
import sys, random, os, math
from direct.interval.FunctionInterval import *
import UserInput
def Tester(task):
if(UserInput.Input().Left == False):
print "Hello"
return Task.cont
All I’m trying to do at the moment is if the left arrow key is pushed it will change the state of the Boolean. Which is then read in another file and if it’s false print it out.
The problem is when I hit the left arrow key nothing happens.
Any help or suggestions would be great!