local TILE_SPACING = 8
local TILE_WIDTH = 70 + TILE_SPACING
local TILE_HEIGHT = 65 + TILE_SPACING
local LIST_MAX_HEIGHT = 0
local Hack_grid_data = {
[0] = {
[0] = {type = 0,},[1] = {type = 0,},[2] = {type = 0,},[3] = {type = 0,},[4] = {type = 0,},[5] = {type = 0,},},
[1] = {
[0] = {type = 0,},[1] = {type = 0,},[2] = {type = 0,},[3] = {type = 0,},[4] = {type = 0,},[5] = {type = 0,},},
[2] = {
[0] = {type = 0,},[1] = {type = 0,},[2] = {type = 0,},[3] = {type = 0,},[4] = {type = 0,},[5] = {type = 0,},},
[3] = {
[0] = {type = 0,},[1] = {type = 0,},[2] = {type = 0,},[3] = {type = 0,},[4] = {type = 0,},[5] = {type = 0,},},
[4] = {
[0] = {type = 0,},[1] = {type = 0,},[2] = {type = 0,},[3] = {type = 0,},[4] = {type = 0,},[5] = {type = 0,},},
[5] = {
[0] = {type = 0,},[1] = {type = 0,},[2] = {type = 0,},[3] = {type = 0,},[4] = {type = 0,},[5] = {type = 0,},},
}
local Hack_grid_solution_data = {
[0] = {
[0] = {type = 1,},[1] = {type = -1,},[2] = {type = -1,},[3] = {type = -1,},[4] = {type = -1,},[5] = {type = -1,},},
[1] = {
[0] = {type = 6,},[1] = {type = 2,},[2] = {type = 2,},[3] = {type = 2,},[4] = {type = 3,},[5] = {type = -1,},},
[2] = {
[0] = {type = -1,},[1] = {type = -1,},[2] = {type = -1,},[3] = {type = -1,},[4] = {type = 1,},[5] = {type = -1,},},
[3] = {
[0] = {type = -1,},[1] = {type = -1,},[2] = {type = -1,},[3] = {type = -1,},[4] = {type = 1,},[5] = {type = -1,},},
[4] = {
[0] = {type = -1,},[1] = {type = -1,},[2] = {type = -1,},[3] = {type = -1,},[4] = {type = 6,},[5] = {type = 3,},},
[5] = {
[0] = {type = -1,},[1] = {type = -1,},[2] = {type = -1,},[3] = {type = -1,},[4] = {type = -1,},[5] = {type = 1,},},
}
local Hack_list_data = {
[0] = {
type = 0,
max_amount = -1,
name = "cell_blank",
},
[1] = {
type = 1,
max_amount = 0,
name = "cell_hor",
},
[2] = {
type = 2,
max_amount = 0,
name = "cell_vert",
},
[3] = {
type = 3,
max_amount = 0,
name = "cell_ne",
},
[4] = {
type = 4,
max_amount = 0,
name = "cell_se",
},
[5] = {
type = 5,
max_amount = 0,
name = "cell_sw",
},
[6] = {
type = 6,
max_amount = 0,
name = "cell_nw",
},
[7] = {
type = -1,
max_amount = -1,
name = "cell_dead",
},
}
local Hack_start = 0
local Hack_end = 0
local LIST_HEIGHT = #Hack_list_data + 1
local Grid_width = 6
local Grid_height = 6
-- 0 = north, 1 = East, 2, 3
local Hack_list_connections_data = {
[0] = { -1, -1},
[1] = { 1, 3 },
[2] = { 0, 2 },
[3] = { 0, 1 },
[4] = { 1, 2 },
[5] = { 2, 3 },
[6] = { 0, 3 },
}
local Hack_list_connection_directions = {
[0] = 2,
[1] = 3,
[2] = 0,
[3] = 1,
}
local Hack_timer_thread
local Hack_timer_run = true
local Hint_bar
local List_h
local List_highlight_h
local Grid_h
local Input_tracker
local Grid_highlight_h
local Mouse_input_tracker
local Hack_main_doc_h = -1
local New_item_idx = 0
local Current_idx = 0
local List_idx = 0
local Grid_x_idx = 0
local Grid_y_idx = 0
local Timer_h = 0
local Hack_timer = 0
local Grid_max_width = 0
local Grid_max_height = 0
function hack_main_editor_init()
--[[for x = 0, Grid_height - 1 do
Hack_grid_data[ x ] = { }
for y = 0, Grid_width - 1 do
Hack_grid_data[ x ][ y ] = { }
end
end--]]
-- unload the full screen map to pillage memory
pause_map_dump()
-- Find our documents...
Hack_main_doc_h = vint_document_find("hack_main_editor")
-- Setup input tracker.+
local priority = 500000
Input_tracker = Vdo_input_tracker:new()
Input_tracker:add_input("select", "hack_main_editor_button_a", priority)
Input_tracker:add_input("back", "hack_main_editor_button_b", priority)
Input_tracker:add_input("alt_select", "hack_main_editor_button_x", 50)
Input_tracker:add_input("nav_up", "hack_main_editor_nav_up", priority)
Input_tracker:add_input("nav_down", "hack_main_editor_nav_down", priority)
Input_tracker:add_input("nav_left", "hack_main_editor_nav_left", priority)
Input_tracker:add_input("nav_right", "hack_main_editor_nav_right", priority)
Input_tracker:add_input("alt_joy_up", "hack_main_editor_list_up", priority)
Input_tracker:add_input("alt_joy_down", "hack_main_editor_list_down", priority)
Input_tracker:add_input("scroll_left", "hack_main_editor_size_down", priority)
Input_tracker:add_input("scroll_right", "hack_main_editor_size_up", priority)
Input_tracker:subscribe(true)
Grid_max_width = TILE_WIDTH * (Grid_width - 1)
Grid_max_height = TILE_HEIGHT * (Grid_height - 1)
LIST_MAX_HEIGHT = TILE_HEIGHT * (LIST_HEIGHT - 1)
-- Setup Button Hints
Hint_bar = Vdo_hint_bar:new("hint_bar", 0, Hack_main_doc_h)
local hint_data = {
{CTRL_MENU_BUTTON_B, "START/END"},
{CTRL_BUTTON_LS, "MOVE"},
{CTRL_BUTTON_X, "RESET"},
}
Hint_bar:set_hints(hint_data)
Grid_h = vint_object_find( "cell_grid" )
Grid_highlight_h = vint_object_find( "cell_highlight" )
List_h = vint_object_find( "list_main" )
List_highlight_h = vint_object_find( "list_highlight_grp" )
Timer_h = vint_object_find( "timer" )
local list_button = Vdo_hint_button:new( "list_button" )
list_button:set_button( CTRL_BUTTON_RS )
if game_get_platform() == "PC" then
Hint_bar:set_visible(true)
Hint_bar:set_highlight(0)
Mouse_input_tracker = Vdo_input_tracker:new()
Hint_bar:add_mouse_inputs("hack_main_editor", Mouse_input_tracker)
Mouse_input_tracker:subscribe(false)
end
local popup_grp_h = vint_object_find( "popup_grp" )
vint_set_property( popup_grp_h, "visible", false )
--draw the grid
hack_main_editor_draw_grid()
hack_main_editor_set_list_highlight(0)
-- position the list
local list_grp_h = vint_object_find("cell_list_grp")
local grid_x,grid_y = vint_get_property(Grid_h, "anchor")
local list_x,list_y = vint_get_property(list_grp_h, "anchor")
vint_set_property(list_grp_h, "anchor", grid_x + 50 + (Grid_width * TILE_WIDTH), grid_y )
-- position hintbar
local hint_x,hint_y = Hint_bar:get_property("anchor")
Hint_bar:set_property("anchor", grid_x + 10, grid_y + 30 + (Grid_height * TILE_HEIGHT))
Hack_timer_thread = thread_new("hack_main_editor_timer_thread")
local start_point_anim_h = vint_object_find("start_point_anim")
lua_play_anim( start_point_anim_h, 0 )
end
function hack_main_editor_cleanup()
-- reload the full screen map
pause_map_restore()
thread_kill(Hack_timer_thread)
-- Nuke all button subscriptions
Input_tracker:subscribe(false)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(false)
end
end
function hack_main_editor_validate_cells()
-- the start and end cells could be changed based on the board setup
local current_cell_x = 0
local current_cell_y = Hack_start
local incoming_direction = 3
local end_cell_x = Grid_width
local end_cell_y = Hack_end
local hack_title_h = vint_object_find("hack_title")
vint_set_property(hack_title_h,"visible",false)
-- reset grid tint
for x = 0, Grid_width - 1 do
for y = 0, Grid_height - 1 do
local cell_type = Hack_grid_data[ x ][ y ].type
if cell_type > 0 then
vint_set_property( Hack_grid_data[ x ][ y ].handle, "tint", 0.2, 0.2, 0.2 )
else
vint_set_property( Hack_grid_data[ x ][ y ].handle, "tint", 1, 1, 1 )
end
end
end
while true do
-- validate the current cell
local cell_type = Hack_grid_data[ current_cell_x ][ current_cell_y ].type
if cell_type == -1 then
return false
end
local valid = false
local exit_direction = -1
for k, v in pairs( Hack_list_connections_data[ cell_type ] ) do
if v == incoming_direction then
valid = true
else
exit_direction = v
end
end
if valid == false then
return false
end
-- update the tint
vint_set_property( Hack_grid_data[ current_cell_x ][ current_cell_y ].handle, "tint", 1, 1, 1 )
-- move to the next cell
if exit_direction == 0 then
current_cell_y = current_cell_y - 1
elseif exit_direction == 1 then
current_cell_x = current_cell_x + 1
elseif exit_direction == 2 then
current_cell_y = current_cell_y + 1
elseif exit_direction == 3 then
current_cell_x = current_cell_x - 1
else
-- hmmmmm
return false
end
-- did we win?
if current_cell_x == end_cell_x and current_cell_y == end_cell_y then
--launch success popup
--hack_main_editor_launch_popup( true )
vint_set_property(hack_title_h,"visible",true)
--kill the timer
Hack_timer_run = false
--thread_kill( Hack_timer_thread )
--kill input
--hack_main_editor_lock_controls()
return true
end
-- did we move out of the grid?
if current_cell_x < 0 or current_cell_x >= Grid_width then
return false
end
if current_cell_y < 0 or current_cell_y >= Grid_height then
return false
end
-- update incoming direction
incoming_direction = Hack_list_connection_directions[ exit_direction ]
end
end
function hack_main_editor_timer_thread()
while Hack_timer_run do
thread_yield()
if Hack_timer < 60 then
Hack_timer = Hack_timer + 1
vint_set_property( Timer_h, "text_tag", Hack_timer )
delay( 1 )
else
--we ran out of timer--launch the failure popup
--hack_main_editor_launch_popup( false )
--kill the timer
Hack_timer_run = false
--thread_kill( Hack_timer_thread )
--kill input
--hack_main_editor_lock_controls()
end
end
end
function hack_main_editor_nav_up(event, acceleration)
hack_main_editor_set_grid_highlight(-2)
end
function hack_main_editor_nav_down(event, acceleration)
hack_main_editor_set_grid_highlight(2)
end
function hack_main_editor_nav_left(event, acceleration)
hack_main_editor_set_grid_highlight(-1)
end
function hack_main_editor_nav_right(event, acceleration)
hack_main_editor_set_grid_highlight(1)
end
function hack_main_editor_size_up(event, acceleration)
Grid_width = Grid_width + 1
Grid_height = Grid_height + 1
if Grid_width > 6 then
Grid_width = 6
Grid_height = 6
end
hack_main_editor_nuke_grid()
end
function hack_main_editor_size_down(event, acceleration)
Grid_width = Grid_width - 1
Grid_height = Grid_height - 1
if Grid_width < 4 then
Grid_width = 4
Grid_height = 4
end
hack_main_editor_nuke_grid()
end
function hack_main_editor_nuke_grid()
if #Hack_grid_data > 0 then
--nuke the grid
for x = 0, #Hack_grid_data do
for y = 0, #Hack_grid_data do
vint_object_destroy( Hack_grid_data[ x ][ y ].handle )
end
end
Hack_grid_data = {}
for x = 0, Grid_width - 1 do
Hack_grid_data[ x ] = { }
for y = 0, Grid_height - 1 do
Hack_grid_data[ x ][ y ] = { }
Hack_grid_data[ x ][ y ].type = 0
end
end
Grid_max_width = TILE_WIDTH * (Grid_width - 1)
Grid_max_height = TILE_HEIGHT * (Grid_height - 1)
hack_main_editor_draw_grid()
hack_main_editor_set_grid_highlight(0)
end
end
function hack_main_editor_button_b(event, acceleration)
local cell_start_grp = vint_object_find( "cell_start_grp" )
local cell_end_grp = vint_object_find( "cell_end_grp" )
if Grid_x_idx == 0 then
Hack_start = Grid_y_idx
vint_set_property( cell_start_grp, "anchor", -10, ((Hack_start + 1) * TILE_HEIGHT) - (TILE_HEIGHT * 0.5))
elseif Grid_x_idx == Grid_width - 1 then
Hack_end = Grid_y_idx
vint_set_property( cell_end_grp, "anchor", Grid_width * TILE_WIDTH, ((Hack_end + 1) * TILE_HEIGHT) - (TILE_HEIGHT * 0.5))
end
hack_main_editor_validate_cells()
end
function hack_main_editor_button_x(event, acceleration)
hack_main_editor_reset_grid()
end
function hack_main_editor_list_up(event, acceleration)
local current_type = Hack_grid_data[ Grid_x_idx ][ Grid_y_idx ].type
--check if cell is open
if current_type >= -1 then
local upper_limit = 0
local bottom_limit = TILE_HEIGHT * (LIST_HEIGHT - 1)
local x ,y = vint_get_property( List_highlight_h, "anchor" )
y = y - TILE_HEIGHT
local prev_idx = List_idx
List_idx = List_idx - 1
if y < upper_limit then
y = bottom_limit
List_idx = LIST_HEIGHT - 1
end
hack_main_editor_update_amount( prev_idx )
vint_set_property( List_highlight_h, "anchor", 0, y )
hack_main_editor_update_cell( Grid_x_idx, Grid_y_idx )
else
--play some error sound
end
end
function hack_main_editor_list_down(event, acceleration)
local current_type = Hack_grid_data[ Grid_x_idx ][ Grid_y_idx ].type
if current_type >= -1 then
local upper_limit = 0
local bottom_limit = TILE_HEIGHT * (LIST_HEIGHT - 1)
local x ,y = vint_get_property( List_highlight_h, "anchor" )
y = y + TILE_HEIGHT
local prev_idx = List_idx
List_idx = List_idx + 1
if y > bottom_limit then
y = upper_limit
List_idx = 0
end
hack_main_editor_update_amount( prev_idx )
vint_set_property( List_highlight_h, "anchor", 0, y )
hack_main_editor_update_cell( Grid_x_idx, Grid_y_idx )
else
--play some error sound
end
end
function hack_main_editor_button_a(event, acceleration)
--TODO: Check to see if tween is done before you move to next screen.
--local current_id = Menu:get_id()
--cell_menu_handle_state(current_id)
hack_main_editor_print_list()
end
function hack_main_editor_mouse_click(event, target_handle)
local hint_index = Hint_bar:get_hint_index(target_handle)
if hint_index == 1 then
hack_main_editor_button_b()
end
-- If the target_handle matches a button, activate it
--if Menu:select_button(target_handle) == true then
--hack_main_editor_button_a()
--end
end
function hack_main_editor_mouse_move(event, target_handle)
Hint_bar:set_highlight(0)
local hint_index = Hint_bar:get_hint_index(target_handle)
if hint_index ~= 0 then
Hint_bar:set_highlight(hint_index)
game_UI_audio_play("UI_Cell_Nav")
end
end
function hack_main_editor_unlock_controls()
Input_tracker:subscribe(true)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(true)
end
end
function hack_main_editor_lock_controls()
Input_tracker:subscribe(false)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(false)
end
end
function hack_main_editor_set_list_highlight(new_idx)
local x ,y = vint_get_property(List_highlight_h, "anchor")
if new_idx == -1 then
new_idx = 7
end
if new_idx >= 0 then
List_idx = new_idx
if new_idx > 0 then
y = TILE_HEIGHT * new_idx--1 * ( TILE_HEIGHT * new_idx )
else
y = 0
end
vint_set_property(List_highlight_h, "anchor", 0, y)
else
vint_set_property(List_highlight_h, "anchor", 0, 0)
end
end
function hack_main_editor_set_grid_highlight(direction)
local x ,y = vint_get_property(Grid_highlight_h, "anchor")
if direction == 1 then
-- RIGHT
x = x + TILE_WIDTH
Grid_x_idx = Grid_x_idx + 1
elseif direction == -1 then
-- LEFT
x = x - TILE_WIDTH
Grid_x_idx = Grid_x_idx - 1
elseif direction == 2 then
-- DOWN
y = y + TILE_HEIGHT
Grid_y_idx = Grid_y_idx + 1
elseif direction == -2 then
-- UP
y = y - TILE_HEIGHT
Grid_y_idx = Grid_y_idx - 1
else
-- RESET
x = 0
Grid_x_idx = 0
y = 0
Grid_y_idx = 0
end
--check the limits
if x > Grid_max_width then
x = Grid_max_width
Grid_x_idx = Grid_width - 1
elseif x < 0 then
x = 0
Grid_x_idx = 0
end
if y > Grid_max_height then
y = Grid_max_height
Grid_y_idx = Grid_height - 1
elseif y < 0 then
y = 0
Grid_y_idx = 0
end
vint_set_property(Grid_highlight_h, "anchor", x, y)
local current_type = Hack_grid_data[ Grid_x_idx ][ Grid_y_idx ].type
hack_main_editor_set_list_highlight( current_type )
end
function hack_main_editor_update_cell( cell_x, cell_y )
--debug_print("vint","cell = "..cell_x..", "..cell_y.."\n")
--debug_print("vint","List_idx = "..List_idx.."\n")
local current_type = Hack_grid_data[ cell_x ][ cell_y ].type
local list_type = Hack_list_data[ List_idx ].type
--debug_print("vint","current_type = "..var_to_string(current_type).."\n")
--debug_print("vint","list_type = "..var_to_string(list_type).."\n\n")
if current_type >= -1 then
if current_type ~= list_type then
Hack_grid_data[ cell_x ][ cell_y ].type = list_type
hack_main_editor_set_cell_image( cell_x, cell_y )
hack_main_editor_validate_cells()
end
end
end
function hack_main_editor_set_cell_image( cell_x, cell_y )
local cell_type = Hack_grid_data[ cell_x ][ cell_y ].type
local cell_handle = Hack_grid_data[ cell_x ][ cell_y ].handle
if cell_type == -1 then
vint_set_property( cell_handle, "image", "ui_hack_grid_lock" )
vint_set_property( cell_handle, "alpha", 0.33 )
elseif cell_type == 0 then
vint_set_property( cell_handle, "image", "ui_hack_grid_blank" )
vint_set_property( cell_handle, "alpha", 0.67 )
elseif cell_type == 1 then
vint_set_property( cell_handle, "image", "ui_hack_grid_hor" )
vint_set_property( cell_handle, "alpha", 1.0 )
elseif cell_type == 2 then
vint_set_property( cell_handle, "image", "ui_hack_grid_vert" )
vint_set_property( cell_handle, "alpha", 1.0 )
elseif cell_type == 3 then
vint_set_property( cell_handle, "image", "ui_hack_grid_ne" )
vint_set_property( cell_handle, "alpha", 1.0 )
elseif cell_type == 4 then
vint_set_property( cell_handle, "image", "ui_hack_grid_ne" )
vint_set_property( cell_handle, "alpha", 1.0 )
elseif cell_type == 5 then
vint_set_property( cell_handle, "image", "ui_hack_grid_sw" )
vint_set_property( cell_handle, "alpha", 1.0 )
elseif cell_type == 6 then
vint_set_property( cell_handle, "image", "ui_hack_grid_nw" )
vint_set_property( cell_handle, "alpha", 1.0 )
end
end
function hack_main_editor_draw_list()
--loop through the list of cells and store handles
for i = 0, LIST_HEIGHT - 1 do
--store handles if we have not done so already
if Hack_list_data[ i ].handle == nil then
Hack_list_data[ i ].handle = vint_object_find( Hack_list_data[ i ].name )
Hack_list_data[ i ].txt = vint_object_find( "cell_txt", Hack_list_data[ i ].handle )
Hack_list_data[ i ].bg = vint_object_find( "cell_txt_bg", Hack_list_data[ i ].handle )
Hack_list_data[ i ].image = vint_object_find( "cell_image", Hack_list_data[ i ].handle )
end
--reset the amount to the max amount you can have
Hack_list_data[ i ].amount_used = Hack_list_data[ i ].max_amount
end
--update the visual state of the cells in the list
hack_main_editor_refresh_list()
end
function hack_main_editor_refresh_list()
--loop through all the list items
for i = 0, LIST_HEIGHT - 1 do
--grab the amount
local amount_used = Hack_list_data[ i ].amount_used
--if we are not the blank cell then refresh
if amount_used >= 0 then
--set the amount
vint_set_property( Hack_list_data[ i ].txt, "text_tag", Hack_list_data[ i ].amount_used )
--if we have no pieces and we are not blank then turn us off
if amount_used == 0 and Hack_list_data[ i ].type > 0 then
--vint_set_property( Hack_list_data[ i ].image, "tint", 0.5,0.5,0.5)
else
--if we have pieces and we are not blank then turn us on
vint_set_property( Hack_list_data[ i ].image, "tint", 1, 1, 1 )
end
else
--we are the blank cell so we have infinite pieces, don't show the amount ever
vint_set_property( Hack_list_data[ i ].txt, "visible", false)
vint_set_property( Hack_list_data[ i ].bg, "visible", false)
end
end
end
function hack_main_editor_update_amount( prev_idx )
--if the current tile is not blank then change the amount
if Hack_list_data[ List_idx ].type > 0 then
--take one tile away
--Hack_list_data[ List_idx ].amount = Hack_list_data[ List_idx ].amount - 1
Hack_list_data[ List_idx ].amount_used = Hack_list_data[ List_idx ].amount_used + 1
end
--if the previous tile was not blank then subtract one
if Hack_list_data[ prev_idx ].type > 0 then
--Hack_list_data[ prev_idx ].amount = Hack_list_data[ prev_idx ].amount - 1
Hack_list_data[ prev_idx ].amount_used = Hack_list_data[ prev_idx ].amount_used - 1
if Hack_list_data[ prev_idx ].amount_used < 0 then
Hack_list_data[ prev_idx ].amount_used = 0
end
end
hack_main_editor_refresh_list()
end
function hack_main_editor_draw_grid()
local cur_y = 0
local tile_count = 0
--loop through the amount of cells needed
for tile_y = 0, Grid_height - 1 do
for tile_x = 0, Grid_width - 1 do
local bitmap_h = vint_object_create("grid_blank", "bitmap", Grid_h)
--store the handle
Hack_grid_data[ tile_x ][ tile_y ].handle = bitmap_h
debug_print("vint","handle = "..var_to_string(Hack_grid_data[ tile_x ][ tile_y ].handle).."\n\n")
--set the image
hack_main_editor_set_cell_image( tile_x, tile_y )
--position...
local x = tile_x * TILE_WIDTH
local y = cur_y
vint_set_property(bitmap_h, "anchor", x, y)
tile_count = tile_count + 1
end
--Increment y positon...
cur_y = cur_y + TILE_HEIGHT
end
--set the start point
local cell_start_grp = vint_object_find( "cell_start_grp" )
vint_set_property( cell_start_grp, "anchor", -10, ((Hack_start + 1) * TILE_HEIGHT) - (TILE_HEIGHT * 0.5))
--set the end point(s)
local cell_end_grp = vint_object_find( "cell_end_grp" )
vint_set_property( cell_end_grp, "anchor", Grid_width * TILE_WIDTH, ((Hack_end + 1) * TILE_HEIGHT) - (TILE_HEIGHT * 0.5))
--set up the list handles and tile amounts
hack_main_editor_draw_list()
end
function hack_main_editor_reset_grid()
--loop through the grid and reset anything that is not invalid or blank
for y = 0, Grid_height - 1 do
for x = 0, Grid_width - 1 do
local type = Hack_grid_data[ x ][ y ].type
--if we are not invalid or blank then set us to blank
if type >= -1 then
Hack_grid_data[ x ][ y ].type = 0
hack_main_editor_set_cell_image( x, y )
end
--reset all the tints
vint_set_property( Hack_grid_data[ x ][ y ].handle, "tint", 1, 1, 1 )
end
end
Hack_start = 0
Hack_end = 0
Hack_timer = 0
Hack_timer_run = true
thread_kill( Hack_timer_thread )
Hack_timer_thread = thread_new("hack_main_editor_timer_thread")
--set the start point
local cell_start_grp = vint_object_find( "cell_start_grp" )
vint_set_property( cell_start_grp, "anchor", -10, ((Hack_start + 1) * TILE_HEIGHT) - (TILE_HEIGHT * 0.5))
--set the end point(s)
local cell_end_grp = vint_object_find( "cell_end_grp" )
vint_set_property( cell_end_grp, "anchor", Grid_width * TILE_WIDTH, ((Hack_end + 1) * TILE_HEIGHT) - (TILE_HEIGHT * 0.5))
--refresh all our piece amounts in the list and redraw it
hack_main_editor_draw_list()
hack_main_editor_set_list_highlight(0)
end
function hack_main_editor_launch_popup( success )
local popup_grp_h = vint_object_find( "popup_grp" )
local popup_title_h = vint_object_find( "popup_title" )
vint_set_property( popup_grp_h, "visible", true )
if success then
vint_set_property( popup_title_h, "text_tag", "HACK COMPLETE" )
vint_set_property( popup_title_h, "tint", 6/255, 162/255, 170/255 )
else
vint_set_property( popup_title_h, "text_tag", "HACK FAILED" )
vint_set_property( popup_title_h, "tint", 1, 0, 0 )
end
end
function hack_main_editor_print_list()
debug_print("vint","[ X ] = {\n")
debug_print("vint","hack_grid_data = {\n")
for y = 0, Grid_height - 1 do
debug_print("vint","["..y.."] = {\n")
for x = 0, Grid_width - 1 do
if Hack_grid_data[y][x].type < 0 then
debug_print("vint","["..x.."] = {type = "..Hack_grid_data[y][x].type..",},")
else
debug_print("vint","["..x.."] = {type = 0,},")
end
end
debug_print("vint","},\n")
end
debug_print("vint","},\n")
debug_print("vint","hack_list_data = {\n")
for i = 0, LIST_HEIGHT - 2 do
debug_print("vint","["..i.."] = {\n")
debug_print("vint","type = "..Hack_list_data[i].type..",\n")
debug_print("vint","max_amount = "..Hack_list_data[i].amount_used..",\n")
debug_print("vint","name = \""..Hack_list_data[i].name.."\",\n")
debug_print("vint","},\n")
end
debug_print("vint","},\n")
debug_print("vint","hack_start = "..Hack_start..",\n")
debug_print("vint","hack_end = "..Hack_end..",\n")
debug_print("vint","},\n")
end