diff --git a/expcore/common.lua b/expcore/common.lua index 1f7f6448..6cd27b56 100644 --- a/expcore/common.lua +++ b/expcore/common.lua @@ -135,4 +135,66 @@ function Public.ext_require(path,...) return Public.extract_keys(rtn,...) end +--- Formats ticks into a time format - this is alot of work and will do later +-- time denominations: D,H,M,S,T days,hours,minutes,seconds,ticks +-- time prefixes (minutes as example): %m,%m,%M,%MM just the value, value with short tag, value with long tag +-- adding a number after the prefix AND denomination will show that many decimal palaces +-- examples: '%H %M' => '0H 0M'; '%MM and %SS3' => '0 Minutes and 0.000 Seconds' +function Public.format_time(ticks,format) + local has_days, has_hours, has_minutes, has_seconds, has_ticks = false,false,false,false,false + local max_days, max_hours = ticks/5184000, ticks/216000 + local max_minutes, max_seconds, max_ticks = ticks/3600, ticks/60, ticks + local days, hours = max_days, max_hours-math.floor(max_days)*5184000 + local minutes, seconds = max_minutes-math.floor(max_hours)*216000, max_seconds-math.floor(max_minutes)*3600 + local tags = {} + return 'Use format_time_simple currently WIP' +end + +--- Formats tick into a time format, this format is predefined to either H:M:S; HH MM SS or H Hours M Minutes S seconds +-- seconds are not required to be shown with option show_seconds = false, true to show them, default false +-- show_sub_seconds will show three decimal places for the seconds +-- long_format will use words rather than letters +-- tagged is default to true when false it will remove all letters and use : +-- @tparam ticks number the number of ticks that represents a time +-- @tparam options table a table of options to use for the format +function Public.format_time_simple(ticks,options) + -- Sets up the options + options = { + show_seconds = options.show_seconds or false, + show_sub_seconds = options.show_sub_seconds or false, + long_format = options.long_format or false, + tagged = options.tagged or true + } + -- Basic numbers that are used in calculations + local max_hours, max_minutes, max_seconds = ticks/216000, ticks/3600, ticks/60 + local hours, minutes, seconds = max_hours, max_minutes-math.floor(max_hours)*216000, max_seconds-math.floor(max_minutes)*3600 + -- Format options + local suffix = 'time-format.short-' + if options.long_format then + suffix = 'time-format.long-' + end + local div = 'time-format.simple-format-tagged' + if options.tagged then + div = 'time-format.simple-format-div' + suffix = false + end + -- The returned numbers in the right format + local rtn_hours, rtn_minutes, rtn_seconds = math.floor(hours), math.floor(minutes), math.floor(seconds) + if suffix then + rtn_hours = {suffix..'hours',rtn_hours} + rtn_minutes = {suffix..'minutes',rtn_minutes} + if options.show_sub_seconds then + rtn_seconds = {suffix..'seconds',string.format('%d03',seconds)} + else + rtn_seconds = {suffix..'seconds',rtn_seconds} + end + end + -- The final return is construed + local rtn = {div,rtn_hours,rtn_minutes} + if options.show_seconds then + rtn = {div,rtn,rtn_seconds} + end + return rtn +end + return Public \ No newline at end of file diff --git a/locale/en/expcore.cfg b/locale/en/expcore.cfg index b33e7ee3..6dbc9b41 100644 --- a/locale/en/expcore.cfg +++ b/locale/en/expcore.cfg @@ -14,4 +14,19 @@ invalid-param=Invalid Param "__1__"; __2__ command-help=__1__ - __2__ command-ran=Command Complete command-fail=Command failed to run: __1__ -command-error-log-format=[ERROR] command/__1__ :: __2__ \ No newline at end of file +command-error-log-format=[ERROR] command/__1__ :: __2__ + +[time-format] +simple-format-none=__1__ +simple-format-div=__1__:__2__ +simple-format-tagged=__1__ __2__ +long-days=__1__ __plural_for_parameter_1_{1=Day|rest=Days}__ +short-days=__1__D +long-hours=__1__ __plural_for_parameter_1_{1=Hour|rest=Hours}__ +short-hours=__1__H +long-minutes=__1__ __plural_for_parameter_1_{1=Minute|rest=Minutes}__ +short-minutes=__1__M +long-seconds=__1__ __plural_for_parameter_1_{1=Second|rest=Seconds}__ +short-seconds=__1__S +long-ticks=__1__ __plural_for_parameter_1_{1=Tick|rest=Ticks}__ +short-ticks=__1__T \ No newline at end of file diff --git a/modules/addons/death-markers.lua b/modules/addons/death-markers.lua index 616854b9..c161dc5a 100644 --- a/modules/addons/death-markers.lua +++ b/modules/addons/death-markers.lua @@ -3,5 +3,38 @@ local Game = require 'utils.game' local Global = require 'utils.global' local Commands = require 'expcore.commands' local config = require 'config.death_markers' -local opt_require = ext_require('expcore.common','opt_require') -opt_require 'config.command_auth_runtime_disable' -- if the file is present then we can disable the commands \ No newline at end of file +local opt_require, format_time = ext_require('expcore.common','opt_require','format_time_simple') +opt_require 'config.command_auth_runtime_disable' -- if the file is present then we can disable the commands rather than not load them + +local bodies = { + --{player_name='Cooldude2606',time_of_death='15H 15M',body=LuaEntity,tag=LuaCustomChartTag} +} +Global.register(bodies,function(tbl) + bodies = tbl +end) + +--- Checks that all map tags are present and valid +-- adds missing ones, deletes expired ones +local function check_map_tags() + +end + +--- Teleports the owner of a body to the body +local function teleport_player(body) + +end + +--- Teleports the items in a body to a certain position putting it in chests +-- if there are no chests close by them some are created +local function teleport_items(body,position) + +end + +Event.add(defines.events.on_player_died,function(event) + +end) + +local check_period = 60*60*5 -- five minutes +Event.on_nth_tick(check_period,function(event) + +end) \ No newline at end of file diff --git a/modules/commands/interface.lua b/modules/commands/interface.lua index 24424ebf..da03fdd1 100644 --- a/modules/commands/interface.lua +++ b/modules/commands/interface.lua @@ -5,6 +5,7 @@ local Common = require 'expcore.common' -- modules that are loaded into the interface env to be accessed local interface_modules = { ['Game']='utils.game', + ['_C']=Common, ['Commands']=Commands, ['output']=Common.player_return, ['Group']='expcore.permission_groups'