Page 2 of 4

Re: useGoodie

Posted: Sun May 29, 2011 1:02 am
by harbifm
is there an old version, may 6-7 months old.

I would like to give it a try

Re: useGoodie

Posted: Sun May 29, 2011 4:01 am
by Giram
harbifm wrote:did not work

where should I save the file (userfunction_useGoodie_universal .lua)?
Default folder for userfunctions is micromacro\scripts\rom\userfunctions . But since you need to use older version of rombot the rombot might not be able to use these files. I think it was addons folder at first.
harbifm wrote:
I have put into the script ffolder, not the profile folder. shouldl I rename the lua file to (usergoodie) for the bot to recongnize it since it is named that in the code, not userfunction_useGoodie_universal.lua, or the other way around

what I meen is changeing the name as an example (useGoodie ("speed"); to (userfunction_useGoodie_universal "speed"); in the profile code?

and again where to save it for the bot to recongnize it?
You can't use different name for function in code. That is always useGoodie("item_name or ID"); . As for file name there should be userfunction or addon in front of the name. Otherwise bot won't recognice these files.
harbifm wrote:is there an old version, may 6-7 months old.

I would like to give it a try
If you have english client then you can try http://www.solarstrike.net/phpBB3/viewt ... =27&t=2051 . That is oldest i can give now. In code there is english buff names so if your clients language is not english then it won't work.

Re: useGoodie

Posted: Mon May 30, 2011 1:26 pm
by harbifm
the proplem that I have is that the rom folder does have either addons or userfunctions folders,

I create them manualy,still the bot did not recongnize them but still , it did not work.

i update to newer version (545), which has the userfucntions folder, but then rombot did not work,,my version is 468

is there a solution

Re: useGoodie

Posted: Mon May 30, 2011 1:57 pm
by Giram
I don't know the version that introducted addons or userfunctions. So it might be that you have too old version of rombot for userfunctions. Creating folders won't work cause rombot won't have code to find those folders and use files in them.

Because you play with older version or runes of magic and are forced to use older version you might not be able to use these files directly. I don't know what functions you are able to use but you can still use code in profile or waypoints.

You could try something like this:

Code: Select all

if not player:hasBuff("write_buff_name_here") then
      inventory:useItem("write_item_name_here")
end
To get buff name use item you want that gives you buff. Check that name and enter it exactly as you see it in hasBuff() function. Then in useItem() function write item you wan't to use. That can also accept item ID but then you can't use semicolons i think. It might work or then it won't work. I am also using much newer version of runes of magic and this is done for newest version. I can only give hints how you can do this but can't be sure if it will work. Depends of the functions your rombot has at the moment. Hope you can get something to work.

You can place that code in your profile between onLeavecombat, onPreSkillCast, onSkillCast or in waypoint file. Profile settings also depends from your rombot version. I don't know at wich versions those are implemented in rombot.

Re: useGoodie

Posted: Mon May 30, 2011 8:45 pm
by rock5
Please note that in older versions, player:hasBuff didn't use the memory, it used RoMScript commands. So you might find it slows things down too much if used in certain places.

Re: useGoodie

Posted: Tue May 31, 2011 4:13 am
by harbifm
so the code should read like this:

<onLeaveCombat>
if not player:hasBuff("luck") then
inventory:useItem("XXX")
end

if not player:hasBuff("1200 elemental damage") then
inventory:useItem("XXX")
end



</onLeaveCombat>
<onLevelup><![CDATA[
-- Additional Lua code to execute after having a levelup
-- and levelup the skills for a new character (mage or priest recommended)
-- e.g. sendMacro("SetSpellPoint(_tabnr, _skillnr);"); would levelup a skill
]]></onLevelup>


where luck and 1200 elemental damage are the effect/buff name, and XXX are the items name. should not that be a number for each item?

Re: useGoodie

Posted: Wed Jun 01, 2011 12:27 am
by harbifm
by the way, why not copy the whole code into (userfuction.lua) and doing the same thing?

will that work?

Re: useGoodie

Posted: Wed Jun 01, 2011 1:04 am
by lisa
because userfunction.lua has the core functions for the bot to run. The userfunctions folder was implemented so people can make their own functions without edited the core files of the bot. each time the bot is updated people would need to redo their code again and again. With the usage of the userfunctions folder there is no need for that.

Re: useGoodie

Posted: Wed Jun 01, 2011 2:52 am
by harbifm
the problem with my version is that there is no userfucntions or addon folder

why not add the code to the user fucntion at the end, and call it in my profie. (for my case)

I can back-up the userfuction folder if need later for updating my rombot

they way that I am going to do it is to cut and past all the content of usergoodie and catch cavi to the userfuntion.lua at the end of every thing, so it does interept any thing, and try to put actions after onLeaveCompat for it to catch golden cavi, use luck potion and Swamp delcious salad every time a compat finish.

I only need these items

Re: useGoodie

Posted: Wed Jun 01, 2011 4:26 am
by rock5
I would probably just create a file, let's call it "MyFunctions.lua", and put all my functions in there. Then just add the one line to functions.lua,

Code: Select all

include("MyFunctions.lua")
Or maybe you could avoid editing functions.lua and put that command in your profile <onload> instead.

Re: useGoodie

Posted: Wed Jun 01, 2011 6:32 am
by harbifm
as I understood it

function.lua contain a list of fucntions.

if i add any thing there, as long as added and do not scrow the sequence in the middle, and that it is already have been set in the system (profile) ,or what ever sitting there are, to use funtions.lua for any comand (or look into it there)

like if a called on somthing listed there, as example, if I copy the all the code from Addon_catchcavi.xml, into the functions.lua and I use the following:

<onLeaveCompat>

catchcavi();)

