Page 1 of 1

"While-loop" problem

Posted: Tue Nov 02, 2010 2:12 pm
by Personalausweis

Code: Select all

<!-- # 11 --><waypoint x="5534" z="-4432" tag ='main'>
						player:target_NPC("Lehman");
						local questCompleted = RoMScript("CheckQuest(421457);");
   						if questCompleted == 0
							then -- does AT quest
								player:target_NPC("Lehman");
								sendMacro("OnClick_QuestListButton(1,1)");
								yrest(1000);
								sendMacro("OnClick_QuestListButton(1,1)");
								yrest(1000);
                                                                __WPL:setWaypointIndex(__WPL:findWaypointTag("main")); -- PROBLEM 2
							else  -- buys charges
								player:merchant("Lehman");
								yrest(500);
								sendMacro("ChoiceOption(1);");
								yrest(500);
								while (inventory:itemTotalCount(203038) >= 30)  -- PROBLEM 1
									do
									sendMacro("StoreBuyItem(1)");
									yrest(1000); 
									end;
								sendMacro("CloseWindows();"); 
								while (inventory:itemTotalCount(203487) > 0) -- uses charges
									do
									inventory:useItem(203487);   
									end;
								write_tokens();
						end;
						RoMScript("UseSkill(1,2);");   -- Port to Elven island
						player:rest(30); 
						loadPaths("back");
	</waypoint>

Hi there

i got some problems with above posted code:

1. The first "while-loop" won't end, i have a character with 1000 tokens, he ran to Lehman an bought 33 charges for AT he had 10 tokens left an still wanted to buy more charges

2. if he finishes the AT quest, he directly ports back to elven-island, instead of repeating the waypoint, starting with the quest-check.

Re: "While-loop" problem

Posted: Tue Nov 02, 2010 3:01 pm
by runensammler
ad Problem 1

Code: Select all

while (inventory:itemTotalCount(203038) >= 30)  -- PROBLEM 1
I experienced some problems with >= so i always use only the >

try this one

Code: Select all

while (inventory:itemTotalCount(203038) > 29)  -- PROBLEM 1
ad Problem 2

I think its because the bot finishes the waypoint and then goes to the indexed one

maybe this could do the trick

Code: Select all

<!-- # 12 --><waypoint x="5534" z="-4432">
         RoMScript("UseSkill(1,2);");   -- Port to Elven island
         player:rest(30);
         loadPaths("back");
</waypoint>

Re: "While-loop" problem

Posted: Tue Nov 02, 2010 9:27 pm
by rock5
runensammler wrote:ad Problem 1

I experienced some problems with >= so i always use only the >
There is no problem with >=. There is no difference between >=30 and >29 when dealing with integers.
runensammler wrote:ad Problem 2

I think its because the bot finishes the waypoint and then goes to the indexed one
No, the code for the waypoint will be completed.

Personalausweis,

First problem is most likely because you are not updating the inventory so the bot thinks he still has 1000.

Second problem is because setWaypointIndex only sets the next waypoint. It won't move to that waypoint until it has finished the code for this waypoint. If you don't want it to teleport if it is completing the quest then just move the teleport to the 'else' section of the 'if' statement. Also you can use the new function waitForLoadingScreen() instead of the player:rest(30) command. It will return control as soon as the teleport completes.

So try;

Code: Select all

	<!-- # 11 --><waypoint x="5534" z="-4432" tag ='main'>
		player:target_NPC("Lehman");
		local questCompleted = RoMScript("CheckQuest(421457);");
			if questCompleted == 0 then -- does AT quest
				player:target_NPC("Lehman");
				sendMacro("OnClick_QuestListButton(1,1)");
				yrest(1000);
				sendMacro("OnClick_QuestListButton(1,1)");
				yrest(1000);
				__WPL:setWaypointIndex(__WPL:findWaypointTag("main")); -- PROBLEM 2
			else  -- buys charges
				player:merchant("Lehman");
				yrest(500);
				sendMacro("ChoiceOption(1);");
				yrest(500);
				while (inventory:itemTotalCount(203038) >= 30) do
					sendMacro("StoreBuyItem(1)");
					yrest(1000);
					inventory:update()
				end;
				sendMacro("CloseWindows();");
				while (inventory:itemTotalCount(203487) > 0) do -- uses charges
					inventory:useItem(203487);   
				end;
				write_tokens();
				RoMScript("UseSkill(1,2);");   -- Port to Elven island
				waitForLoadingScreen();
				loadPaths("back");
		end;
   </waypoint>

Re: "While-loop" problem

Posted: Wed Nov 03, 2010 2:45 am
by Personalausweis
Thanks a lot you two.

will test the "inventory:update();" and loadingscreen-thing today.

about the second problem i thought ab bit that night, if all characters (atm 64) are lvl 10, whitch will be today, i could erase the if part which asks for the AT quest.
than i could replace it with:

Code: Select all

player:merchant("Lehman");
            yrest(500);
            sendMacro("ChoiceOption(1);");
            yrest(500);
            while (inventory:itemTotalCount(203038) >= 30) do
               sendMacro("StoreBuyItem(1)");
               yrest(1000);
               inventory:update();
            end;
            sendMacro("CloseWindows();");
            while (inventory:itemTotalCount(203487) > 0) do -- uses charges
               inventory:useItem(203487);   
            end;
            write_tokens();
            RoMScript("UseSkill(1,2);");   -- Port to Elven island
            waitForLoadingScreen();
            loadPaths("back");
this should do it.


in whitch rev is the "waitforLoadingScreen" function included ?

Re: "While-loop" problem

Posted: Wed Nov 03, 2010 3:32 am
by rock5
Personalausweis wrote:in whitch rev is the "waitforLoadingScreen" function included ?
513

Re: "While-loop" problem

Posted: Wed Nov 03, 2010 6:46 am
by runensammler
rock5 wrote:
runensammler wrote:
runensammler wrote:ad Problem 2

I think its because the bot finishes the waypoint and then goes to the indexed one
No, the code for the waypoint will be completed.
Thtas what i meant with finishing the waypoint :D
rock5 wrote: Also you can use the new function waitForLoadingScreen() instead of the player:rest(30) command. It will return control as soon as the teleport completes.
Is there help wanted to find the pointer if we get a new update?

Re: "While-loop" problem

Posted: Wed Nov 03, 2010 1:04 pm
by Personalausweis

Code: Select all

<!-- # 11 --><waypoint x="5534" z="-4432" tag ='main'>
     					player:target_NPC("Lehman");
					local questCompleted = RoMScript("CheckQuest(421457);");
				        if questCompleted == 0 then
				        player:target_NPC("Lehman");
				        sendMacro("OnClick_QuestListButton(1,1)");
				        yrest(1000);
				        sendMacro("OnClick_QuestListButton(1,1)");
				        yrest(1000);
				        __WPL:setWaypointIndex(__WPL:findWaypointTag("main"));
        				else
				        player:merchant("Lehman");
            				yrest(500);
            				sendMacro("ChoiceOption(1);");
            				yrest(500);
            				while (inventory:itemTotalCount(203038) >= 30)
						do
               					sendMacro("StoreBuyItem(1)");
               					yrest(500);
               					inventory:update()
            					end;
            				sendMacro("CloseWindows();");
					end;
					</waypoint>
	<!-- # 12 --><waypoint x="5534" z="-4432">
	while (inventory:itemTotalCount(203487) > 0)
		do
               	inventory:useItem(203487);   
            	end;
	write_tokens();	
	RoMScript("UseSkill(1,2);");   -- Port to Elven island
        player:rest(35);
        loadPaths("zuDaylie");
   </waypoint>

Working perfectly :)

thanks a lot guys