That said... One of the problems I am facing is that ships don't have Characters associated with them. It would be best if crime is attached to a (persistent) Character though. Because my coding abilities in C++ are next to nil I am trying to solve this entirely from the lua side and stitch ship objects and Character objects together. I realize that this is a pretty hackish way of doing it. If someone wants to realize this cleanly in C++ I would be more than happy to give the reigns to her/him. I am posting this here because it does change things a bit (more so in the future when things depend on this structure). So if you don't like this direction - please let me know.
The way I would approach it right now would require one new lua file: Pilots.lua.
(In Pseudocode) it would contain the following:
1.
Code: Select all
a central table where ships are associated with characters (pilots[ship] = character)
Code: Select all
createPilot(ship)
char = Character.New()
pilots[ship] = char
return char
Code: Select all
linkPilotShip(ship, char)
pilots[ship] = char
Code: Select all
Code to save the pilots table during serialization, clear it before a player leaves the system, etc. (general "housekeeping" stuff :))
Code: Select all
Ship:Pilot()
if ship in Pilots.pilot then
pilot = Pilots.pilot[ship]
else
pilot = Pilots.createPilot(self)
end
return pilot
end
If this works out I would then work on extending crime tracking to Characters.