# GPLv3 or later # (C) J.Y.Amihud ( blenderdumbass ) # This scripts will deal with money in the game. import bge import aud if "money" not in bge.logic.globalDict: bge.logic.globalDict["money"] = 0.0 money = bge.logic.globalDict["money"] def Set(amount): global money money = amount UpdateUI(sound=False) def Get(): return money def Recieve(amount): global money money += amount UpdateUI() def Pay(amount): global money money -= amount UpdateUI() def Have(amount): if money >= amount: return True else: return False def UpdateUI(sound=True): scene = bge.logic.getCurrentScene() UI = scene.objects["Dani_Money_Indicator"] UI["Text"] = "$"+str(int(money)) bge.logic.globalDict["money"] = money if sound: Sound() def Sound(): device = bge.logic.globalDict["SoundDevice"] code = "//sfx/money.ogg" if code not in bge.logic.globalDict["sounds"]: bge.logic.globalDict["sounds"][code] = {"sound":aud.Sound(bge.logic.expandPath(code)), "play":None} sound = bge.logic.globalDict["sounds"][code] if not sound["play"] or not sound["play"].status: sound["play"] = device.play(sound["sound"]) sound["play"].volume = 2