Rombot feature request - Userfunctions file

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Rombot feature request - Userfunctions file

#1 Post by rock5 » Thu Jan 07, 2010 2:21 am

Hi,

I just had an idea.

I've gotten to the point that I create routines that do certain tasks and cut and paste them to waypoints as needed which can make waypoints quite large.

I thought I'd like to make them in to functions but I gather I would have to edit one of the exiting files to include my functions. This would cause problems when updating to the latest svn.

It would be great if users could create their own functions and keep them in their own userfunctions file to use in their waypoint files as needed.

The exciting part of this idea is it would allow an easy way for users to help each other by sharing their functions, that complete specific tasks, with other users. It would encourage more user participation. You could have a forum dedicated to user created functions. If people need help to complete a specific task they could go there copy and paste a solution into their userfunctions files. Then they could use it in their scripts.

And who knows, maybe you'll see a function that needs to be added to the main files of the rombot.? :)

What do you think? I believe it would be very simple to implement, wouldn't it? Just a matter of including the userfunctions file if it exists.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Rombot feature request - Userfunctions file

#2 Post by Administrator » Thu Jan 07, 2010 1:09 pm

If you're updating off of SVN, you can merge your changes with updates so that you don't lose them. That's the whole reason behind SVN. Also, you could just create a new file named 'myfunctions.lua', and then add 'include("myfunctions.lua")' to rom/bot.lua.

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Rombot feature request - Userfunctions file

#3 Post by rock5 » Fri Jan 08, 2010 8:05 am

The reason I don't like to make changes to the regular files of rombot is because sometimes the changes I want to make are specific to my needs and they might conflict with future versions.

Thanks for telling me where to put the 'myfunctions.lua'. I'd seen 'include' commands in various files and didn't know if just putting it in the bot.lua would be enough. I'm doing that now.

So I take it you weren't as excited by the idea as me? I just thought if you made it a part if rombot it would stimulate user participation.

To give you an example, here are the first functions I'm adding;

Code: Select all

------------------------------------------------
-- Dismount Script
-- mountsbuff = name of mount as appears in player buffs
-- returns 'true' if the player dismounted or 'false' if not.
------------------------------------------------
function CancelBuff(buffname)
    if mountsbuff == nil then
        cprintf(cli.yellow,"No mount specified. Please use 'CancelBuff(buffname)'.\n")
        return false
    end
    local buffnum=1
    local buff=RoMScript("UnitBuff('player',"..buffnum..")");
    while buff ~= nil do
        if buff == buffname then
            sendMacro("CancelPlayerBuff("..buffnum..");")
            return true
        end
        buffnum=buffnum+1
        buff=RoMScript("UnitBuff('player',"..buffnum..")");
    end
    return false
end

------------------------------------------------
-- Select Option By Name
-- optiontext = option text or part of
-- NPC option dialog should already be open
------------------------------------------------
function SelectOptionByName(optiontext)
    counter = 1
    while RoMScript("GetSpeakOption("..counter..")") do
        if string.find(RoMScript("GetSpeakOption("..counter..")"),optiontext) then
            sendMacro("ChoiceOption("..counter..");"); yrest(1500);
            return true
        end
        counter = counter +1
    end
    return false
end

------------------------------------------------
-- Buy number of items by item name
-- itemname = name of item to buy
-- num = number of items to buy
-- Store should already be open
------------------------------------------------
function BuyItemByName(itemname, num)
    if num == nil then num = 1 end -- Assume you want to buy 1

    counter = 1
    icon, name = RoMScript("GetStoreSellItemInfo("..counter..")")
    while name do
        if string.find(name,itemname) then
            for i = 1, num do
                sendMacro("StoreBuyItem("..counter..")"); yrest(1000);
            end
            return true
        end
        counter = counter + 1
        icon, name = RoMScript("GetStoreSellItemInfo("..counter..")")
    end
    return false
end
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Rombot feature request - Userfunctions file

#4 Post by Administrator » Fri Jan 08, 2010 12:51 pm

I've added a conditional include (see below) to include the file if it exists, but have not committed it to the SVN repository yet. I will not make a default userfunctions.lua file for the reason that installing a newer version would overwrite the users' copy in the future. Basically, the file will still need to be created by the user to prevent upgrade issues.

Code: Select all

if( fileExists("userfunctions.lua") ) then
	include("userfunctions.lua");
end

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Rombot feature request - Userfunctions file

#5 Post by rock5 » Fri Jan 08, 2010 11:07 pm

Yep, that's the way I was expecting it to work.

Please do commit it. I think maybe I will start a thread so users know about it and can start using it, unless you want to do it?

1 last question I've been meaning to ask, what is the difference between the solarstrike and elitepvpers forums? When should users use 1 or the other?
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Rombot feature request - Userfunctions file

#6 Post by Administrator » Sat Jan 09, 2010 9:44 am

It was committed.
1 last question I've been meaning to ask, what is the difference between the solarstrike and elitepvpers forums? When should users use 1 or the other?
This is the official forum. If you have technical problems, it's probably better to post here. If you don't speak English, it's probably best to post on elitepvpers.

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Rombot feature request - Userfunctions file

#7 Post by rock5 » Sun Jan 10, 2010 12:11 am

It doesn't work. Looks like fileExists command is wrong.

Can you please change it to:

Code: Select all

if( fileExists(getExecutionPath().."/userfunctions.lua") ) then
Thanks.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Rombot feature request - Userfunctions file

#8 Post by Administrator » Sun Jan 10, 2010 12:16 am

rock5 wrote:It doesn't work. Looks like fileExists command is wrong.

Can you please change it to:

Code: Select all

if( fileExists(getExecutionPath().."/userfunctions.lua") ) then
Thanks.
Good catch. It's committed.

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Rombot feature request - Userfunctions file

#9 Post by rock5 » Sun Jan 10, 2010 5:18 am

So is it ok for me to start a thread informing users about this and encouraging them to contribute functions?

If so should I do it here at solarstrike?
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Rombot feature request - Userfunctions file

#10 Post by Administrator » Sun Jan 10, 2010 10:33 am

rock5 wrote:So is it ok for me to start a thread informing users about this and encouraging them to contribute functions?

If so should I do it here at solarstrike?
That would be fine. A mention in the wiki would also be useful.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 7 guests