214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
...
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
|
return val, (val - min) / d
end;
---------------
-- phenotype --
---------------
lookupSpecies = function(self)
return starlit.world.species.lookup(self.persona.species, self.persona.speciesVariant)
end;
phenoTrait = function(self, trait, dflt)
-- local s,v = self:lookupSpecies()
-- return v.traits[trait] or s.traits[trait] or 0
return self.pheno:trait(trait, dflt)
end;
damageModifier = function(self, kind, amt)
................................................................................
local luser = self.entity
local bar = {def = def}
local img = lib.image 'starlit-ui-bar.png'
local colorized = img
if type(def.color) ~= 'function' then
colorized = colorized:shift(def.color)
end
bar.id = luser:hud_add {
type = 'statbar';
position = def.pos;
offset = def.ofs;
name = def.name;
text = colorized:render();
text2 = img:tint{hue=0, sat=-1, lum = -0.5}:fade(0.5):render();
number = def.size;
item = def.size;
direction = def.dir;
alignment = def.align;
size = {x=4,y=24};
}
bar.update = function()
local sv, sf = def.stat(self, bar, def)
luser:hud_change(bar.id, 'number', def.size * sf)
if type(def.color) == 'function' then
local clr = def.color(sv, luser, sv, sf)
luser:hud_change(bar.id, 'text', img:tint(clr):render())
end
end
return bar, {x=3 * def.size, y=16} -- x*2??? what
end;
createHUD = function(self)
local function basicStat(statName)
return function(user, bar)
return self:effectiveStat(statName)
end
end
|
|
>
>
>
>
>
>
>
>
>
<
|
|
|
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
...
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
|
return val, (val - min) / d
end;
---------------
-- phenotype --
---------------
lookupSpecies = function(self)
return starlit.world.species.lookup(
self.persona.species,
self.persona.speciesVariant)
end;
phenoTrait = function(self, trait, dflt)
-- local s,v = self:lookupSpecies()
-- return v.traits[trait] or s.traits[trait] or 0
return self.pheno:trait(trait, dflt)
end;
damageModifier = function(self, kind, amt)
................................................................................
local luser = self.entity
local bar = {def = def}
local img = lib.image 'starlit-ui-bar.png'
local colorized = img
if type(def.color) ~= 'function' then
colorized = colorized:shift(def.color)
end
local function adjustNumber(n)
-- produce a value that is realized as whole number
-- of images, rather than half-images
return math.floor(n/2)*2;
end
bar.id = luser:hud_add {
type = 'statbar';
position = def.pos;
offset = def.ofs;
name = def.name;
number = adjustNumber(def.size);
text = colorized:render();
text2 = img:tint{hue=0, sat=-1, lum = -0.5}:fade(0.5):render();
item = def.size;
direction = def.dir;
alignment = def.align;
size = {x=4,y=24};
}
bar.update = function()
local sv, sf = def.stat(self, bar, def)
luser:hud_change(bar.id, 'number', adjustNumber(def.size * sf))
if type(def.color) == 'function' then
local clr = def.color(sv, luser, sv, sf)
luser:hud_change(bar.id, 'text', img:tint(clr):render())
end
end
return bar, {x=3 * def.size, y=16} -- x*3??? what
end;
createHUD = function(self)
local function basicStat(statName)
return function(user, bar)
return self:effectiveStat(statName)
end
end
|