Pablostuka
King
Bonjour @Dadais !
1) Not all units already exist on scenario start, but I want to have all entries predefined in my tables to help my planning. So for these the uId is initially set to 0, and once created at some point via events, updated later with the actual unit id. The ids are saved in the state table as counters, for persistence, and overwritten to the table onLoad().
2) My espionage module works retrieving random information. If spies are to produce a report on an enemy ship/commander, I want to display the info of a random ship/commander retrieved from my tables. The best way I thought about meeting this requirement is to generate a random integer between 0 (the 1st key) and the no. of elements in the table-1, that's why these sequential integers are the keys of the table as I ensure I get a valid key that exists. See code on how I do this when spying on an enemy ship (for commanders it will be pretty much the same):
Also this code ensures a ship not created yet is not picked up, by checking their uId == 0 in a while loop.
I'm all ears if you have better ideas!
I need to check it out, I don't have so much free time so when I do I focus on working on SCW, so I'm missing many scenarios!It looks very much like my "stuff" table for units in the TES scenario.
That's a very good question. The unitId is not the key in my tables for the following two reasons:Why didnt you use directly unitsID as the key of your table and added an integer ?
1) Not all units already exist on scenario start, but I want to have all entries predefined in my tables to help my planning. So for these the uId is initially set to 0, and once created at some point via events, updated later with the actual unit id. The ids are saved in the state table as counters, for persistence, and overwritten to the table onLoad().
2) My espionage module works retrieving random information. If spies are to produce a report on an enemy ship/commander, I want to display the info of a random ship/commander retrieved from my tables. The best way I thought about meeting this requirement is to generate a random integer between 0 (the 1st key) and the no. of elements in the table-1, that's why these sequential integers are the keys of the table as I ensure I get a valid key that exists. See code on how I do this when spying on an enemy ship (for commanders it will be pretty much the same):
Also this code ensures a ship not created yet is not picked up, by checking their uId == 0 in a while loop.
I'm all ears if you have better ideas!