Page 1 of 1

Rock5's DN_AutoQuest userfunction

Posted: Wed May 27, 2015 12:55 am
by rock5
Description:
  • This userfunction sets up DailyNotes to auto complete/accept the supplied quest Id.
Syntax:
  • DN_AutoQuest(questid)
Requirements:

Re: Rock5's DN_AutoQuest userfunction

Posted: Tue Jun 09, 2015 7:25 am
by noobbotter
Rock5,

I found the need to be able to disable autoquesting in Dailynotes. (for being able to do separate quests from a bulletin board for example) so I modified your Autoquest userfunction to allow me to do so. Feel free to take a look and make any changes to suit your preferences and re-share/update the post.

Added optional argument of "on" or "off" to enable automated turning off of autoaccepting quests:
DN_AutoQuest(questid, [state]) -- optional state should be "on" or "off". Default is "on". Anything other than ("off" or "Off" or "OFF") will turn the autoaccept of the specified quest on, including nil.

So at the beginning of my waypoint file, I will do

Code: Select all

QuestID = 123456  -- ID of Quest
DN_AutoQuest(QuestID) 	-- activate DailyNotes Autoquest 
then at the end of the waypoint, I will use

Code: Select all

DN_AutoQuest(QuestID,"off")
to turn off auto accepting of that quest.

NoobBotter


Update: Come to think about it, I never did do a check to see if my update actually disables the autoquest of a particular quest. It doesn't throw an error so I assumed it works. Maybe tonight I'll verify if it actually does what I intended.

Re: Rock5's DN_AutoQuest userfunction

Posted: Wed Jun 10, 2015 2:45 am
by rock5
I did think about adding a cancelling feature, I was thinking of a separate function, but, funnily enough, I couldn't decide on a name. That, and I wasn't sure of the necessity, so I didn't bother. Your solution is elegant enough. A few comments though.

This is not proper lua code

Code: Select all

	if state == ("off" or "Off" or "OFF") then
It should be

Code: Select all

	if state == "off" or state == "Off" or state == "OFF" then
Because onoff has 2 possible values I would probably used booleans and in case users expect to use booleans I would add that too. Eg.

Code: Select all

	if state == "off" or state == "Off" or state == "OFF" or state == false then
onoff starts as 1 so all you need to do is decide if you need to change it to 0. You never have to change it to 1. So

Code: Select all

	local onoff = 1
	if state == nil then
		onoff = 1
	end
	if state == "off" or state == "Off" or state == "OFF" or state == false then
		onoff = 0
	else
		onoff = 1
	end
Could be abbreviated to

Code: Select all

	local onoff = 1
	if state == "off" or state == "Off" or state == "OFF" or state == false then
		onoff = 0
	end
Otherwise it's good to go.

Re: Rock5's DN_AutoQuest userfunction

Posted: Wed Jun 10, 2015 2:57 am
by rock5
I just realized you don't even need 2 variables. You can do this.

Code: Select all

function DN_AutoQuest(questid, onoff)

...

	if onoff == "off" or onoff == "Off" or onoff == "OFF" or onoff == false then
		onoff = 0
	else
		onoff = 1
	end