My questions thread

(12)
I kinda solved this by simply removing the FSM from the player, since it simply isn’t one.
I guess a solution is to simply use a “isEnabled” attribute that at class creation is 0, during Jumping is 1, and at the end of Jumping goes back to 0. I use that pattern now in other places.

(13)
You’re right, it is simply the setup time of the DirectRadioButtons. I brought the time down from 5-6 seconds to 3-4 seconds by using only DirectButtons. I guess I will have to come back to that later.
I know how to create a bunch of geoms via CardMaker for example. I know how to get the x,y coords of the mouse on click. But to be honest I don’t know how to connect the two.

(14)
I’ve got a problem it seems with class attributes.

I’ve got a HUD that is in it’s own class in a file, like:

class MCHUD(DirectObject):
	def __init__(self):
		pass
	
	# the build function only sets background images and empty text fields
	def buildHUD(self):
		self.hudpictures = []
		self.hudtexts = []
		
		self.targetBackgrd = OnscreenImage( bla )
		self.targetBackgrd.reparentTo(base.a2dTopRight)
		self.hudpictures.append(self.targetBackgrd)

		(...)

	def deleteHUD(self):
		for hudpicture in self.hudpictures:
			hudpicture.destroy()
		self.hudpictures = []
		for hudtext in self.hudtexts:
			hudtext.destroy()
		self.hudtexts = []

At start of the game or when I jump from system to system the Environment AKA World class gets (re-)created. This is where the HUD initially becomes visible:

from mchud import MCHUD	

class MCEnvironment(DirectObject): # AKA the World class
	def __init__(self, ..., ...):

		self.hud = MCHUD()
		self.hud.buildHUD()
		# now fill the empty fields with current data
		self.FreeCargoSpace = int(self.mcdbships.ShipList[self.PlayerShipIdentifier][8])
		self.hud.incargoText.setText('In Hold: '+str(sum(self.CargoContent.values()))+"t ("+str(self.CargoContent.keys())+")")
		self.hud.creditsText.setText('Credits: '+str(self.PlayerCredits))
		self.hud.freecargoText.setText('Free: '+str(self.FreeCargoSpace - sum(self.CargoContent.values())))
		self.hud.starsystemText.setText(self.StobIdentifier)
		self.hud.stellarnavGoal.setText("- none selected -")

Now upgrading the HUD content from the Environment works fine. But there are other elements in the game that also update the HUD. For example, the Starmap, where the HUD reflects some button clicks:

from mchud import MCHUD

class MCStarmap(DirectObject):
	def __init__(self, ...):

		self.hud = MCHUD()
		# on some button click
		self.hud.hudtexts[1].setText(chosenStob[0])
		self.hud.stellarnavGoal.setText(chosenStob[0])

Another entity manipulating the HUD is some ingame menus. I think I see what is going on. The HUD class get’s thrown into several namespaces over time.

The init of the HUD is a pass to avoid multiple builds of the HUD when the classes import the HUD class. If I put the setup code from def buildHUD(self) to the init I get three or four HUDs over each other, and only one of them gets changed with setText() commands.
What helped historically is to do something like:

class MCIngameMenu(DirectObject):
	def __init__(self, ..., ...):

		self.hud = MCHUD()
		self.hud.deleteHUD()
		self.hud.buildHUD()
		# now fill the empty fields with current data
		self.hud.incargoText.setText('In Hold: '+str(sum(self.CargoContent.values()))+"t ("+str(self.CargoContent.keys())+")")

If I don’t do something like that, I draw the HUD originally in Environment, then I do self.hud.incargoText.setText() in the Starmap and get “self.hud has no attribute incargoText”.