Data Management for Management Game

Blitz3D Forums/Blitz3D Beginners Area/Data Management for Management Game

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

You don't need IDs, you can simply store pointers.

p\league[0]\team[0]\player[0]\team = p\league[0]\team[0]


I actually did try the NULL thing (setting to null once I`ve copied it) but it calls an error when i was trying to output the values of [0,0,0] to screen, rather than printing nothing.


The problem is with your display code. Your display code should check if the player object it's given to display is NULL or not. If it's NULL, display nothing. Just like my FOR..NEXT loop example above checks for NULL for every object it loops over.

function display_player_by_indices(league_index, team_index, player_index)
	found_player = false
	this_league.league = p\league[league_index]
	if this_league <> NULL then
		this_team.team = this_league\team[team_index]
		if this_team <> NULL then
			this_player.player = this_team\player[player_index]
			if this_player <> NULL then
				found_player = true
				print this_player\name$
			endif
		endif
	endif
	if found_player = false then
		print ""
	endif
end function


;remove orig data
Delete p\league[0]\team[0]\player[0]
p\league[0]\team[0]\player[0]=New player
Does this cause any problems I`m not aware of, memory etc?


Yes, it'll blow away the data you're trying to copy because you're passing the pointer to the copied data to Delete. Check out the following example - there is only one object created (New foo), but three pointers (a, b, c) which all point to it. When Delete is called, the object is destroyed and the pointers will all point to nothing.

type foo
	field name$
end type

a.foo = new foo
a\name$ = "red"

b.foo = a
c.foo = a

print a\name$

b\name$ = "yellow"
print a\name$

b=null
print a\name$

delete c
print a\name$		; error!