rendered paste bodylocal logf_console = nil
function logf( fmt, ... )
logf_console = get_console()
logf = logf_main
logf_main( fmt, ... )
end
function logf_main( fmt, ... )
local c = select( "#", ... )
if c <= 0 then -- nothing to format
logf_console:execute( ":" .. string.gsub( fmt, " ", "\160" ) )
else
logf_console:execute( ":" .. string.gsub( string.format( fmt, ... ), " ", "\160" ) )
end
end
local basic_time_factor
function time_shift_start (hour)
logf("time_shift_start() called")
basic_time_factor = level.get_time_factor ()
logf ("Need time : %d:00:00", hour )
local c_time = level.get_time_hours()
local n_time = hour
if c_time > n_time then n_time = n_time + 24 end
logf("c_time: %d, n_time: %d", c_time, n_time )
local time_diff = ( ( n_time - c_time ) )
local factor = time_diff * (2650*0.25)
logf( "time_diff: %d, factor: %d", time_diff, factor )
game.start_tutorial("time_scaling")
level.set_time_factor (factor)
logf("time_shift_start() completed")
end
function time_shift_stop()
level.set_time_factor (basic_time_factor)
logf("new time: %d", level.get_time_hours() )
spawn_bar_dolg_respawn_3()
end
function spawn_bar_dolg_respawn_3( position, total )
--' Spawn a bunch of dutyers
local index
local new_pos, x_offset, z_offset
local area_longitude, area_latitude = 40, 40
local height = 10
logf("start adding dutyers")
for index = 1, total do -- spawns dutyers numbering from index to total (1...total)
x_offset = math.random(-(area_longitude/2),(area_longitude/2)) -- 40 gives -20 to 20
z_offset = math.random(-(area_latitude/2),(area_latitude/2))
new_pos = vector():set(
position.x + x_offset,
position.y + height,
position.z + z_offset
)
alife():create("bar_dolg_respawn_3",
new_pos,
db.actor:level_vertex_id() ,
db.actor:game_vertex_id() )
logf( "dutyers %i created", index )
end
end
function tell_story( actor, npc )
logf("tell_story() called")
--'level.add_pp_effector ("vibros.ppe", 234, false)
--'time_shift_start( 24 )
--' Spawn 10 dutyers at a specific location
--' local spawn_point = db.actor:position()
local spawn_point = vector():set( 2, 8, 129 )
spawn_bar_dolg_respawn_3( spawn_point, 2 )
logf("tell_story() completed")
end