z_mirror/Tapeline
git clone https://git.raiguard.me/z_mirror/Tapeline
35cfa44
color-setting
1local constants =require ( "__Tapeline__/constants" ) 2 3local player_data ={} 4 5--- @param player_index uint 6function player_data . init ( player_index ) 7--- @class PlayerTable 8global . players [ player_index ] ={ 9flags ={ 10editing =false , 11drawing =false , 12holding_tool =false , 13increased_build_distance =false , 14} , 15--- @type LuaEntity? 16last_entity =nil , 17--- @type VisualSettings? 18visual_settings =nil , 19tapes ={ 20-- @type TapeData? 21editing =nil , 22-- @type TapeData? 23drawing =nil , 24} , 25--- @class TapeSettings 26tape_settings ={ 27mode ="subgrid" , 28subgrid_divisor =5 , 29split_divisor =4 , 30} , 31} 32end 33 34--- @param player LuaPlayer 35--- @param settings_table VisualSettings 36--- @param prototype string 37--- @param internal string 38function player_data . update_visual_setting ( player , settings_table , prototype , internal ) 39local value =player . mod_settings [ prototype ]. value 40if string . find ( internal , "color" ) then 41settings_table [ internal ] =value --[[@as Color]] 42else 43settings_table [ internal ] =value 44end 45end 46 47--- @param player LuaPlayer 48--- @param player_table PlayerTable 49function player_data . update_visual_settings ( player , player_table ) 50local settings ={} 51for prototype , internal in pairs ( constants . setting_names ) do 52player_data . update_visual_setting ( player , settings , prototype , internal ) 53end 54player_table . visual_settings =settings 55end 56 57--- @param player LuaPlayer 58--- @param player_table PlayerTable 59function player_data . refresh ( player , player_table ) 60player_data . update_visual_settings ( player , player_table ) 61end 62 63return player_data