More spelling fixes

This commit is contained in:
bbassie
2019-07-03 16:16:39 +02:00
parent 786525f58f
commit 36aae4fd12
42 changed files with 312 additions and 312 deletions

View File

@@ -1,17 +1,17 @@
--- This file is a breakout from core which forcues on instance management of defines
--[[
>>>> Using registered instance groups
The main use of this module is to register a group of elements refered here as "instances of an element define" in which
The main use of this module is to register a group of elements referred here as "instances of an element define" in which
is meant that you define the name of a group of drawn elements that are really just multiple versions of a single element.
For example this might be that you have one label in multiple places (either for one player or many) and you want to update
the caption of all of them at once; this is where this module comes it.
First you must register the way that the intances are stored and under what name, using Instances.register you will give the
name of the collective group of instances followed by an optional categorise function which allows varients to be stored under one
First you must register the way that the instances are stored and under what name, using Instances.register you will give the
name of the collective group of instances followed by an optional categorise function which allows variants to be stored under one
name (like one for each force or player)
-- categorise works in the same way as store categorise
-- so the function will worl here but no value is stored only gui elements
-- so the function will world here but no value is stored only gui elements
Instances.register('score',Gui.categorize_by_force)
Then when you draw the new element to a gui you will want to add the element to the group:
@@ -26,13 +26,13 @@
element.caption = 0
end)
Note that if you dont give a categorise function then you dont need to give a category when getting the elements.
Note that if you don't give a categorise function then you don't need to give a category when getting the elements.
>>>> Using unregistered instance groups
When using a registered group and the functions that go with them it is much simpler to use and more importantly includes error checking
for valid instance group names; the down side is that the group must be registered which can only be done during startup and not during runtime.
To counter this there are two functions simlair to those above in order to add and get instances but may lead to errors not being noticed due to
the error interal error checking being skiped to allow it to work.
for valid instance group names; the down side is that the group must be registered which can only be done during start-up and not during runtime.
To counter this there are two functions similar to those above in order to add and get instances but may lead to errors not being noticed due to
the error internal error checking being skipped to allow it to work.
The main difference between the two groups of functions is that the category must always be present even if is nil; example below shows how a
instance group would work when registered vs unregistered:
@@ -50,7 +50,7 @@
element.caption = '0'
end) -- gets all instances from the player force and sets the caption to 0
-- Registered without category; note that category can just be igroned
-- Registered without category; note that category can just be ignored
Instances.register('score') -- all instances will be under one group with no categories
Instances.add_element('score',new_element) -- adds the new element to the instance list
Instances.apply_to_elements('score',function(element)
@@ -64,7 +64,7 @@
end) -- gets all instances and sets the element caption to 0
>>>> Functions
Instances.has_categories(name) --- Returns if a instnace group has a categorise function; must be registerd
Instances.has_categories(name) --- Returns if a instance group has a categorise function; must be registered
Instances.is_registered(name) --- Returns if the given name is a registered instance group
Instances.register(name,categorise) --- Registers the name of an instance group to allow for storing element instances
@@ -85,7 +85,7 @@ Global.register(Instances.data,function(tbl)
Instances.data = tbl
end)
--- Returns if a instnace group has a categorise function; must be registerd
--- Returns if a instance group has a categorise function; must be registered
-- @tparam string name the name of the instance group
-- @treturn boolean true if there is a categorise function
function Instances.has_categories(name)
@@ -104,7 +104,7 @@ end
-- @tparam[opt] function categorise function used to turn the element into a string
-- categorise param - element LuaGuiElement - the gui element to be turned into a string
-- categorise return - string - the category that the element will be added to like the player's name or force's name
-- @treturn string the name that was added so it can be used as a varible
-- @treturn string the name that was added so it can be used as a variable
function Instances.register(name,categorise)
if _LIFECYCLE ~= _STAGE.control then
return error('Can only be called during the control stage', 2)
@@ -127,7 +127,7 @@ end
-- @tparam LuaGuiElement element the element to add the the instance group
function Instances.add_element(name,element)
if not Instances.categorise[name] then
return error('Inavlid name for instance group: '..name,2)
return error('Invalid name for instance group: '..name,2)
end
if Instances.has_categories(name) then
@@ -145,7 +145,7 @@ end
-- @treturn table the table of element instances of which some may be invalid
function Instances.get_elements_raw(name,category)
if not Instances.categorise[name] then
return error('Inavlid name for instance group: '..name,2)
return error('Invalid name for instance group: '..name,2)
end
if Instances.has_categories(name) then
@@ -158,12 +158,12 @@ end
--- Gets all valid element instances and has the option of running a callback on those that are valid
-- @tparam string name the name of the instance group to get the instances of
-- @tparam[opt] string category the category to get the instances of, not needed when no categorise function
-- @tparan[opt] callback function when given the callback will be ran on all valid elements
-- @tparam[opt] callback function when given the callback will be ran on all valid elements
-- callback param - element LuaGuiElement - the current valid element
-- @treturn table the table of element instances with all invalid ones removed
function Instances.get_valid_elements(name,category,callback)
if not Instances.categorise[name] then
return error('Inavlid name for instance group: '..name,2)
return error('Invalid name for instance group: '..name,2)
end
category = category or callback