mirror of
https://github.com/Refactorio/RedMew.git
synced 2024-12-10 10:00:00 +02:00
Fixed inverted height and width
Polygons are not being placed correctly
This commit is contained in:
parent
71044d6ade
commit
f811da5b30
@ -10,6 +10,8 @@ local set_timeout_in_ticks = Task.set_timeout_in_ticks
|
||||
local debug_print = Debug.print
|
||||
|
||||
local skip_btn_name = Gui.uid_name()
|
||||
local backward_btn_name = Gui.uid_name()
|
||||
local forward_btn_name = Gui.uid_name()
|
||||
|
||||
local Public = {}
|
||||
local handler
|
||||
@ -37,18 +39,70 @@ local function valid(entity)
|
||||
return entity and entity.valid
|
||||
end
|
||||
|
||||
local play_sound_delayed =
|
||||
local function waypoint_still_active(tick, player_index)
|
||||
local running_cutscene = running_cutscenes[player_index]
|
||||
tick = tick or -1
|
||||
if tick == -1 then
|
||||
debug_print('Tick was nil', 5)
|
||||
end
|
||||
if not running_cutscene or tick < running_cutscene.start_tick then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local toggle_gui_delayed =
|
||||
Token.register(
|
||||
function(params)
|
||||
params.player.play_sound {path = params.path}
|
||||
local player = params.player
|
||||
if not waypoint_still_active(params.tick, player.index) then
|
||||
debug_print('Cutscene is no longer active. Skipping toggle_gui')
|
||||
return
|
||||
end
|
||||
local event = {player = player}
|
||||
local clear = params.clear
|
||||
if clear == 'left' then
|
||||
player.gui.left.clear()
|
||||
elseif clear == 'top' then
|
||||
player.gui.top.clear()
|
||||
elseif clear == 'center' then
|
||||
player.gui.center.clear()
|
||||
end
|
||||
params.gui.toggle(event)
|
||||
end
|
||||
)
|
||||
|
||||
function Public.play_sound(player, path, times, delay, initial_delay)
|
||||
function Public.toggle_gui(tick, player, gui, initial_delay, clear)
|
||||
--[[if type(gui) == 'table' then
|
||||
debug_print('Provided GUI is invalid.')
|
||||
return
|
||||
end]]
|
||||
set_timeout_in_ticks(initial_delay, toggle_gui_delayed, {tick = tick, player = player, gui = gui, clear = clear})
|
||||
end
|
||||
|
||||
local play_sound_delayed =
|
||||
Token.register(
|
||||
function(params)
|
||||
local player = params.player
|
||||
if not waypoint_still_active(params.tick, player.index) then
|
||||
debug_print('Cutscene is no longer active. Skipping play_sound')
|
||||
return
|
||||
end
|
||||
player.play_sound {path = params.path}
|
||||
end
|
||||
)
|
||||
|
||||
function Public.play_sound(tick, player, path, times, delay, initial_delay)
|
||||
if not game.is_valid_sound_path(path) then
|
||||
debug_print('Provided SoundPath is invalid. Try opening /radio and browse for a valid path')
|
||||
return
|
||||
end
|
||||
|
||||
if not waypoint_still_active(tick, player.index) then
|
||||
debug_print('Cutscene is no longer active. Skipping play_sound')
|
||||
return
|
||||
end
|
||||
|
||||
times = times or 1
|
||||
if times == 1 and not delay and initial_delay then
|
||||
delay = initial_delay
|
||||
@ -57,7 +111,7 @@ function Public.play_sound(player, path, times, delay, initial_delay)
|
||||
delay = delay or 20
|
||||
initial_delay = initial_delay or 0
|
||||
for i = 1, times, 1 do
|
||||
set_timeout_in_ticks(initial_delay + delay * i, play_sound_delayed, {player = player, path = path})
|
||||
set_timeout_in_ticks(initial_delay + delay * i, play_sound_delayed, {tick = tick, player = player, path = path})
|
||||
end
|
||||
else
|
||||
player.play_sound {path = path}
|
||||
@ -129,7 +183,9 @@ function Public.register_running_cutscene(player_index, identifier, final_transi
|
||||
final_transition_time = final_transition_time,
|
||||
character = player.character,
|
||||
terminate_func = cutscene_function.terminate_func,
|
||||
rendering = {}
|
||||
rendering = {},
|
||||
current_index = -1,
|
||||
start_tick = 0
|
||||
}
|
||||
local running_cutscene = running_cutscenes[player_index]
|
||||
|
||||
@ -148,14 +204,28 @@ function Public.register_running_cutscene(player_index, identifier, final_transi
|
||||
final_transition_time = final_transition_time
|
||||
}
|
||||
|
||||
local btn = player.gui.top.add {type = 'sprite-button', name = skip_btn_name, caption = 'Skip cutscene'}
|
||||
local flow = player.gui.top.add {type = 'flow'}
|
||||
running_cutscene.btn = flow
|
||||
|
||||
local btn = flow.add {type = 'sprite-button', name = skip_btn_name, caption = 'Skip cutscene'}
|
||||
btn.style.minimal_height = 28
|
||||
btn.style.minimal_width = 150
|
||||
btn.style.font = 'default-large-bold'
|
||||
btn.style.font_color = {r = 255, g = 215, b = 0}
|
||||
running_cutscene.btn = btn
|
||||
|
||||
handler({player_index = player_index, waypoint_index = -1})
|
||||
local back_btn = flow.add {type = 'sprite-button', name = backward_btn_name, caption = 'Go back'}
|
||||
back_btn.style.minimal_height = 28
|
||||
back_btn.style.minimal_width = 100
|
||||
back_btn.style.font = 'default-large-bold'
|
||||
back_btn.style.font_color = {r = 255, g = 215, b = 0}
|
||||
|
||||
local forward_btn = flow.add {type = 'sprite-button', name = forward_btn_name, caption = 'Go forward'}
|
||||
forward_btn.style.minimal_height = 28
|
||||
forward_btn.style.minimal_width = 100
|
||||
forward_btn.style.font = 'default-large-bold'
|
||||
forward_btn.style.font_color = {r = 255, g = 215, b = 0}
|
||||
|
||||
handler({player_index = player_index, waypoint_index = -1, tick = game.tick})
|
||||
end
|
||||
|
||||
local function restart_cutscene(player_index, waypoints, start_index)
|
||||
@ -187,7 +257,9 @@ local function restart_cutscene(player_index, waypoints, start_index)
|
||||
character = character,
|
||||
terminate_func = current_running.terminate_func,
|
||||
rendering = current_running.rendering,
|
||||
btn = current_running.btn
|
||||
btn = current_running.btn,
|
||||
current_index = current_running.current_index,
|
||||
start_tick = current_running.start_tick
|
||||
}
|
||||
|
||||
debug_print('Updating cutscene for player_index ' .. player_index)
|
||||
@ -215,7 +287,7 @@ local function restart_cutscene(player_index, waypoints, start_index)
|
||||
start_index = -1
|
||||
end
|
||||
|
||||
handler({player_index = player_index, waypoint_index = start_index})
|
||||
handler({player_index = player_index, waypoint_index = start_index, tick = game.tick})
|
||||
end
|
||||
|
||||
function Public.inject_waypoint(player_index, waypoint, waypoint_index, override)
|
||||
@ -243,8 +315,9 @@ local callback_function =
|
||||
Token.register(
|
||||
function(params)
|
||||
local player_index = params.player_index
|
||||
if (running_cutscenes[player_index]) then
|
||||
Token.get(params.func)(player_index, params.waypoint_index, params.params)
|
||||
local func_params = params.params
|
||||
if waypoint_still_active(func_params.tick, player_index) then
|
||||
Token.get(params.func)(player_index, params.waypoint_index, func_params)
|
||||
else
|
||||
debug_print('Skipping callback function. Cutscene got terminated!')
|
||||
end
|
||||
@ -290,14 +363,14 @@ function Public.terminate_cutscene(player_index, ticks)
|
||||
)
|
||||
end
|
||||
|
||||
function Public.register_rendering_id(player_index, render_id)
|
||||
function Public.register_rendering_id(player_index, tick, render_id)
|
||||
if type(render_id) ~= 'table' then
|
||||
render_id = {render_id}
|
||||
end
|
||||
local running_cutscene = running_cutscenes[player_index]
|
||||
for _, id in pairs(render_id) do
|
||||
if rendering.is_valid(id) then
|
||||
if not running_cutscene then
|
||||
if not waypoint_still_active(tick, player_index) then
|
||||
debug_print('The rendering with id ' .. id .. ' was not added. Destroying it instead')
|
||||
rendering.destroy(id)
|
||||
else
|
||||
@ -316,13 +389,16 @@ end
|
||||
handler = function(event)
|
||||
local player_index = event.player_index
|
||||
local waypoint_index = event.waypoint_index
|
||||
local tick = event.tick
|
||||
|
||||
debug_print('Waypoint_index ' .. waypoint_index .. ' has finished')
|
||||
debug_print('Waypoint_index ' .. waypoint_index .. ' has finished at tick: ' .. tick)
|
||||
|
||||
local running_cutscene = running_cutscenes[player_index]
|
||||
if not running_cutscene then
|
||||
return
|
||||
end
|
||||
running_cutscene.current_index = waypoint_index + 1
|
||||
running_cutscene.start_tick = tick
|
||||
|
||||
local update = running_cutscene.update
|
||||
if update then
|
||||
@ -350,7 +426,8 @@ handler = function(event)
|
||||
time_to_wait = current_waypoint.time_to_wait,
|
||||
transition_time = current_waypoint.transition_time,
|
||||
zoom = current_waypoint.zoom,
|
||||
name = current_waypoint.name
|
||||
name = current_waypoint.name,
|
||||
tick = tick
|
||||
}
|
||||
|
||||
debug_print('Waypoint_index ' .. waypoint_index + 1 .. ' (waypoint #' .. waypoint_index + 2 .. ') callback in ' .. ticks .. ' ticks')
|
||||
@ -358,6 +435,18 @@ handler = function(event)
|
||||
set_timeout_in_ticks(ticks, callback_function, {func = running_cutscene.func, player_index = player_index, waypoint_index = waypoint_index, params = params})
|
||||
end
|
||||
|
||||
function Public.goTo(player_index, waypoint_index)
|
||||
local running_cutscene = running_cutscenes[player_index]
|
||||
if waypoint_index < 0 or waypoint_index > #running_cutscene.waypoints - 2 then
|
||||
return false
|
||||
end
|
||||
Token.get(remove_renderings)(running_cutscene.rendering)
|
||||
game.get_player(player_index).jump_to_cutscene_waypoint(waypoint_index)
|
||||
handler({player_index = player_index, waypoint_index = waypoint_index - 1, tick = game.tick})
|
||||
running_cutscene.current_index = waypoint_index
|
||||
return true
|
||||
end
|
||||
|
||||
local function restore(event)
|
||||
Public.terminate_cutscene(event.player_index)
|
||||
end
|
||||
@ -417,4 +506,24 @@ Gui.on_click(
|
||||
end
|
||||
)
|
||||
|
||||
Gui.on_click(
|
||||
backward_btn_name,
|
||||
function(event)
|
||||
local player_index = event.player_index
|
||||
if Public.goTo(player_index, running_cutscenes[player_index].current_index - 1) == false then
|
||||
game.get_player(player_index).print("Cutscene: You're already at the beginning")
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Gui.on_click(
|
||||
forward_btn_name,
|
||||
function(event)
|
||||
local player_index = event.player_index
|
||||
if Public.goTo(event.player_index, running_cutscenes[player_index].current_index + 1) == false then
|
||||
game.get_player(player_index).print("Cutscene: You're already at the end")
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
return Public
|
||||
|
@ -46,12 +46,12 @@ local function fit_to_screen(percentage, coordinates)
|
||||
local tile = percentage.tile
|
||||
for _, pos in pairs(coordinates) do
|
||||
if type(pos) == 'number' then
|
||||
coordinates.x = coordinates.x * height
|
||||
coordinates.y = coordinates.y * width
|
||||
coordinates.x = coordinates.x * width
|
||||
coordinates.y = coordinates.y * height
|
||||
break
|
||||
else
|
||||
pos.x = pos.x * height
|
||||
pos.y = pos.y * width
|
||||
pos.x = pos.x * width
|
||||
pos.y = pos.y * height
|
||||
end
|
||||
end
|
||||
for _, pos in pairs(coordinates) do
|
||||
@ -283,7 +283,7 @@ function Public.draw_arrow(settings, offset, player, params)
|
||||
params.players = players
|
||||
|
||||
params.surface = RS.get_surface()
|
||||
|
||||
Debug.print(vertices)
|
||||
return Rendering.draw_polygon(vertices, params)
|
||||
end
|
||||
|
||||
|
@ -3,7 +3,7 @@ local Token = require 'utils.token'
|
||||
local Task = require 'utils.task'
|
||||
local Debug = require 'utils.debug'
|
||||
local Cutscene = require 'features.cutscene.cutscene_controller'
|
||||
local CS_Rendering = require 'features.cutscene.Rendering'
|
||||
local CS_Rendering = require 'features.cutscene.rendering'
|
||||
local RS = require 'map_gen.shared.redmew_surface'
|
||||
local Color = require 'resources.color_presets'
|
||||
local PC = require 'features.player_create'
|
||||
@ -13,21 +13,23 @@ local play_sound = Cutscene.play_sound
|
||||
local draw_text = CS_Rendering.draw_text
|
||||
local draw_multi_line = CS_Rendering.draw_multi_line_text
|
||||
local rad = math.rad
|
||||
local Rendering = require 'utils.Rendering'
|
||||
local Rendering = require 'utils.rendering'
|
||||
|
||||
local DiggyCutscene = {}
|
||||
|
||||
local delayed_draw_text =
|
||||
Token.register(
|
||||
function(params)
|
||||
local tick = params.tick
|
||||
local player = params.player
|
||||
if params.play_sound > 1 then
|
||||
play_sound(params.player, 'utility/list_box_click', 1)
|
||||
play_sound(tick, player, 'utility/list_box_click', 1)
|
||||
end
|
||||
register_rendering(params.player.index, draw_text(params.settings, params.offset, params.text, params.player, params.params, params.draw_background))
|
||||
register_rendering(player.index, tick, draw_text(params.settings, params.offset, params.text, params.player, params.params, params.draw_background))
|
||||
end
|
||||
)
|
||||
|
||||
local function draw_text_auto_replacing(settings, offset, texts, player, params, draw_background, time, between_time)
|
||||
local function draw_text_auto_replacing(tick, settings, offset, texts, player, params, draw_background, time, between_time)
|
||||
time = time or 400
|
||||
time = time / #texts
|
||||
between_time = between_time or 30
|
||||
@ -37,11 +39,7 @@ local function draw_text_auto_replacing(settings, offset, texts, player, params,
|
||||
end
|
||||
for i = 1, #texts do
|
||||
if texts[i] ~= '' then
|
||||
Task.set_timeout_in_ticks(
|
||||
time * (i - 1),
|
||||
delayed_draw_text,
|
||||
{settings = settings, offset = offset, text = texts[i], player = player, params = params, draw_background = draw_background, play_sound = i}
|
||||
)
|
||||
Task.set_timeout_in_ticks(time * (i - 1), delayed_draw_text, {tick = tick, settings = settings, offset = offset, text = texts[i], player = player, params = params, draw_background = draw_background, play_sound = i})
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -50,42 +48,26 @@ local delayed_draw_arrow =
|
||||
Token.register(
|
||||
function(params)
|
||||
local player = params.player
|
||||
local tick = params.tick
|
||||
params = params.params
|
||||
local rendering_parmas = params.params
|
||||
local id = CS_Rendering.draw_arrow(params.settings, params.offset, player, rendering_parmas)
|
||||
register_rendering(player.index, id)
|
||||
register_rendering(player.index, tick, id)
|
||||
Rendering.blink(id, 20, rendering_parmas.time_to_live)
|
||||
end
|
||||
)
|
||||
|
||||
local function delayed_function(func, player, params, offset_time)
|
||||
Task.set_timeout_in_ticks(offset_time, func, {player = player, params = params})
|
||||
local function delayed_function(func, player, tick, params, offset_time)
|
||||
Task.set_timeout_in_ticks(offset_time, func, {player = player, tick = tick, params = params})
|
||||
end
|
||||
|
||||
local delayed_blackout =
|
||||
Token.register(
|
||||
function(params)
|
||||
register_rendering(params.player.index, CS_Rendering.blackout(params.player, params.params.zoom, params.params.time_to_live, params.params.color))
|
||||
end
|
||||
)
|
||||
|
||||
local delayed_fade_blackout =
|
||||
Token.register(
|
||||
function(params)
|
||||
local id = CS_Rendering.blackout(params.player, params.params.zoom, params.params.time_to_live, params.params.color)
|
||||
register_rendering(params.player.index, id)
|
||||
Rendering.fade(id, params.params.time_to_live - 1, 10)
|
||||
end
|
||||
)
|
||||
|
||||
local delay_open_gui =
|
||||
Token.register(
|
||||
function(params)
|
||||
local event = {player = params.player}
|
||||
if params.clear then
|
||||
params.player.gui.left.clear()
|
||||
end
|
||||
Experience.toggle(event)
|
||||
local render_params = params.params
|
||||
local id = CS_Rendering.blackout(params.player, render_params.zoom, render_params.time_to_live, render_params.color)
|
||||
register_rendering(params.player.index, params.tick, id)
|
||||
Rendering.fade(id, render_params.time_to_live - 1, 10)
|
||||
end
|
||||
)
|
||||
|
||||
@ -98,57 +80,59 @@ local function cutscene_function(player_index, waypoint_index, params)
|
||||
local player = game.players[player_index]
|
||||
local ttw = params.time_to_wait
|
||||
local zoom = params.zoom
|
||||
local tick = params.tick
|
||||
local settings = {original_resolution = original_resolution, original_zoom = original_zoom, player_zoom = zoom}
|
||||
|
||||
if waypoint_index ~= -1 then
|
||||
play_sound(player, 'utility/list_box_click', 1)
|
||||
--play_sound(player, 'utility/inventory_move', 1, 10)
|
||||
play_sound(tick, player, 'utility/list_box_click', 1)
|
||||
--play_sound(tick, player, 'utility/inventory_move', 1, 10)
|
||||
end
|
||||
cases[-1] = function()
|
||||
play_sound(player, 'utility/game_won')
|
||||
play_sound(player, 'ambient/first-light', 1, 550)
|
||||
register_rendering(player_index, CS_Rendering.blackout(player, zoom, ttw + 1))
|
||||
register_rendering(player_index, draw_text(settings, {x = 0, y = -16}, 'Diggy', player, {scale = 10, time_to_live = ttw, color = Color.yellow}, false))
|
||||
play_sound(tick, player, 'utility/game_won')
|
||||
play_sound(tick, player, 'ambient/first-light', 1, 550)
|
||||
register_rendering(player_index, tick, CS_Rendering.blackout(player, zoom, ttw + 1))
|
||||
register_rendering(player_index, tick, draw_text(settings, {x = 0, y = -16}, 'Diggy', player, {scale = 10, time_to_live = ttw, color = Color.yellow}, false))
|
||||
register_rendering(
|
||||
player_index,
|
||||
tick,
|
||||
draw_multi_line(settings, {x = 0, y = -5}, {{'diggy.cutscene_case_line2', 'Diggy'}, '---------------------', {'diggy.cutscene_case_line4', 'Redmew'}, {'diggy.cutscene_case_line5', 'www.redmew.com/discord'}}, player, {scale = 5, time_to_live = ttw}, false)
|
||||
)
|
||||
draw_text_auto_replacing(settings, {x = 0, y = 10}, {'', {'diggy.cutscene_case_line6'}}, player, {scale = 3}, false, ttw, 0)
|
||||
draw_text_auto_replacing(settings, {x = 0, y = 16}, {'', '', {'diggy.cutscene_case_line7'}}, player, {scale = 1}, false, ttw, 0)
|
||||
delayed_function(delayed_blackout, player, {zoom = zoom, time_to_live = (275 * 7), color = {0, 0, 0, 1}}, ttw)
|
||||
draw_text_auto_replacing(tick, settings, {x = 0, y = 10}, {'', {'diggy.cutscene_case_line6'}}, player, {scale = 3}, false, ttw, 0)
|
||||
draw_text_auto_replacing(tick, settings, {x = 0, y = 16}, {'', '', {'diggy.cutscene_case_line7'}}, player, {scale = 1}, false, ttw, 0)
|
||||
end
|
||||
cases[0] = function()
|
||||
register_rendering(player_index, draw_text(settings, {x = 0, y = 0}, 'Redmew - Diggy', player, {scale = 10, time_to_live = ttw - 60, color = Color.red}, false))
|
||||
register_rendering(player_index, draw_text(settings, {x = 0, y = -5}, 'Introduction', player, {scale = 5, time_to_live = ttw - 60}, false))
|
||||
register_rendering(player_index, tick, CS_Rendering.blackout(player, zoom, ttw + 1))
|
||||
register_rendering(player_index, tick, draw_text(settings, {x = 0, y = 0}, 'Redmew - Diggy', player, {scale = 10, time_to_live = ttw - 60, color = Color.red}, false))
|
||||
register_rendering(player_index, tick, draw_text(settings, {x = 0, y = -5}, 'Introduction', player, {scale = 5, time_to_live = ttw - 60}, false))
|
||||
|
||||
delayed_function(delayed_draw_arrow, player, {settings = settings, offset = {x = -34, y = -21}, params = {rotation = rad(-45), time_to_live = 275 * 3 - 30}}, 0)
|
||||
delayed_function(delayed_draw_arrow, player, tick, {settings = settings, offset = {x = -33, y = -20}, params = {rotation = rad(-45), time_to_live = 275 * 3 - 30}}, 0)
|
||||
|
||||
draw_text_auto_replacing(settings, {x = -31.5, y = -19.5}, {'This is our toolbar!'}, player, {scale = 2.5, alignment = 'left'}, false, 275)
|
||||
draw_text_auto_replacing(tick, settings, {x = -31.5, y = -19.5}, {'This is our toolbar!'}, player, {scale = 2.5, alignment = 'left'}, false, 275)
|
||||
|
||||
draw_text_auto_replacing(settings, {x = -31.5, y = -19.5}, {'', "Here you'll find a wide range of tools and informations about us!"}, player, {scale = 2.5, alignment = 'left'}, false, 275 * 2)
|
||||
draw_text_auto_replacing(tick, settings, {x = -31.5, y = -19.5}, {'', "Here you'll find a wide range of tools and informations about us!"}, player, {scale = 2.5, alignment = 'left'}, false, 275 * 2)
|
||||
|
||||
draw_text_auto_replacing(settings, {x = -31.5, y = -19.5}, {'', '', 'Hover your mouse over them for more information'}, player, {scale = 2.5, alignment = 'left'}, false, 275 * 3)
|
||||
draw_text_auto_replacing(tick, settings, {x = -31.5, y = -19.5}, {'', '', 'Hover your mouse over them for more information'}, player, {scale = 2.5, alignment = 'left'}, false, 275 * 3)
|
||||
|
||||
delayed_function(delayed_draw_arrow, player, {settings = settings, offset = {x = -39.5, y = -21}, params = {rotation = rad(-45), time_to_live = 275 - 30}}, 275 * 3)
|
||||
delayed_function(delayed_draw_arrow, player, tick, {settings = settings, offset = {x = -38.5, y = -20}, params = {rotation = rad(-45), time_to_live = 275 - 30}}, 275 * 3)
|
||||
|
||||
draw_text_auto_replacing(settings, {x = -37, y = -19.5}, {'', '', '', 'You can toggle our toolbar with this button'}, player, {scale = 2.5, alignment = 'left'}, false, 275 * 4)
|
||||
draw_text_auto_replacing(tick, settings, {x = -37, y = -19.5}, {'', '', '', 'You can toggle our toolbar with this button'}, player, {scale = 2.5, alignment = 'left'}, false, 275 * 4)
|
||||
|
||||
delayed_function(delayed_draw_arrow, player, {settings = settings, offset = {x = -37, y = -21}, params = {rotation = rad(-45), time_to_live = 275 - 30}}, 275 * 4.5)
|
||||
delayed_function(delayed_draw_arrow, player, tick, {settings = settings, offset = {x = -36, y = -20}, params = {rotation = rad(-45), time_to_live = 275 - 30}}, 275 * 4.5)
|
||||
|
||||
draw_text_auto_replacing(settings, {x = -34.5, y = -19.5}, {'', '', '', '', 'This is the Diggy experience menu'}, player, {scale = 2.5, alignment = 'left'}, false, 275 * 5.5)
|
||||
draw_text_auto_replacing(tick, settings, {x = -34.5, y = -19.5}, {'', '', '', '', 'This is the Diggy experience menu'}, player, {scale = 2.5, alignment = 'left'}, false, 275 * 5.5)
|
||||
|
||||
delayed_function(delayed_draw_arrow, player, {settings = settings, offset = {x = -27, y = -13}, params = {rotation = rad(-90), time_to_live = 275 - 30}}, 275 * 5.5)
|
||||
delayed_function(delayed_draw_arrow, player, tick, {settings = settings, offset = {x = -26, y = -13}, params = {rotation = rad(-90), time_to_live = 275 - 30}}, 275 * 5.5)
|
||||
|
||||
delayed_function(delay_open_gui, player, {clear = true}, 275 * 5.5)
|
||||
Cutscene.toggle_gui(tick, player, Experience, 275 * 5.5, 'left')
|
||||
|
||||
draw_text_auto_replacing(settings, {x = -24, y = -13.2}, {'', '', '', '', '', 'Here you can see the current progress of the mine'}, player, {scale = 2.5, alignment = 'left'}, false, 275 * 6.5)
|
||||
draw_text_auto_replacing(tick, settings, {x = -24, y = -13.2}, {'', '', '', '', '', 'Here you can see the current progress of the mine'}, player, {scale = 2.5, alignment = 'left'}, false, 275 * 6.5)
|
||||
|
||||
delayed_function(delay_open_gui, player, {}, 275 * 6.5)
|
||||
Cutscene.toggle_gui(tick, player, Experience, 275 * 6.5)
|
||||
|
||||
delayed_function(delayed_fade_blackout, player, {zoom = zoom, time_to_live = 120+61, color = {0, 0, 0, 1}}, ttw - 61)
|
||||
delayed_function(delayed_fade_blackout, player, tick, {zoom = zoom, time_to_live = 120 + 61, color = {0, 0, 0, 1}}, ttw - 61)
|
||||
end
|
||||
cases[1] = function()
|
||||
draw_text_auto_replacing(settings, {x = 0, y = 18}, {{'diggy.cutscene_case0_line1'}, {'diggy.cutscene_case0_line3'}}, player, {scale = 2.5}, true, ttw)
|
||||
draw_text_auto_replacing(tick, settings, {x = 0, y = 18}, {{'diggy.cutscene_case0_line1'}, {'diggy.cutscene_case0_line3'}}, player, {scale = 2.5}, true, ttw)
|
||||
local entity = RS.get_surface().find_entities_filtered {position = {0, 0}, radius = 20, name = 'stone-wall', limit = 1}
|
||||
if entity[1] then
|
||||
local position = entity[1].position
|
||||
@ -164,14 +148,14 @@ local function cutscene_function(player_index, waypoint_index, params)
|
||||
end
|
||||
end
|
||||
cases[2] = function()
|
||||
--play_sound(player, 'utility/build_small', 1, 25)
|
||||
draw_text_auto_replacing(settings, {x = 0, y = 18}, {{'diggy.cutscene_case1_line1'}}, player, {scale = 2.5}, true, ttw)
|
||||
--play_sound(tick, player, 'utility/build_small', 1, 25)
|
||||
draw_text_auto_replacing(tick, settings, {x = 0, y = 18}, {{'diggy.cutscene_case1_line1'}}, player, {scale = 2.5}, true, ttw)
|
||||
end
|
||||
cases[3] = function()
|
||||
draw_text_auto_replacing(settings, {x = 0, y = 18}, {{'diggy.cutscene_case2_line1'}, {'diggy.cutscene_case2_line3'}}, player, {scale = 2.5}, true, ttw)
|
||||
draw_text_auto_replacing(tick, settings, {x = 0, y = 18}, {{'diggy.cutscene_case2_line1'}, {'diggy.cutscene_case2_line3'}}, player, {scale = 2.5}, true, ttw)
|
||||
end
|
||||
cases[4] = function()
|
||||
draw_text_auto_replacing(settings, {x = 0, y = 18}, {{'diggy.cutscene_case3_line1'}, {'diggy.cutscene_case3_line3'}}, player, {scale = 2.5}, true, ttw)
|
||||
draw_text_auto_replacing(tick, settings, {x = 0, y = 18}, {{'diggy.cutscene_case3_line1'}, {'diggy.cutscene_case3_line3'}}, player, {scale = 2.5}, true, ttw)
|
||||
local radius = 10
|
||||
local entity
|
||||
repeat
|
||||
@ -201,24 +185,24 @@ local function cutscene_function(player_index, waypoint_index, params)
|
||||
Cutscene.inject_waypoint(player_index, waypoint, waypoint_index + 3)
|
||||
end
|
||||
cases[5] = function()
|
||||
play_sound(player, 'utility/axe_mining_ore', 3, 35)
|
||||
draw_text_auto_replacing(settings, {x = 0, y = 18}, {{'diggy.cutscene_case4_line1'}, {'diggy.cutscene_case4_line3'}}, player, {scale = 2.5}, true, ttw)
|
||||
play_sound(waypoint_index, player, 'utility/axe_mining_ore', 3, 35)
|
||||
draw_text_auto_replacing(tick, settings, {x = 0, y = 18}, {{'diggy.cutscene_case4_line1'}, {'diggy.cutscene_case4_line3'}}, player, {scale = 2.5}, true, ttw)
|
||||
end
|
||||
cases[6] = function()
|
||||
play_sound(player, 'utility/research_completed', 1, 5)
|
||||
play_sound(tick, player, 'utility/research_completed', 1, 5)
|
||||
local exp = 2500
|
||||
local text = {'', '[img=item/automation-science-pack] ', {'diggy.float_xp_gained_research', exp}}
|
||||
player.create_local_flying_text {position = params.position, text = text, color = Color.light_sky_blue, time_to_live = ttw / 3}
|
||||
draw_text_auto_replacing(settings, {x = 0, y = 18}, {{'diggy.cutscene_case5_line1'}, {'diggy.cutscene_case5_line3'}}, player, {scale = 2.5}, true, ttw)
|
||||
draw_text_auto_replacing(tick, settings, {x = 0, y = 18}, {{'diggy.cutscene_case5_line1'}, {'diggy.cutscene_case5_line3'}}, player, {scale = 2.5}, true, ttw)
|
||||
end
|
||||
cases[7] = function()
|
||||
play_sound(player, 'utility/axe_fighting', 5, 25, 10)
|
||||
play_sound(player, 'worm-sends-biters', 1, 70)
|
||||
draw_text_auto_replacing(settings, {x = 0, y = 18}, {{'diggy.cutscene_case6_line1'}, {'diggy.cutscene_case6_line3'}}, player, {scale = 2.5}, true, ttw)
|
||||
play_sound(tick, player, 'utility/axe_fighting', 5, 25, 10)
|
||||
play_sound(tick, player, 'worm-sends-biters', 1, 70)
|
||||
draw_text_auto_replacing(tick, settings, {x = 0, y = 18}, {{'diggy.cutscene_case6_line1'}, {'diggy.cutscene_case6_line3'}}, player, {scale = 2.5}, true, ttw)
|
||||
end
|
||||
cases[8] = function()
|
||||
draw_text_auto_replacing(settings, {x = 0, y = 18}, {{'diggy.cutscene_case7_line1'}, {'diggy.cutscene_case7_line3'}}, player, {scale = 2.5}, true, ttw)
|
||||
--play_sound(player, 'utility/tutorial_notice', 1)
|
||||
draw_text_auto_replacing(tick, settings, {x = 0, y = 18}, {{'diggy.cutscene_case7_line1'}, {'diggy.cutscene_case7_line3'}}, player, {scale = 2.5}, true, ttw)
|
||||
--play_sound(tick, player, 'utility/tutorial_notice', 1)
|
||||
end
|
||||
local case = cases[waypoint_index]
|
||||
if case then
|
||||
@ -237,7 +221,7 @@ local waypoints = {
|
||||
{
|
||||
-- case -1.1
|
||||
position = {x = 0, y = 0},
|
||||
transition_time = 60,
|
||||
transition_time = 0,
|
||||
time_to_wait = 275 * 7,
|
||||
zoom = 0.5
|
||||
},
|
||||
|
@ -1,5 +1,5 @@
|
||||
local shapes = {
|
||||
arrow = {
|
||||
arrow_point = {
|
||||
--triangle
|
||||
{1, 1}, -- right edge g
|
||||
{-1, 1}, -- left edge b
|
||||
@ -9,7 +9,8 @@ local shapes = {
|
||||
{0.5, 2}, -- right inner bottom e
|
||||
{-0.5, 1}, -- left inner top c
|
||||
{-0.5, 2} -- left inner bottom d
|
||||
}
|
||||
},
|
||||
arrow = {{1, 0}, {-1, 0}, {0, -1}, {0.5, 0}, {0.5, 1}, {-0.5, 0}, {-0.5, 1}}
|
||||
}
|
||||
|
||||
return shapes
|
||||
|
@ -77,6 +77,7 @@ local fade_token =
|
||||
function Public.fade(id, time, ticks)
|
||||
ticks = ticks or 20
|
||||
local count = (time - time % ticks) / ticks
|
||||
if rendering.is_valid(id) then
|
||||
local color = rendering.get_color(id)
|
||||
local a = color.a or 1
|
||||
local decrement = a / count
|
||||
@ -86,6 +87,7 @@ function Public.fade(id, time, ticks)
|
||||
Task.set_timeout_in_ticks(ticks * i, fade_token, {id = id, color = {r = color.r, b = color.b, g = color.g, a = a}})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local blink_token =
|
||||
Token.register(
|
||||
@ -100,11 +102,13 @@ local blink_token =
|
||||
function Public.blink(id, rate, time)
|
||||
local count = (time - time % rate) / rate
|
||||
rate = (time / count) * 2
|
||||
if rendering.is_valid(id) then
|
||||
local visible = rendering.get_visible(id)
|
||||
for i = 1, count do
|
||||
visible = not visible
|
||||
Task.set_timeout_in_ticks(rate * i, blink_token, {id = id, visible = visible})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return Public
|
||||
|
Loading…
Reference in New Issue
Block a user