Skip to content

Commit

Permalink
mostly bug-free
Browse files Browse the repository at this point in the history
  • Loading branch information
coveleski committed Jun 20, 2024
1 parent f2ca50c commit 0ba8bac
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 16 deletions.
9 changes: 7 additions & 2 deletions scripts/autotracking/archipelago.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ CUR_INDEX = -1
SLOT_DATA = nil
LOCAL_ITEMS = {}
GLOBAL_ITEMS = {}
TRAINERSANITY_LOCATIONS = {}
-- TRAINERSANITY_LOCATIONS = {}

function onClear(slot_data)

Expand Down Expand Up @@ -74,12 +74,17 @@ function onClear(slot_data)
end
LOCAL_ITEMS = {}
GLOBAL_ITEMS = {}
TRAINERSANITY_LOCATIONS = {}
IS_CONNECTED = TRUE
get_slot_options(slot_data)
local ap_locations = get_ap_locations()
dexsanity_init(ap_locations)
if Tracker:FindObjectForCode('trainer_on') then
trainersanity_init(ap_locations)
end
-- we run this after trainersanity for /reasons/
--because visiblity rules don't update until an item code changes
-- so we might as well update these ones after
dexsanity_init(ap_locations)
end

-- called when an item gets collected
Expand Down
31 changes: 18 additions & 13 deletions scripts/autotracking/slot_options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -282,16 +282,21 @@ function dexsanity_init(locations)
end
end

function trainersanity_init(locations)
-- trainersanity checks have ids in the range 172000215-172000531
local start_index = 172000215
local end_index = 172000531
for i = start_index, end_index do
local location_exists = locations[index]
if location_exists then
TRAINERSANITY_LOCATIONS[i] = true
else
TRAINERSANITY_LOCATIONS[i] = false
end
end
end
-- function trainersanity_init(locations)
-- -- trainersanity checks have ids in the range 172000215-172000531
-- local start_index = 172000215
-- local end_index = 172000531
-- print(dump_table(locations, 1))
-- for i = start_index, end_index do
-- print(i .. ': ' .. tostring(locations[i]))
-- local location_exists = locations[i]
-- -- print(location_exists)
-- if location_exists then
-- TRAINERSANITY_LOCATIONS[i] = true
-- print("Trainersanity Location enabled: " .. i .. "#############################################")
-- else
-- TRAINERSANITY_LOCATIONS[i] = false
-- -- print("Trainersanity Location disabled: " .. i)
-- end
-- end
-- end
6 changes: 6 additions & 0 deletions scripts/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ local variant = Tracker.ActiveVariantUID
-- check variant info
IS_ITEMS_ONLY = variant:find("itemsonly")

function debug()
trainer_visible(172000458)
end

function split_key()
local obj = Tracker:FindObjectForCode('opt_cardkey_split')
key = Tracker:FindObjectForCode('custom_cardkey')
Expand Down Expand Up @@ -58,6 +62,8 @@ if PopVersion and PopVersion >= "0.1.0" then
--add watches to hide items from the itemgrid if they're not enabled
ScriptHost:AddWatchForCode("toggle_extra_key_items", "opt_extra_key_items", toggle_extra_key_items)
ScriptHost:AddWatchForCode("toggle_tea", "opt_tea", toggle_tea)
ScriptHost:AddWatchForCode("debug", "coincase", debug)

end
--load cardkey customitem
ScriptHost:LoadScript('scripts/custom_items/cardkey.lua')
28 changes: 27 additions & 1 deletion scripts/logic/logic.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,33 @@
saffron_access = AccessibilityLevel.None
TRAINERSANITY_LOCATIONS = {}
TABLE_DUMP = TRUE

function trainer_visible(id)
return TRAINERSANITY_LOCATIONS[id]
local obj = Tracker:FindObjectForCode('opt_trn')
if (obj.CurrentStage == 0) then
return false
end
-- playernumber doesn't matter, just checking if we're connected
if Archipelago.PlayerNumber < 1 then
return true
end

local key = tonumber(id)
local x = TRAINERSANITY_LOCATIONS[key]
return TRAINERSANITY_LOCATIONS[key]
end

function trainersanity_init(locations)
TRAINERSANITY_LOCATIONS = {}
-- trainersanity checks have ids in the range 172000215-172000531
local start_index = 172000215
local end_index = 172000531
for i = start_index, end_index do
local location_exists = locations[i]
TRAINERSANITY_LOCATIONS[i] = location_exists
end
end

-- ITEM COUNT CHECKS

-- returns int of # of badges
Expand Down

0 comments on commit 0ba8bac

Please sign in to comment.