"While-loop" problem

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
Personalausweis
Posts: 73
Joined: Mon Aug 16, 2010 12:50 pm

"While-loop" problem

#1 Post 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.
runensammler
Posts: 13
Joined: Mon Apr 06, 2009 6:20 am

Re: "While-loop" problem

#2 Post 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>
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: "While-loop" problem

#3 Post 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>
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
Personalausweis
Posts: 73
Joined: Mon Aug 16, 2010 12:50 pm

Re: "While-loop" problem

#4 Post 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 ?
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: "While-loop" problem

#5 Post by rock5 »

Personalausweis wrote:in whitch rev is the "waitforLoadingScreen" function included ?
513
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
runensammler
Posts: 13
Joined: Mon Apr 06, 2009 6:20 am

Re: "While-loop" problem

#6 Post 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?
Personalausweis
Posts: 73
Joined: Mon Aug 16, 2010 12:50 pm

Re: "While-loop" problem

#7 Post 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
Post Reply