Userfunctions

Additional botting resources. Addons may be either for the game itself or for the RoM bot.
Forum rules
Only post additional bot resources here. Please do not ask unrelated questions.
Post Reply
Message
Author
Newbie
Posts: 14
Joined: Wed Aug 10, 2016 7:17 am

Userfunctions

#1 Post by Newbie » Wed Aug 31, 2016 2:52 am

Can anyone help me, how i can use userfunctions, how run etc? I can't find this on Wiki.
Thanks.

User avatar
Bill D Cat
Posts: 555
Joined: Sat Aug 10, 2013 8:13 pm
Location: Deep in the Heart of Texas

Re: Userfunctions

#2 Post by Bill D Cat » Wed Aug 31, 2016 5:07 pm

Newbie wrote:Can anyone help me, how i can use userfunctions, how run etc? I can't find this on Wiki.
Thanks.
If you've ever done any kind of programming at all, then you will be familiar with and can think of userfunctions as a collection of subroutines or functions that you can call from anywhere when the bot is running. An example of this is Rock5's userfunction_travelTo.lua file. In it is the function that automates traveling around the world via Snoop and other local city transporters. You can use it in a waypoint file by adding a command when near one of these transporters just by calling the function with the name of your destination as the argument.

Example:

Code: Select all

travelTo("Varanas")
This also works from the bot's CommandLine option. Just type the command at the prompt and it will execute the function. So if you want to create your own function, just make a new .lua file in the userfunctions directory and name it appropriately. Any functions you add to the file can then be called from either a waypoint file or used at the commandline option. You can add as many individual functions as you like to the file, just as long as they each have a unique function name. Duplicating the name inside the same file, or even one from a different userfunction file will give very unexpected results. I highly recommend that any variables you declare within a function are defined as LOCAL so as not to potentially overwrite variables in use elsewhere within the bot or other functions.

See my userfunction_QuestHelpers file for an example of multiple functions within the same file: http://www.solarstrike.net/phpBB3/viewt ... =27&t=6016

Newbie
Posts: 14
Joined: Wed Aug 10, 2016 7:17 am

Re: Userfunctions

#3 Post by Newbie » Thu Sep 01, 2016 4:10 am

Thanks, but still i'm confused

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests