-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathRandomPokémon.lua
More file actions
50 lines (42 loc) · 1.24 KB
/
RandomPokémon.lua
File metadata and controls
50 lines (42 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
--[[
Questo modulo sceglie un Pokémon randomicamente e ne
fa usi diversi in base alla funzione
--]]
local p = {}
-- stylua: ignore start
local tab = require('Wikilib-tables')
local txt = require('Wikilib-strings')
local form = require('Wikilib-forms')
local data = require("Wikilib-data")
local pokedata = require("Poké-data")
local alt = require("AltForms-data")
-- stylua: ignore end
-- Ritorna un ndex randomico
local randomNdex = function()
math.randomseed(os.time())
return math.random(data.pokeNum)
end
-- Ritorna l'artwork di un Pokèmon random
p.artwork = function(frame)
local dimensione = txt.trim(frame.args[1] or "100")
local num = tonumber(frame.args[2]) or randomNdex()
local nome = pokedata[num].name
local forme = nil
alt = form.allFormsData()
if alt[num] then
forme = alt[num].gamesOrder
end
local ndex = txt.fourFigures(num)
if forme then
ndex = ndex
.. form.toEmptyAbbr(
forme[math.random(tab.getn(forme))],
nome:lower()
)
end
return txt.interp(
"[[File:Artwork${num}.png|center|${dimensione}x${dimensione}px|link=${nome}]]",
{ num = ndex, nome = nome, dimensione = dimensione }
)
end
return p