134 lines
5.1 KiB
Text
134 lines
5.1 KiB
Text
|
|
----------------------------------------------------------
|
|
local old_time = 0 --need for update filter
|
|
local stats = {} --information table
|
|
local filter_time = 1000 --filter time
|
|
local additional_time = 0
|
|
|
|
--constants
|
|
local actor_position = 0
|
|
local actor_item_drop = 1
|
|
local actor_item_take = 2
|
|
local actor_item_use = 3
|
|
local actor_update_task = 4
|
|
local actor_money_trade = 5
|
|
local actor_money_quest = 6
|
|
local actor_money_total = 7
|
|
----------------------------------------------------------
|
|
function initialize ()
|
|
stats = {}
|
|
end
|
|
----------------------------------------------------------
|
|
function shutdown ()
|
|
printf ("GAME STATS START AT LEVEL [%s]", level.name ())
|
|
local l_name = level.name ()
|
|
for a = 1, #stats, 1 do
|
|
if stats[a].id == actor_position then
|
|
printf ("[stats][%s][%s][%d][%f,%f,%f][%f, %f, %f]", l_name, stats[a].time, stats[a].id, stats[a].position.x, stats[a].position.y, stats[a].position.z, stats[a].health, stats[a].radiation, stats[a].satiety)
|
|
elseif stats[a].id == actor_item_take then
|
|
printf ("[stats][%s][%s][%d][%f,%f,%f][%s]", l_name, stats[a].time, stats[a].id, stats[a].position.x, stats[a].position.y, stats[a].position.z, stats[a].item_name)
|
|
elseif stats[a].id == actor_item_drop then
|
|
printf ("[stats][%s][%s][%d][%f,%f,%f][%s]", l_name, stats[a].time, stats[a].id, stats[a].position.x, stats[a].position.y, stats[a].position.z, stats[a].item_name)
|
|
elseif stats[a].id == actor_money_trade or stats[a].id == actor_money_quest or stats[a].id == actor_money_total then
|
|
printf ("[stats][%s][%s][%d][%f,%f,%f][%d]", l_name, stats[a].time, stats[a].id, stats[a].position.x, stats[a].position.y, stats[a].position.z, stats[a].money)
|
|
end
|
|
end
|
|
stats = {}
|
|
end
|
|
----------------------------------------------------------
|
|
function update (delta, actor)
|
|
additional_time = additional_time + delta
|
|
if additional_time < filter_time then
|
|
return
|
|
end
|
|
additional_time = 0
|
|
local t = {
|
|
time = game.get_game_time ():timeToString (game.CTime.TimeToSeconds),
|
|
id = actor_position,
|
|
position = actor:position (),
|
|
health = actor.health,
|
|
radiation = actor.radiation,
|
|
satiety = actor.satiety
|
|
}
|
|
table.insert (stats, t)
|
|
end
|
|
----------------------------------------------------------
|
|
function update_task (id_task, subtask, id_state, actor)
|
|
|
|
local state
|
|
if subtask == 0 then
|
|
if id_state == task.fail then
|
|
state = "fail"
|
|
elseif id_state == task.completed then
|
|
state = "complete"
|
|
else
|
|
state = "new"
|
|
end
|
|
else
|
|
state = "update"
|
|
end
|
|
|
|
local t =
|
|
{
|
|
time = game.get_game_time ():timeToString (game.CTime.TimeToSeconds),
|
|
id = actor_update_task,
|
|
position = actor:position (),
|
|
task = string.format ("%s, %s, %s", id_task, subtask, state)
|
|
}
|
|
table.insert (stats, t)
|
|
end
|
|
----------------------------------------------------------
|
|
function update_take_item (object, actor)
|
|
local t = {
|
|
time = game.get_game_time ():timeToString (game.CTime.TimeToSeconds),
|
|
id = actor_item_take,
|
|
position = actor:position (),
|
|
item_name = object:name ()
|
|
}
|
|
table.insert (stats, t)
|
|
end
|
|
----------------------------------------------------------
|
|
function update_drop_item (object, actor)
|
|
local t = {
|
|
time = game.get_game_time ():timeToString (game.CTime.TimeToSeconds),
|
|
id = actor_item_drop,
|
|
position = db.actor:position (),
|
|
item_name = object:name ()
|
|
}
|
|
table.insert (stats, t)
|
|
end
|
|
----------------------------------------------------------
|
|
function money_trade_update (money_i)
|
|
local t = {
|
|
time = game.get_game_time ():timeToString (game.CTime.TimeToSeconds),
|
|
id = actor_money_trade,
|
|
position = db.actor:position (),
|
|
money = money_i
|
|
}
|
|
table.insert (stats, t)
|
|
t = {
|
|
time = game.get_game_time ():timeToString (game.CTime.TimeToSeconds),
|
|
id = actor_money_total,
|
|
position = db.actor:position (),
|
|
money = db.actor:money ()
|
|
}
|
|
table.insert (stats, t)
|
|
end
|
|
----------------------------------------------------------
|
|
function money_quest_update (money_i)
|
|
local t = {
|
|
time = game.get_game_time ():timeToString (game.CTime.TimeToSeconds),
|
|
id = actor_money_quest,
|
|
position = db.actor:position (),
|
|
money = money_i
|
|
}
|
|
table.insert (stats, t)
|
|
t = {
|
|
time = game.get_game_time ():timeToString (game.CTime.TimeToSeconds),
|
|
id = actor_money_total,
|
|
position = db.actor:position (),
|
|
money = db.actor:money ()
|
|
}
|
|
table.insert (stats, t)
|
|
end
|
|
----------------------------------------------------------
|