</onLeaveCompat>


it will look for catchcavi() from the funtions.lua file and use it, why add another loop into the function.lua file?

Re: useGoodie

Posted: Wed Jun 01, 2011 7:36 am
by lisa
Another reason is for troubleshooting, since your version is so old I am guessing there will be a lot of problems that arise, if you keep the original files in tact it is a lot easier for us to try and help fix the issues. Adding a single line to the top of the file which says to include another file is a good way to go about it.

Re: useGoodie

Posted: Wed Jun 01, 2011 8:31 am
by rock5
Like I said in the other post, put all your functions, such as the catchcavy function, into the userfunction.lua file. It wont initially exist, just create it in the rom folder and add the functions. That way, like Lisa said, you don't need to modify any of the original files. Note: the userfunctions.lua file was created specifically for this purpose, use it.

Re: useGoodie

Posted: Wed Jun 01, 2011 3:41 pm
by harbifm
ok

I created a userfunctions.lua,

I put the code for catch cavi and useGoodies into it.

and wrote this into the profile, tell me if am doing something wrong

<onLoad><![CDATA[
<include("userfunctions.lua");
-- Additional Lua code to execute after loading the profile
-- and before the bot starts. e.g. You could overwrite profile settings here
-- like: changeProfileOption("HP_REST", 60);
]]></onLoad>

Re: useGoodie

Posted: Wed Jun 01, 2011 6:53 pm
by lisa
at the top of functions.lua it says something like this

Code: Select all

if( settings == nil ) then
	include("settings.lua");
end
just add the include at the top

Code: Select all

include("userfunctions.lua");
if( settings == nil ) then
	include("settings.lua");
end
or if you want to leave functions.lua as it is by default then in all of your profiles

Code: Select all

<onLoad><![CDATA[
include("userfunctions.lua");
]]></onLoad>
you just had a < in the code you posted that shouldn't have been there

Re: useGoodie

Posted: Thu Jun 02, 2011 7:09 am
by rock5
You don't need to do any of that. Revision 472 already has code to use "userfunctions.lua". You'll see near the top of bot.lua

Code: Select all

if( fileExists(getExecutionPath().."/userfunctions.lua") ) then
	include("userfunctions.lua");
end
Edit: I thought you had 472. I see above you said you had 468. What I said still applies

Re: useGoodie

Posted: Sat Jun 04, 2011 9:02 am
by harbifm
worked fine

but the luck potion is named differently in my server, it is:

lucky target

Re: useGoodie

Posted: Sat Jun 04, 2011 12:40 pm
by Giram
Those names that are used by useGoodie is not buff names. They are just words that i have defined and i could change that name to what i want. For example using usegoodie("luck") it would search client specific buff name by using buff ids that are defined in code.

Re: useGoodie

Posted: Sat Jun 04, 2011 1:07 pm
by harbifm
the good thing i am not getting errors any more, I have version 475

the way i have done is as u said, cereated a file called userfunctions.lua
copy and paste both catch cavi and useGoodies into that file

than added one line into my profile like this after onLoad:
include "userfunctions"

as described above by rock5

now, how should i call the buff "luck" or the action "catch_cavi()" into action after <onLeaveCombat>?

Re: useGoodie

Posted: Sat Jun 04, 2011 9:25 pm
by rock5
I never said you needed to "include" userfunctions. I said 475 already includes it so you don't have to include it. All you have to do is create the "userfunctions.lua" file.

To use the functions add the following to the onLeaveCombat section,

Code: Select all

catchCavy() -- Will catch only Golden Magic Cavy and should work in any language.
or

Code: Select all

catchCavy("Cavy") -- Will catch both normal and golden, Change "Cavy" to your language.
  • This is assuming you already made that change to the catchCavy function I talked about.
  • Also you might need to upgrade to 477 to use catchCavy.
and

Code: Select all

useGoodie("luck")