Log in

View Full Version : Knight [Refiller] How to create



Beo
02-01-2013, 10:13 AM
This is going to be a real quick tutorial on how to create a refiller.

First you'll need the LUA code.



-------------------------------------------------
----------------Y2Quake--------------------
--------------TARANTULAS PH------------------
-----------------KNIGHT-----------------------
-------------------------------------------------
--Settings---------------------------------------
MPotID = 268 --- mana potion ID
MinMPots = 1 ---- if less then script will exit spawn
MPots = 5 ----- amount to refill
MPotprice = 50 ---- price of 1 single mana pot
HPotID = 266 ---- health potion ID
HPotprice = 45 ---- health potion price
HPots = 150 ---- health potions you want to buy
MinHPots = 30 ---- min of health potions to leave
MinCap = 50 ---- if less then script will exit spawn
-------------------------------------------------
--END OF SETTINGS--------------------------------



--- DO NOT CHANGE BELOW UNLESS YOU KNOW WHAT YOU'RE DOING ---

registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")

local info = [[
Free script made by:
Y2Quake]]
function NpcConv(...)
for _, str in ipairs(arg) do
wait((tostring(str):len() / 125) * 60000 * math.random(1.1, 1.8))
Self.SayToNpc(str)
end
end
dofile("Forgee.lua")
function onWalkerSelectLabel(labelName)
if (labelName == "check") then
delayWalker(1000)
setWalkerEnabled(false)
if (Self.ItemCount(MPotID) <= MinMPots) or (Self.Cap() < MinCap) or (Self.ItemCount(HPotID) <= MinHPots) then
setWalkerEnabled(true)
gotoLabel("refill")
else
setWalkerEnabled(true)
gotoLabel("KeepHunting")
end
elseif (labelName == "KeepHunting") then
print(info)
elseif (labelName == "bank") then
setWalkerEnabled(false)
NpcConv("hi","deposit all","yes","balance")
wait(900, 1200)
Self.WithdrawMoney((MPotprice*(MPots-Self.ItemCount(MPotID))))
wait(900, 1200)
Self.SayToNpc("yes")
wait(900, 1200)
Self.WithdrawMoney((HPotprice*(HPots-Self.ItemCount(HPotID))))
wait(900, 1200)
Self.SayToNpc("yes")
wait(900, 1200)
Self.SayToNpc("withdraw 15")
wait(900, 1200)
Self.SayToNpc("yes")
wait(15000,19000)
setWalkerEnabled(true)
elseif (labelName == "deposit") then
setWalkerEnabled(false)
Self.DepositItems(10281, {3053, 1}, {5902, 1}, {3351, 1})
wait(1500,1900)
setWalkerEnabled(true)
elseif (labelName == "tradepots") then
setWalkerEnabled(false)
wait(900, 1200)
Self.SayToNpc({"Hi", "flasks", "yes", "yes", "yes", "Trade"}, 65)
sleep(math.random(2000, 2400))
buyAlotOfItemsBecauseItsSuchAGodDamnBigDeal(MPotID , (MPots-Self.ItemCount(MPotID)))
sleep(math.random(2000, 2400))
buyAlotOfItemsBecauseItsSuchAGodDamnBigDeal(HPotID , (HPots-Self.ItemCount(HPotID)))
sleep(math.random(2000, 2400))
setWalkerEnabled(true)
elseif (labelName == "resetbps") then
dofile("Forgee.lua")
delayWalker(15000)
resetBackpacks()
end
end

function buyAlotOfItemsBecauseItsSuchAGodDamnBigDeal(item, count)
count = tonumber(count) or 1
repeat
local amnt = math.min(count, 100)
if(Self.ShopBuyItem(item, amnt) == 0)then
return printf("ERROR: failed to buy item: %s", tostring(item))
end
wait(200,500)
count = (count - amnt)
until count <= 0
end



Here is one I have found by Y2Quake for Tarantulas. I have edited it a bit to remove some labels we won't use in this tutorial.

You can edit the top part, no problem. That is the settings.
Now copy and paste this into your Scripts folder located in "Documents".

Rename it to the waypoints you are going to make, for better organization.

E.G.
You want to make Thais Trolls with depositor. You rename this to ThaisTrolls-DepositandRefill.lua




Now we're going to make the waypoints and refiller.

You're going to start at the entrance of the spawn and make a label called "check".

You're now going to make at the exact same spot called "KeepHunting".

Make the waypoints around the cave using Node, until you're back at where you made the "check" label.

You will now make a label called "refill".

Make waypoints to the bank, when you are standing next to the banker make a "stand". Then create a label called "bank".

Then make waypoints to the depot and make a label called "deposit".

Time to buy some life. Make waypoints to the potion shop. Make a "stand" and make a label called "trade pots".

Now make a few nodes around the shop or go to PZ and make a label called "resetbps".

Now make waypoints back to the label "checker".

Save your settings by right clicking yourself, settings, new profile, save.

Now, edit your LUA settings and you are ready to start banking that cash.


NOTES

-- You will need to ensure the label names are exactly the same as the ones above. Otherwise it will not work.
-- You will need Forgee.Lua which a simple search can find.


