Shared data

Game Maker 8

Shared data

Shared data communication is probably the easiest way to synchronize the game. All communication is shielded from you. There is a set of 1000000 values that are common to all entities of the game (preferably only use the first few to save memory). Each entity can set values and read values. Game Maker makes sure that each entity sees the same values. A value can either be a real or a string. There are just two routines:

mplay_data_write(ind,val) write value val (string or real) into location ind (ind between 0 and 1000000).
mplay_data_read(ind) returns the value in location ind (ind between 0 and 1000000). Initially all values are 0.

To synchronize the data on the different machines you can either use a guaranteed mode that makes sure that the change arrives on the other machine (but which is slow) or non-guaranteed. To change this use the following routine:

mplay_data_mode(guar) sets whether or not to use guaranteed transmission for shared data. guar should either be true (the default) or false.