diff --git a/config/compilatron.lua b/config/compilatron.lua new file mode 100644 index 00000000..a4980f92 --- /dev/null +++ b/config/compilatron.lua @@ -0,0 +1,21 @@ +return { + message_cycle=60*15, -- 15 seconds default, how often (in ticks) the messages will cycle + locations={ -- defines the spawn locations for all compilatrons + ['Spawn']={x=0,y=0} + }, + messages={ -- the messages that each one will say, must be same name as its location + ['Spawn']={ + {'info.website-message'}, + {'info.read-readme'}, + {'info.discord-message'}, + {'info.softmod'}, + {'info.wiki-message'}, + {'info.redmew'}, + {'info.feedback-message'}, + {'info.custom-commands'}, + {'info.status-message'}, + {'info.lhd'}, + {'info.github-message'}, + } + } +} \ No newline at end of file diff --git a/config/file_loader.lua b/config/file_loader.lua index 72802122..048cbd72 100644 --- a/config/file_loader.lua +++ b/config/file_loader.lua @@ -20,6 +20,7 @@ return { 'modules.addons.death-logger', 'modules.addons.advanced-starting-items', 'modules.addons.spawn-area', + 'modules.addons.compilatron', -- Config Files 'config.command_auth_admin', -- commands tagged with admin_only are blocked for non admins 'config.command_auth_runtime_disable', -- allows commands to be enabled and disabled during runtime diff --git a/locale/en/addons.cfg b/locale/en/addons.cfg index a4bb08a6..d2d99105 100644 --- a/locale/en/addons.cfg +++ b/locale/en/addons.cfg @@ -4,4 +4,25 @@ ping=You have been mentioned in chat by __1__. [damage-popup] player-health=__1__ -player-damage=__1__ \ No newline at end of file +player-damage=__1__ + +[info] +players-online=There are __1__ players online +total-map-time=This map has been on for __1__ +discord-link=https://discord.explosivegaming.nl +discord-message=Join use on our discord at: https://discord.explosivegaming.nl +website-link=https://www.explosivegaming.nl +website-message=Please vist our website at: https://www.explosivegaming.nl +wiki-link=https://wiki.explosivegaming.nl/ +wiki-message=You can get more information about us and the custom scenario from our wiki: https://wiki.explosivegaming.nl/ +feedback-link=https://exp.fider.io/ +feedback-message=Do you have feedback? leave it at https://exp.fider.io/ +status-link=https://status.explosivegaming.nl +status-message=Want to check if out servers are down, vist: https://status.explosivegaming.nl +github-link=https://github.com/explosivegaming/scenario +github-message=Want to help improve our server with some extra features? Help us at: https://github.com/explosivegaming/scenario +custom-commands=We use custom commands, such as /tag and /me, use /chelp for more info. +read-readme=Make sure you have read the Readme (It can be found through the question mark on the top left) +softmod=We run a softmod on our servers. A softmod is a custom scenario that runs on this server, example is the player list. +redmew=We dont talk about redmew here; they beat us to 1000 members ;-; +lhd=All trains must be LHD! This is a long standing rule on our servers, please resepect this. \ No newline at end of file diff --git a/modules/addons/addons.cfg b/modules/addons/addons.cfg deleted file mode 100644 index a4bb08a6..00000000 --- a/modules/addons/addons.cfg +++ /dev/null @@ -1,7 +0,0 @@ -[chat-popup] -message=__1__: __2__ -ping=You have been mentioned in chat by __1__. - -[damage-popup] -player-health=__1__ -player-damage=__1__ \ No newline at end of file diff --git a/modules/addons/compilatron.lua b/modules/addons/compilatron.lua new file mode 100644 index 00000000..dec30416 --- /dev/null +++ b/modules/addons/compilatron.lua @@ -0,0 +1,100 @@ +local Event = require 'utils.event' +local Global = require 'utils.global' +local Game = require 'utils.game' +local Task = require 'utils.task' +local Token = require 'utils.token' +local config = require 'config.compilatron' +local messages = config.messages +local locations = config.locations + +local compilatrons = {} +local current_messages = {} +Global.register( + { + compilatrons = compilatrons, + current_messages = current_messages + }, + function(tbl) + compilatrons = tbl.compilatrons + current_messages = tbl.current_messages + end +) + +--- This will re-create the speech bubble after it de-spawns called with set_timeout +local callback = + Token.register( + function(data) + local ent = data.ent + local name = data.name + local msg_number = data.msg_number + local message = + ent.surface.create_entity( + {name = 'compi-speech-bubble', text = messages[name][msg_number], position = {0, 0}, source = ent} + ) + current_messages[name] = {message = message, msg_number = msg_number} + end +) + +--- This will move the messages onto the next message in the loop +local function circle_messages() + for name, ent in pairs(compilatrons) do + local current_message = current_messages[name] + local msg_number + local message + if current_message ~= nil then + message = current_message.message + if message ~= nil then + message.destroy() + end + msg_number = current_message.msg_number + msg_number = (msg_number < #messages[name]) and msg_number + 1 or 1 + else + msg_number = 1 + end + -- this calls the callback above to re-spawn the message after some time + Task.set_timeout_in_ticks(300, callback, {ent = ent, name = name, msg_number = msg_number}) + end +end + +Event.on_nth_tick(config.message_cycle, circle_messages) + +local Public = {} + +--- This will add a compilatron to the global and start his message cycle +-- @tparam entity LuaEntity the compilatron entity that moves around +-- @tparam name string the name of the location that the complitron is at +function Public.add_compilatron(entity, name) + if not entity and not entity.valid then + return + end + if name == nil then + return + end + compilatrons[name] = entity + local message = + entity.surface.create_entity( + {name = 'compi-speech-bubble', text = messages[name][1], position = {0, 0}, source = entity} + ) + current_messages[name] = {message = message, msg_number = 1} +end + +--- This spawns a new compilatron on a surface with the given location tag (not a position) +-- @tparam surface LuaSurface the surface to spawn the compilatron on +-- @tparam location string the location tag that is in the config file +function Public.spawn_compilatron(surface,location) + local position = locations[location] + local pos = surface.find_non_colliding_position('compilatron', position, 1.5, 0.5) + local compi = surface.create_entity {name='compilatron',position=pos,force=game.forces.neutral} + Public.add_compilatron(compi,location) +end + +-- When the first player is created this will create all comilatrons that are resisted in the config +Event.add(defines.events.on_player_created,function(event) + if not event.player_index == 1 then return end + local player = Game.get_player_by_index(event.player_index) + for location,pos in pairs(locations) do + Public.spawn_compilatron(player.surface,location) + end +end) + +return Public diff --git a/modules/commands/commands.cfg b/modules/commands/commands.cfg deleted file mode 100644 index ddf4213b..00000000 --- a/modules/commands/commands.cfg +++ /dev/null @@ -1,10 +0,0 @@ -[exp-commands] -kill-already-dead=You are already dead. -admin-chat-format=[Admin Chat] [color=__3__]__1__: __2__ -tp-no-position-found=No position to teleport to was found, please try again later. -tp-to-self=Player can not be teleported to themselves. -chelp-title=Help results for "__1__": -chelp-footer=(__1__ results found; page __2__ of __3__) -chelp-format=/__1__ __2__ - __3__ __4__ -chelp-alias=Alias: __1__ -chelp-out-of-range=__1__ is an invalid page number. \ No newline at end of file