Page 1 of 1
Userfunctions
Posted: Wed Aug 31, 2016 2:52 am
by Newbie
Can anyone help me, how i can use userfunctions, how run etc? I can't find this on Wiki.
Thanks.
Re: Userfunctions
Posted: Wed Aug 31, 2016 5:07 pm
by Bill D Cat
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:
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
Re: Userfunctions
Posted: Thu Sep 01, 2016 4:10 am
by Newbie
Thanks, but still i'm confused