z_mirror/Krastorio2
git clone https://git.raiguard.me/z_mirror/Krastorio2
722847a5
trunk
1-- Show a warning ten seconds after the game starts and whenever a player joins the game. 2-- Modders: This warning can be disabled in the data stage using the prototypes.libraries.space-age-warning API. 3 4local warning_enabled =prototypes . mod_data [ "kr-space-age-warning" ]. data . enabled --[[@as boolean]] 5local warning_time =( 60 * 10 ) 6local warning_cutoff =warning_time + 5 7 8--- @param player LuaPlayer 9local function print_warning ( player ) 10if not warning_enabled then 11return 12end 13player . ( { "message.kr-space-age-warning-title" } ) 14player . ( { "message.kr-space-age-warning-description" } ) 15end 16 17--- @param e NthTickEventData 18local function on_check_show_warning ( e ) 19if not script . active_mods [ "space-age" ] then 20return 21end 22local mod_added_tick =storage . mod_added_tick or 0 23local mod_lifetime_ticks =e . tick - mod_added_tick 24if mod_lifetime_ticks > 0 and mod_lifetime_ticks < warning_cutoff then 25for _ , player in pairs ( game . players ) do 26print_warning ( player ) 27end 28end 29end 30 31--- @class kr.space_age_warning: event_handler 32local space_age_warning ={} 33 34function space_age_warning . on_init () 35storage . mod_added_tick =game . tick 36end 37 38space_age_warning . on_nth_tick ={ 39[ warning_time ] =on_check_show_warning , 40} 41 42return space_age_warning