@@ -2,36 +2,7 @@
Общие утилиты для игр на Instead. Скорее всего будут повторно использоваться в следующих играх, если таковые будут.
]]
--[[
ArrayUtils = {
indexOf = function(array, item)
for i = 1, #array do
if (array[i] == item) then
return i;
end;
return 0;
};
PartyUtils = {
addToParty = function(object)
if (object.home) then
if (ArrayUtils.indexOf(pl.party, object.nam) == 0) then
move(object, object.home);
table.insert(pl.party, object.nam);
Translate utils
--[[Translate utils]]
language = "ru"
@@ -42,6 +13,33 @@ translate = function(table, key)
functions, design to simplify some typical actions while developing Instead game
EngineUtils = {
@@ -68,40 +66,27 @@ EngineUtils = {
room = inherit(room, function(v)
v.entered = stead.hook(v.entered, function(f, s, ...)
if s.showhp then
hp_indicator:enable();
else
hp_indicator:disable();
return f(s, ...)
end)
return v;
internal space
_kh = {
vroom_enter = function(s)
local v = EngineUtils.getValue(s.where);
if (v) then
walk(v);
return false;
vroom_save = function(s)
if need then
local t = stead.string.format("%s = kh_vroom(%s, %q, %s);\n",
name, stead.tostring(s.disp),
stead.deref(s.where), stead.deref(s.nam));
h:write(t);
end
stead.savemembers(h, s, name, false);
function toggle(obj)
@@ -112,7 +97,7 @@ function toggle(obj)
function kh_vobj(nam, dsc, act, used)
return obj {
nam = nam;
dsc = dsc;
@@ -122,13 +107,13 @@ function kh_vobj(nam, dsc, act, used)
function kh_vway(disp, dsc, target, seen_level)
local temp = vway(disp, dsc, target);
temp.seen_level = seen_level;
return temp;
vroom with additional functionality
function kh_vroom(disp, target, nam, seen_level)
if (type(nam) == "number") then
@@ -138,55 +123,72 @@ function kh_vroom(disp, target, nam, see
if (not nam) then
nam = disp;
return room {
disp = disp;
where = target;
enter = _kh.vroom_enter;
seen_level = seen_level;
dlg = inherit(dlg, function(v)
v.hideinv = true;
v.nosave = true;
v.noautosave = true;
end);
if not kh_utils_installed then
obj = inherit(obj, function(v)
v.disable_implicit = hook(v.disable, function(f, s, ...)
s._disabled_implicit = true;
return f(s, unpack({...}));
v.disable = hook(v.disable, function(f, s, ...)
s._disabled_explicit = true;
v.enable_implicit = hook(v.enable, function(f, s, ...)
s._disabled_implicit = false;
if (s._disabled_explicit) then
return s; --mimic original enable() behavior
v.enable = hook(v.enable, function(f, s, ...)
s._disabled_explicit = false;
if (s._disabled_implicit) then
v.toggle = toggle;
kh_utils_installed = true;
character object
Status change: