Page 1 of 1

ReturnCheck Function

Posted: Sat Oct 20, 2012 6:48 pm
by botje
i made this function to re-use it in my waypoints, as a easy way to go to shop etc when im done or my dura/potions get low.

its still in the "beta" phase, but i allready tested it succesfully.

and i thought, lets share this :P

how does it work?

ReturnCheck(_Path_To_GoTo) - this is the simplest one, just checks for dura and bagspace, and goes to the file filled in Path_To_GoTo.

ReturnCheck(_Path_To_GoTo, true) - also simple check for dura and space, and go to tagname within the same waypoint file

spacecheck and duracheck accept numbers to check against, and potioncheck the name of the potion you like to check.

Code: Select all

function ReturnCheck(_Path_To_GoTo, wptag, spacecheck, duracheck, potioncheck)
	local spaces = inventory:itemTotalCount(0);
	local dura = inventory:getMainHandDurability();
	
	if spacecheck == nil or spacecheck == "" then spacecheck = 5 end
	if duracheck == nil or duracheck == "" then duracheck = 50 end
	if wptag == nil or wptag == "" then wptag = false end
	if potioncheck == nil or potioncheck == "" then potioncheck = "false" end
			
	printf("Bag spaces free:  "..spaces.."\n");
	printf("Weapon Durbility: "..dura.."\n");
	
	if potioncheck == "false" then
		if spacecheck > spaces or duracheck > dura then
			printf("Going to shop, loading new waypoint...\n");
			 
			if wptag == false then
				loadPaths(_Path_To_GoTo);
			else
				__WPL:setWaypointIndex(__WPL:findWaypointTag(wptag));
			end
		end
	else
		local potions = inventory:itemTotalCount(potioncheck)
		printf("Potions left: "..potions.."\n");
		
		if spacecheck > spaces or duracheck > dura or 25 > potions then
			printf("Going to shop, loading new waypoint...\n");
			
			if wptag == false then
				loadPaths(_Path_To_GoTo);
			else
				__WPL:setWaypointIndex(__WPL:findWaypointTag(wptag));
			end
		end
	end
end
have fun, and ways to make it better are welcome :)

Botje