Please report and problems and I will try to solve them for you :cool:

Spectrus
02-01-2013, 11:58 AM
This is not a good tutorial. You should seek a firmer understanding of Lua before trying to teach others.

xiaospike
02-01-2013, 12:06 PM
Redundant/Obselete:


function NpcConv(...)
for _, str in ipairs(arg) do
wait((tostring(str):len() / 125) * 60000 * math.random(1.1, 1.8))
Self.SayToNpc(str)
end
end


function buyAlotOfItemsBecauseItsSuchAGodDamnBigDeal(item, count)
count = tonumber(count) or 1
repeat
local amnt = math.min(count, 100)
if(Self.ShopBuyItem(item, amnt) == 0)then
return printf("ERROR: failed to buy item: %s", tostring(item))
end
wait(200,500)
count = (count - amnt)
until count <= 0
end


elseif (labelName == "resetbps") then
dofile("Forgee.lua")
delayWalker(15000)
resetBackpacks()

Infernal Bolt
02-01-2013, 12:09 PM
No need for forgee.lua
No need for the outdated functions (NpcConv/buyAlotOfItemsBecauseItsSuchAGodDamnBigDeal)
No need to delay walker when you are stopping the walker.



--Settings---------------------------------------
local MPotName = "mana potion" --- mana potion name
local MinMPots = 1 ---- if less then script will exit spawn
local MPots = 5 ----- amount to refill
local MPotprice = 50 ---- price of 1 single mana pot
local HPotName = "health potion" ---- health potion name
local HPotprice = 45 ---- health potion price
local HPots = 150 ---- health potions you want to buy
local MinHPots = 30 ---- min of health potions to leave
local MinCap = 50 ---- if less then script will exit spawn
local GoldBP = "brocade backpack" ---- backpack to put gold in
local LootBP = "red backpack" ---- backpack to put loot in
local MinimizeBP = true ---- change to false to not minimize backpacks
--- DO NOT CHANGE BELOW UNLESS YOU KNOW WHAT YOU'RE DOING ---
registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")
function onWalkerSelectLabel(labelName)
if (labelName == "check") then
if (Self.ItemCount(MPotName) <= MinMPots) or (Self.Cap() < MinCap) or (Self.ItemCount(HPotName) <= MinHPots) then
gotoLabel("refill")
else
gotoLabel("KeepHunting")
end
elseif (labelName == "bank") then
Walker.Stop()
Self.DepositMoney('all')
Self.WithdrawMoney((MPotprice*(MPots-Self.ItemCount(MPotName))))
Self.WithdrawMoney((HPotprice*(HPots-Self.ItemCount(HPotName))))
Self.WithdrawMoney(15)
Walker.Start()
elseif (labelName == "deposit") then
Self.DepositItems(10281, {3053, 1}, {5902, 1}, {3351, 1})
elseif (labelName == "tradepots") then
Walker.Stop()
Self.SayToNpc({"Hi", "flasks", "yes", "yes", "yes", "Trade"}, 65)
wait(2000, 2400)
Self.ShopBuyItemsUpTo(MPotName, MPots)
Self.ShopBuyItemsUpTo(HPotName, HPots)
Walker.Start()
elseif (labelName == "resetbps") then
Walker.Stop()
Self.CloseContainers()
wait(900,1000)
Self.OpenMainBackpack(MinimizeBP):OpenChildren({Go ldBP,MinimizeBP}, {LootBP,MinimizeBP})
Walker.Start()
end
end

Avani
02-01-2013, 12:25 PM
I think we need to put "buyAlotOfItemsBecauseItsSuchAGodDamnBigDeal" in the Xenobot museum

Y2Quake
02-01-2013, 03:53 PM
Beo

I released these kind of luas some 3 months ago +-
They're pointless and very buggy now, i'd use infernal bolts script if you want a good base now

Beo
02-01-2013, 08:18 PM
Thanks for the tips, will update Sunday.

Spectrus
This was just a quick base tutorial to help a few people create their first refiller.

Since I get asked a lot by friends this is how I do it. I don't use this script myself but I'm away from my pc atm which has mine on there. Ill add it Sunday anyhow and I have a good knowledge of lua, just not xeno functions.


Sorry for trying ;)

Luchex
02-02-2013, 10:46 PM
uuuuup

XtrmJosh
02-03-2013, 08:39 PM
Thanks for the tips, will update Sunday.

Spectrus
This was just a quick base tutorial to help a few people create their first refiller.

Since I get asked a lot by friends this is how I do it. I don't use this script myself but I'm away from my pc atm which has mine on there. Ill add it Sunday anyhow and I have a good knowledge of lua, just not xeno functions.


Sorry for trying ;)

The problem is that all scripts at the minute work using old functions, and because there is no real function list, it's too difficult to know what function is relevant for what you want to do. It's better if people learn the new way now, and stop using these redundant features so they get retired and hopefully the scripts that do exist will deplete as a sustainable quantity surfaces.

killerfanges
02-04-2013, 06:31 PM
so does this work?