-
Notifications
You must be signed in to change notification settings - Fork 0
Generating the numbers
There are multiple ways to generate the numbers:
- Defining them manually
- Sequence from starting number to ending number
- Random secuence from a pattern
- Advanced techniques
Before continue, we should have the model file look like this:
local kaminari_numbers
-- Function to check if a module available
function isModuleAvailable(name)
if package.loaded[name] then return true end
for _, searcher in ipairs(package.searchers or package.loaders) do
local loader = searcher(name)
if type(loader) == 'function' then
package.preload[name] = loader
return true
end
end
return false
end
-- Main model's data() function
function data()
local platesLeft = {} -- Here we will place the identification numbers who will be shown on left side
local platesRight = {} -- Here we will place the identification numbers who will be shown on right side
-- If "kaminari_numbers" module is available, then we proceed loading the module. This way we prevent breaking any previous save game.
if isModuleAvailable( "kaminari_numbers" ) then
-- LOAD THE MOUDLE
kaminari_numbers = require "kaminari_numbers"
-- HERE WE WILL GENERATE THE NUMBERS
else
print("Warning: kaminari_numbers is not available/found. Please subscribe it on Steam Workshop, activate and make sure it is loaded before all the rest of mods.")
end
-- HERE BEGINS THE USUAL RETURN DATA OF THE MODEL
return {
boundingInfo = {
bbMax = { 6.7790122032166, 1.5564205646515, 4.2407073974609, },
bbMin = { -7.0255718231201, -1.5564205646515, -0.036832869052887, },
},
-- Rest of the model data [...]
}
end
Each digit adds 2 polygons to the model, and because of each identification number may have numerous digits, and a group of generated identification numbers may have
** NOTE ** From now we will insert the code after the -- HERE WE WILL GENERATE THE NUMBERS
line.
To add a number from a manual list, simply call the following function:
local myList = {"V 100-1035","V 100-1023"}
platesLeft = kaminari_numbers.getChildrenColorNumber( myList, "white", "Helvetica", 10.0, 2.20, -1.00, 2.05, 180, 0, 0 ),
platesRight = kaminari_numbers.getChildrenColorNumber( myList, "white", "Helvetica", 10.0, 2.20, -1.00, 2.05, 180, 0, 0 ),
This will print and cycle throug "V 100-1035" and "V 100-1023". You can add as many you want.
💡 TIP the same way we can cycle throug names, like { "MALLARD","ROCKETER","ARROW" } or show random labels like hours or temperatures on a panel. Possibilites are countless.
In this case we want to create a secuence of numbers starting from a number until a ending one. Because of we would like all the numbers shown on the model be the same, the list of numbers must be created separately from the function getChildrenColorNumber()
. If not done like this, you will see different numbers on each label.
We can achieve this with the following code:
local myList = kaminari_numbers.buildListOfNumbers( 1, 35, true, 3, "1", "" )
platesLeft = kaminari_numbers.getChildrenColorNumber( myList, "white", "Helvetica", 10.0, 2.20, -1.00, 2.05, 180, 0, 0 ),
platesRight = kaminari_numbers.getChildrenColorNumber( myList, "white", "Helvetica", 10.0, 2.20, -1.00, 2.05, 180, 0, 0 ),
Note we only changed how myList
is defined. The rest is all the same.
Please refer to buildlistofnumbers() definition on how to use this function.
In this case we want to create a bunch of numbers from a defined pattern. Because of we would like all the numbers shown on the model be the same, the list of numbers must be created separately from the function getChildrenColorNumber()
. If not done like this, you will see different numbers on each label.
We can achieve this with the following code:
local myList = kaminari_numbers.buildListOfNumbers( 1, 35, true, 3, "1", "" )
platesLeft = kaminari_numbers.getChildrenColorNumber( myList, "white", "Helvetica", 10.0, 2.20, -1.00, 2.05, 180, 0, 0 ),
platesRight = kaminari_numbers.getChildrenColorNumber( myList, "white", "Helvetica", 10.0, 2.20, -1.00, 2.05, 180, 0, 0 ),
Note we only changed how myList
is defined. The rest is all the same.
Please refer to buildlistofnumbers() definition on how to use this function.