11-- Main file for mod runtime
2+ local Logger = require (" scripts.logger" )
3+ Logger .init ()
4+
25local util = require (" util" )
36local fa_utils = require (" scripts.fa-utils" )
47local fa_info = require (" scripts.fa-info" )
@@ -2045,6 +2048,8 @@ function turn_to_cursor_direction_cardinal(pindex)
20452048 -- p.character.direction = dir
20462049 pex .player_direction = dir
20472050 end
2051+ -- game.print("set cardinal pindex_dir: " .. direction_lookup(pex.player_direction))--
2052+ -- game.print("set cardinal charct_dir: " .. direction_lookup(p.character.direction))--
20482053end
20492054
20502055-- Makes the character face the cursor, choosing the nearest of 8 directions. Can be overwriten by vanilla move keys.
@@ -2055,6 +2060,8 @@ function turn_to_cursor_direction_precise(pindex)
20552060 local vp = Viewpoint .get_viewpoint (pindex )
20562061 local dir = fa_utils .get_direction_precise (vp :get_cursor_pos (), p .position )
20572062 pex .player_direction = dir
2063+ -- game.print("set precise pindex_dir: " .. direction_lookup(pex.player_direction))--
2064+ -- game.print("set precise charct_dir: " .. direction_lookup(p.character.direction))--
20582065end
20592066
20602067-- Called when a player enters or exits a vehicle
@@ -2190,6 +2197,7 @@ function swap_weapon_forward(pindex, write_to_character)
21902197 -- Simple index increment (not needed)
21912198 gun_index = gun_index + 1
21922199 if gun_index > 3 then gun_index = 1 end
2200+ -- game.print("start " .. gun_index)--
21932201 assert (ammo_inv )
21942202
21952203 -- Increment again if the new index has no guns or no ammo
@@ -2214,9 +2222,13 @@ function swap_weapon_forward(pindex, write_to_character)
22142222 tries = tries + 1
22152223 end
22162224
2217- if tries > 3 then return - 1 end
2225+ if tries > 3 then
2226+ -- game.print("error " .. gun_index)--
2227+ return - 1
2228+ end
22182229
22192230 if write_to_character then p .character .selected_gun_index = gun_index end
2231+ -- game.print("end " .. gun_index)--
22202232 return gun_index
22212233end
22222234
@@ -2466,6 +2478,7 @@ function do_multi_stack_transfer(ratio, pindex)
24662478 end
24672479 end
24682480 printout (result , pindex )
2481+ -- game.print(players[pindex].building.sector_name or "(nil)")--**
24692482end
24702483
24712484--[[ Transfers multiple stacks of a specific item (or all items) to/from the player inventory from/to a building inventory.
@@ -2503,6 +2516,7 @@ function transfer_inventory(args)
25032516 end
25042517 end
25052518 end
2519+ -- game.print("run 1x: " .. args.name)--**
25062520 return results , full
25072521end
25082522
@@ -2612,21 +2626,22 @@ function ensure_storage_structures_are_up_to_date()
26122626 storage .scheduled_events = storage .scheduled_events or {}
26132627end
26142628
2615- script .on_load (function ()
2629+ EventManager .on_load (function ()
26162630 players = storage .players
26172631 entity_types = storage .entity_types
26182632 production_types = storage .production_types
26192633 building_types = storage .building_types
26202634end )
26212635
2622- script .on_configuration_changed (ensure_storage_structures_are_up_to_date )
2636+ EventManager .on_configuration_changed (ensure_storage_structures_are_up_to_date )
26232637
2624- script .on_init (function ()
2638+ EventManager .on_init (function ()
26252639 --- @type any
26262640 local skip_intro_message = remote .interfaces [" freeplay" ]
26272641 skip_intro_message = skip_intro_message and skip_intro_message [" set_skip_intro" ]
26282642 if skip_intro_message then remote .call (" freeplay" , " set_skip_intro" , true ) end
26292643 ensure_storage_structures_are_up_to_date ()
2644+ TestFramework .on_init ()
26302645end )
26312646
26322647script .on_event (defines .events .on_cutscene_cancelled , function (event )
@@ -3055,6 +3070,7 @@ script.on_event(defines.events.on_gui_opened, function(event)
30553070 then
30563071 -- If closing another menu toggles the player GUI screen, we close this screen
30573072 p .opened = nil
3073+ -- game.print("Closed an extra controller GUI",{volume_modifier = 0})--**checks GUI shenanigans
30583074 end
30593075end )
30603076
@@ -3227,7 +3243,10 @@ script.on_event(defines.events.on_entity_damaged, function(event)
32273243 and armor_inv [1 ].grid .valid
32283244 then
32293245 local grid = armor_inv [1 ].grid
3230- if grid .shield > 0 then shield_left = grid .shield end
3246+ if grid .shield > 0 then
3247+ shield_left = grid .shield
3248+ -- game.print(armor_inv[1].grid.shield,{volume_modifier=0})
3249+ end
32313250 end
32323251 -- Play shield and/or character damaged sound
32333252 if shield_left ~= nil then ent .player .play_sound ({ path = " player-damaged-shield" , volume_modifier = 0.8 }) end
@@ -3468,6 +3487,8 @@ function check_and_play_bump_alert_sound(pindex, this_tick)
34683487 -- Return if was not going straight earlier (like was running diagonally, as confirmed by last positions)
34693488 if not was_going_straight then return end
34703489
3490+ -- game.print("checking bump",{volume_modifier=0})--
3491+
34713492 -- Check if latest movement has been straight
34723493 local is_going_straight = false
34733494 if face_dir == dirs .north or face_dir == dirs .south then
@@ -3523,6 +3544,7 @@ function check_and_play_bump_alert_sound(pindex, this_tick)
35233544 else
35243545 p .play_sound ({ path = " player-bump-trip" })
35253546 end
3547+ -- game.print("bump: ent:" .. ent.name,{volume_modifier=0})--
35263548 return
35273549 end
35283550
@@ -3531,6 +3553,7 @@ function check_and_play_bump_alert_sound(pindex, this_tick)
35313553 bump_was_cliff = (# ents > 0 )
35323554 if bump_was_cliff then
35333555 p .play_sound ({ path = " player-bump-slide" })
3556+ -- game.print("bump: cliff",{volume_modifier=0})--
35343557 return
35353558 end
35363559
@@ -3542,11 +3565,13 @@ function check_and_play_bump_alert_sound(pindex, this_tick)
35423565
35433566 if bump_was_tile then
35443567 p .play_sound ({ path = " player-bump-slide" })
3568+ -- game.print("bump: tile:" .. tile.name,{volume_modifier=0})--
35453569 return
35463570 end
35473571
35483572 -- The bump was something else, probably missed it...
35493573 -- p.play_sound{path = "player-bump-slide"}
3574+ -- game.print("bump: unknown, at " .. p.position.x .. "," .. p.position.y ,{volume_modifier=0})--
35503575 return
35513576end
35523577
@@ -5771,6 +5796,7 @@ local function kb_switch_menu_or_gun(event)
57715796 else
57725797 local ammo_stack = ammo_inv [gun_index ]
57735798 local gun_stack = guns_inv [gun_index ]
5799+ -- game.print("print " .. gun_index)--
57745800 result = gun_stack .name .. " with " .. ammo_stack .count .. " " .. ammo_stack .name .. " s "
57755801 end
57765802
@@ -5906,6 +5932,7 @@ local function kb_reverse_switch_menu_or_gun(event)
59065932 else
59075933 local ammo_stack = ammo_inv [gun_index ]
59085934 local gun_stack = guns_inv [gun_index ]
5935+ -- game.print("print " .. gun_index)--
59095936 result = gun_stack .name .. " with " .. ammo_stack .count .. " " .. ammo_stack .name .. " s "
59105937 end
59115938
0 commit comments