Log in

View Full Version : call a variable that is stored on a .lua file



icaro43
03-03-2013, 08:40 AM
Ok, i have a script made of one-liners. And in the bank action i do have the following script:



Self.SayToNpc({'hi', 'ticket', 'yes', 'deposit all', 'yes'}, 65) wait(1700) Self.SayToNpc({'withdraw'.. ((BuyHP-Self.ItemCount(itemHP))*prieceHP)+((BuyMP-Self.ItemCount(itemMP))*prieceMP)}) wait(500) Self.SayToNpc({'yes'}, 65)


basically variables like itemHP, itemMP, buyHP... are stored on a .lua file called kazzsetup.lua
when the script runs i got an error


05:35 XenoScript Error:
Script: [One-Liner executed by XenoBot Walker]
Line #: 1
Chunk: [string ?Self.SayToNpc({'hi', 'ticket', 'yes', 'depo..."]
Error: attempt to perform arithmetic on global 'BuyHP' (a nil value)
This is an error with user-input and should not be reported as a bug with XenoBot.


already tried to put dofile('kazzsetup.lua') and dofile("kazzsetup.lua") in the oneliner and it still dont work:


05:34 XenoScript Error:
Script: [One-Liner executed by XenoBot Walker]
Line #: 1
Chunk: [string ?dofile??kazzsetup.lua") Self.SayToNpc({'hi'..."]
Error: attempt to perform arithmetic on global 'BuyMP' (a nil value)
This is an error with user-input and should not be reported as a bug with XenoBot.

how do i make to import variables from a .lua file to use on the one liners?



btw how to wrap .lua code on the forum already tried [code=lua] and fail :/

Bushu
03-03-2013, 08:47 AM
one does not simply
wrap the lua code on forums

icaro43
03-03-2013, 08:50 AM
tell me :( or it is just for cool guys? thats gay.

Bushu
03-03-2013, 09:14 AM
To wrap code use [xcode=lua].

And instead of making a thing like this:
((BuyHP-Self.ItemCount(itemHP))*prieceHP)+((BuyMP-Self.ItemCount(itemMP))*prieceMP)

Try to swap variables with numbers, like change BuyHP for 100(or whatever you want), prieceHP for 45/100/190(depending what health potions you want to use), etc etc.
Dofile won't work in one liners.

icaro43
03-03-2013, 09:29 AM
Bushu yes, i know this works but i want to make on a way that i could release the script on forum with the .lua containing only the setup, so people wouldnt mess on stuff and it would be easier to fit whatver anyone think it could be better

Bushu
03-03-2013, 09:32 AM
Then why can't you just do the full .lua file instead of playing with it if you're going to release both .lua and .xbst file?
That's just my opinion, but I think it would be no sense of doing it your way :P

icaro43
03-03-2013, 09:42 AM
yes i just read that it was possible to do one liners with some functions, so i was just trying to figure out how to make them... well if anyone knows tell me please :P
also i don't like the label system u.u

Bushu
03-03-2013, 09:45 AM
label system <3
you can't do it your way I told you ;P
you have to set up the amount in script yourself

icaro43
03-03-2013, 09:50 AM
ahh fuck this ok ty for the info rep+

icaro43
03-03-2013, 09:53 AM
how come i could dofile('forgee.lua') to use the function reachdepot() and i cant dofile('kazzsetup.lua') to load my variables :( ?

icaro43
03-03-2013, 12:39 PM
yes, just tried both ways.. even calling a variable GLOBAL

icaro43
03-03-2013, 12:42 PM
yes i have no idea what is going on over here

icaro43
03-03-2013, 12:42 PM
i'm using windows 7 and runing bot as admin right now:


my .lua file:

leaveHP = 10 -- set how much healths to leave
BuyHP = 40 -- set how much healths to buy
prieceHP = 100 -- set the priece of the potion [45 normal, 100 strong, 190 great, 310 ultimate]
itemHP = 236 -- set the item ID of the potion [266 to normal, 236 to strong]
--Mana potions
leaveMP = 20 -- set how much manas to leave
BuyMP = 100 -- set how much manas to buy
prieceMP = 50 -- set the priece of the potion [50 normal, 80 strong]
itemMP = 268 -- set the item ID of the potion [238 to normal]
--General
LeaveCap = 20 -- set the cap to leave the cave

also i have these one liners for the instance:

Self.SayToNpc({'hi', 'ticket', 'yes', 'deposit all', 'yes'}, 65) wait(1700) Self.SayToNpc({'withdraw'.. ((BuyHP-Self.ItemCount(itemHP))*prieceHP)+((BuyMP-Self.ItemCount(itemMP))*prieceMP)}) wait(500) Self.SayToNpc({'yes'}, 65)

Walker.Stop() Creature.Follow('Sigurd') wait(4000) Self.SayToNpc({'hi', 'vials', 'yes', 'trade'}, 65) wait(2000) Self.ShopBuyItemsUpTo(itemMP, buyMP) wait(1600) Self.ShopBuyItemsUpTo(itemHP, buyHP) wait(1600) Walker.Start()
]
dofile('forgee.lua') Self.ReachDepot() wait(500) Self.DepositItems(9689,8031,10275,9692,5894,11485, 5880)



btw everytime i load the kazzsetings.lua it auto closes itself. its happening to every file i make. but if i copy the settings with the same text from a file made from other it work. i'm using sublime.

icaro43
03-03-2013, 01:05 PM
i'm gettin really mad a this lol been working on this like 3 hours before the ss

icaro43
03-03-2013, 01:22 PM
yes i did it, sorry i just sent you the older scripts, but even with the dofile in the front it wasn't working :/

icaro43
03-03-2013, 01:25 PM
i will try to reinstall the bot because i switched to "label way" to make things happen and this is what i have
this is not working to me. when i load the script it closes automatic and i don't get any bug error.


-- Buy Potions?
local BuyPots = true -- Set to false if you don't want to buy potions.
-- Potion Config
local MinPotion = 5 -- Potions to deposit on.
local MaxPotion = 30 -- Amount of Potions to buy.
local PotionID = 266 -- ID of Potions.
local PotionPrice = 45 -- How much Potions cost.
--General
local MinCap = 20 -- Cap to deposit.

-----------
dofile('forgee.lua')


function onWalkerSelectLabel(labelName)
if (labelName == "Bank") then
Self.SayToNpc({"hi", "ticket", "yes", "deposit all", "yes"}, 65)
wait(1700)
Self.SayToNpc({"withdraw".. ((BuyHP-Self.ItemCount(itemHP))*prieceHP)+((BuyMP-Self.ItemCount(itemMP))*prieceMP)}) wait(500) Self.SayToNpc({'yes'}, 65)
elseif (labelName == "depot") then
Self.ReachDepot()
wait(500)
Self.DepositItems(9689,8031,10275,9692,5894,11485, 5880)
elseif (labelname == "BuyPots") then
Walker.Stop()
Creature.Follow("Sigurd")
wait(4000) Self.SayToNpc({"hi", "vials", "yes", "trade"}, 65)
wait(2000) Self.ShopBuyItemsUpTo(itemMP, buyMP)
wait(1600) Self.ShopBuyItemsUpTo(itemHP, buyHP)
wait(1600) Walker.Start()
end
end

SamDaMan
03-03-2013, 01:35 PM
Where is "BuyHp" declared? Is it a built in function?
Is it really supposed to be "priece" or instead price?
It seems as if you need to add registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel") after the original dofile.

icaro43
03-03-2013, 01:41 PM
Where is "BuyHp" declared? Is it a built in function?
Is it really supposed to be "priece" or instead price?
It seems as if you need to add registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel") after the original dofile.

a) yes as i said it was the older script i have the new with the typos fixed and with dofile() before every cavebot action
b) yea that might work i will test this out

icaro43
03-03-2013, 01:56 PM
so the
registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")
kept the .lua file open. and working on LABEL MODE.

if i want to work on one-liner script mode how do i make to keep this open? \/


-- Buy Potions?
BuyPots = true -- Set to false if you don't want to buy potions.
-- Potion Config
MinPotion = 5 -- Potions to deposit on.
MaxPotion = 30 -- Amount of Potions to buy.
PotionID = 266 -- ID of Potions.
PotionPrice = 45 -- How much Potions cost.
--General
MinCap = 20 -- Cap to deposit.