Skip to content

Commit

Permalink
add_automator() can now rewrite the url again
Browse files Browse the repository at this point in the history
Fixes #321
  • Loading branch information
houeland committed Jun 28, 2015
1 parent 9432c91 commit 99cb996
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 62 deletions.
4 changes: 2 additions & 2 deletions scripts/automation/ascension.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2507,7 +2507,7 @@ endif

add_task {
when = classid() < 10 and
(AT_song_duration() == 0 or not have_item("turtle totem") or not have_item("saucepan") or (can_equip_item("Rock and Roll Legend") and AT_song_duration() < 10)) and
(AT_song_duration() == 0 or not have_item("turtle totem") or not have_item("saucepan")) and
meat() >= 500,
task = tasks.get_starting_items,
}
Expand Down Expand Up @@ -4582,7 +4582,7 @@ endif
}

add_task {
prereq = want_star_key(),
prereq = level() >= 10 and want_star_key(),
f = script.make_star_key,
}

Expand Down
3 changes: 3 additions & 0 deletions scripts/automation/macros.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1632,6 +1632,7 @@ function make_gremlin_macro(name, wrongmsg)
cast Lasagna Bandages
goto do_return
endif
]]
end
local use_magnet = [[use molybdenum magnet]]
Expand All @@ -1647,6 +1648,8 @@ sub stall
]]..stall_action()..[[
mark do_return
endsub
if monstername ]] .. name .. [[
Expand Down
7 changes: 6 additions & 1 deletion scripts/automation/scripts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2924,6 +2924,11 @@ endif
}
else
local remaining = remaining_hidden_city_liana_zones()
if not next(remaining) then
for _, x in ipairs(places) do
remaining[x.zone] = true
end
end
for _, x in ipairs(cached_stuff.completed_lianas or {}) do
remaining[x] = nil
end
Expand Down Expand Up @@ -4351,7 +4356,7 @@ endif
elseif advtitle == "Yeah, You're for Me, Punk Rock Giant" then
return "Check behind the trash can"
elseif advtitle == "Flavor of a Raver" then
return "Check Behind the Poster"
return "Check Behind the Giant Poster"
end
end })
end
Expand Down
47 changes: 0 additions & 47 deletions scripts/automation/tasks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,53 +92,6 @@ function get_automation_tasks(script, cached_stuff)
return result, resulturl
end

if playerclass("Accordion Thief") and AT_song_duration() < 10 then
inform "pick up RnR"
script.ensure_worthless_item()
if not have_item("hermit permit") then
store_buy_item("hermit permit", "m")
end
if not have_item("hot buttered roll") then
async_post_page("/hermit.php", { action = "trade", whichitem = get_itemid("hot buttered roll"), quantity = 1 })
end
if not have_item("hot buttered roll") then
critical "Failed to buy hot buttered roll."
end
if not have_item("casino pass") then
store_buy_item("casino pass", "m")
end
if not have_item("casino pass") then
critical "Failed to buy casino pass."
end
if not have_item("big rock") then
if not have_item("ten-leaf clover") then
uncloset_item("ten-leaf clover")
end
if not have_item("ten-leaf clover") and not have_item("disassembled clover") then
script.trade_for_clover()
end
if not have_item("ten-leaf clover") and have_item("disassembled clover") then
use_item("disassembled clover")
end
if not have_item("ten-leaf clover") then
stop "No ten-leaf clover."
end
script.maybe_ensure_buffs { "Mental A-cue-ity" }
async_get_page("/casino.php", { action = "slot", whichslot = 11 })
if not have_item("big rock") then
critical "Didn't get big rock."
end
end
set_result(smith_items("hot buttered roll", "big rock"))
script.unequip_if_worn("stolen accordion")
set_result(smith_items("heart of rock and roll", "stolen accordion"))
if not have_item("Rock and Roll Legend") then
critical "Couldn't smith RnR"
end
did_action = have_item("Rock and Roll Legend")
return result, resulturl, did_action
end

if not playerclass("Accordion Thief") and AT_song_duration() < 5 then
inform "buy toy accordion"
set_result(store_buy_item("toy accordion", "z"))
Expand Down
11 changes: 3 additions & 8 deletions scripts/kolproxy-internal/automate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,12 @@ if not can_read_state() then
end

log_time_interval("automate:initialize", function()
which = path
if (requestpath == "/login.php" and text == "kolproxy login redirect") or (requestpath == "/afterlife.php" and path == "/main.php" and text == "kolproxy afterlife ascension") then
which = "player login"
end

automate_url = intercept_url
setup_variables()
end)

log_time_interval("run automators", function()
if which ~= "/loggedout.php" then
local automate_url = path
if path ~= "/loggedout.php" then
text = run_functions(path, text, function(target, pt)
for _, x in ipairs(automators[target] or {}) do
getfenv(x.f).text = pt
Expand All @@ -38,7 +33,7 @@ if which ~= "/loggedout.php" then
end
end)

return text
return text, automate_url

end

Expand Down
12 changes: 9 additions & 3 deletions scripts/kolproxy-internal/browser-request.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,25 @@ local function run_wrapped_function_internal(f_env)
local intercept_path, intercept_query = kolproxycore_splituri(intercept_url)

f_env.text = intercept_pt
f_env.intercept_url = intercept_url
f_env.path = intercept_path
f_env.query = intercept_query
f_env.effuri_params = kolproxycore_decode_uri_query(intercept_url) or {}

local automate_pt = automate_wrapped(f_env)
local automate_pt, automate_url = automate_wrapped(f_env)

descit("automate", automate_pt, intercept_url)
descit("automate", automate_pt, automate_url)

local automate_path, automate_query = kolproxycore_splituri(automate_url)

f_env.text = automate_pt
f_env.automate_url = automate_url
f_env.path = automate_path
f_env.query = automate_query

local printer_pt = printer_wrapped(f_env)

descit("printer", printer_pt, intercept_url)
descit("printer", printer_pt, automate_url)

return printer_pt, intercept_url
end
Expand Down
2 changes: 1 addition & 1 deletion scripts/paths/standard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ function get_unavailable_items()
end

function item_is_unavailable(item)
return get_unavailable_items()[get_itemname(item)]
return get_unavailable_items()[get_itemname(item)] ~= nil
end

0 comments on commit 99cb996

Please sign in to comment.