sync object color variable

Posted by jose_creative
hi i wonder how do i sync a color variable (like make_colour_rgb() ) for an object
im trying to make a brick building game but when it "syncs" the vaiable the brik it's just full black and it doesn't change!

Replies (9)

Last message on 4 Sep 2021

Size43 (Administrator) on 16 Jul 2021, 22:14:17
Apologies for the delay. A color is just a number in GameMaker, so you should just be able to use gms_self_set and gms_other_get to sync the variable (for player variables), or gms_instance_sync_var_add/gms_instance_set/gms_instance_get (for instance syncing). Could you post the code that you're using to sync the variable?
jose_creative (Topicstarter) on 17 Jul 2021, 20:32:27
here is the code:
BrickColor = global.BrickColor
gms_instance_sync(id,is_extended)
gms_instance_sync_var_add("BC",BrickColor)
Size43 (Administrator) on 26 Jul 2021, 19:03:11
All calls to gms_instance_sync_var_add must appear before the call to gms_instance_sync. Swapping those two calls should make your code work. (assuming you also have the corresponding code in the user defined event to load the value again)
jose_creative (Topicstarter) on 4 Aug 2021, 01:12:47
i did that but still dosen't sync here is a screenshot:https://i.ibb.co/HdY8WY1/RBLX2-D-screenshot-brickcolor-missing.png
Size43 (Administrator) on 9 Aug 2021, 14:46:09
Could you show the code you're using in the user defined event 12 of the brick?
jose_creative (Topicstarter) on 9 Aug 2021, 22:44:38
wasn't it 15? because thats the only one i use and i just looked up and has nothing on it
Size43 (Administrator) on 18 Aug 2021, 16:18:00
You will need to load the variable in the User Defined 12 event. For example, something like this:

mycolor = ds_map_find_value(variable_map, "BC");


variable_map is a variable that contains a ds_map with all the variables you added using gms_instance_sync_var_add. Obviously you then need to somehow use 'mycolor' to actually draw the right color in, for example, the draw event.
jose_creative (Topicstarter) on 25 Aug 2021, 14:52:13
also i forgot to mention something idk if it is the cause of the problem but the global.brickcolor is a make_colour_rgb value
Size43 (Administrator) on 4 Sep 2021, 16:00:25
make_colour_rgb just returns a number, that's fine. If you have the gms_instance_sync_var_add and the code to load the value in the User Defined 12 event it should work.