/usr/share/games/fillets-ng/script/init.lua is in fillets-ng-data 1.0.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | -- There is place to customize game before start
--NOTE: hack for win32, lang Czech = cs
--NOTE: first five characters from LC_CTYPE are stored in "lang" param
local lang = string.sub(getParam("lang") or "", 1, 5)
local winCodes = {
Czech = "cs",
Engli = "en",
Frenc = "fr",
Germa = "de",
Itali = "it",
Polis = "pl",
Spani = "es",
Dutch = "nl",
Bulga = "bg",
Swedi = "sv",
Slove = "sl",
Portu = "pt",
Russi = "ru",
Esper = "eo"
}
if winCodes[lang] then
setParam("lang", winCodes[lang])
end
--NOTE: default speech is 'cs' (there are cs/*.ogg files)
if getParam("speech") == nil then
setParam("speech", "cs")
end
--- Prints global score.
-- Usable from debug console.
function score()
local solvedCounter = 0
local userSteps = 0
local bestSteps = 0
local oldImpl = node_bestSolution
function node_bestSolution(codename, steps, solver)
local solution = "solved/"..codename..".lua"
if file_exists(solution) then
solvedCounter = solvedCounter + 1
bestSteps = bestSteps + steps
file_include(solution)
userSteps = userSteps + string.len(saved_moves)
end
end
file_include("script/worldfame.lua")
node_bestSolution = oldImpl
print("Solved:", solvedCounter)
print("Steps:", userSteps .."/".. bestSteps,
"(loss: ".. 100 * (userSteps - bestSteps) / bestSteps .."%)")
end
-- Prints the Hall of Fame table as HTML.
function hf()
local OUTPUT_LANG = "en"
local origImpls = {
node_bestSolution = node_bestSolution,
woldmap_addDesc = woldmap_addDesc,
}
local solutions = {}
local descs = {}
function node_bestSolution(codename, moves, author)
solutions[codename] = {
moves = moves,
author = author,
}
end
function worldmap_addDesc(codename, lang, levelname, branch)
if lang ~= OUTPUT_LANG then
return
end
if codename == "menu" or codename == "score"
or codename == "ending" then
return
end
local num_steps = nil
local solution = "solved/"..codename..".lua"
if file_exists(solution) then
saved_moves = nil
file_include(solution)
if saved_moves then
num_steps = string.len(saved_moves)
end
end
table.insert(descs, {
codename=codename,
lang=lang,
levelname=levelname,
branch=branch,
num_steps=num_steps,
})
end
local function formatPrefix()
local version = getParam("package") .. " " .. getParam("version")
print(string.format([[
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Hall of Fame Statistics</title>
</head>
<body>
<h3>%s</h3>
<table border="1">
<tr>
<th>Level</th>
<th>Name</th>
<th>Codename</th>
<th>Best solution</th>
<th>Solution author</th>
<th>Your solution</th>
<th>Difference</th>
</tr>]], version))
end
local function formatSuffix()
print([[
</table>
</body>
</html>]])
end
local function formatSpace()
print('<tr><td colspan="7"> </td></tr>')
end
local function formatTotal(total, player_total)
print(string.format('<tr><td colspan="3"> <b>Total</b></td><td align="right">%s</td><td> </td><td align="right">%s</td><td align="right">%s</td></tr>', total, player_total, player_total - total))
end
local function formatRow(index, levelname, codename, moves, author, player_steps)
if index < 10 then
index = '0'..index
end
local diff = "-"
if moves and player_steps then
diff = player_steps - moves
end
print(string.format('<tr><td align="right">%s </td><td> %s</td><td> %s</td><td align="right">%s </td><td> %s</td><td align="right"> %s</td><td align="right"> %s</td></tr>',
index, levelname, codename, moves or "-", author or "-",
player_steps or "-", diff or "-"))
end
file_include("script/worlddesc.lua")
file_include("script/worldfame.lua")
formatPrefix()
local total = 0
local player_total = 0
local lastBranch = descs[1].branch
for index, level in ipairs(descs) do
local moves = nil
local author = nil
local solution = solutions[level.codename]
if solution then
moves = solution.moves
author = solution.author
total = total + moves
end
if level.num_steps then
player_total = player_total + level.num_steps
end
if lastBranch ~= level.branch then
formatSpace()
lastBranch = level.branch
end
formatRow(index, level.levelname, level.codename, moves, author,
level.num_steps)
if index == 70 then
-- subtotal
formatSpace()
formatTotal(total, player_total)
end
end
formatSpace()
formatTotal(total, player_total)
formatSuffix()
for k, v in pairs(origImpls) do
_G[k] = v
end
sendMsg("App", "flush_stdout")
end
|