Local counter

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
ZZZZZ
Posts: 513
Joined: Sun Oct 21, 2012 1:42 am

Local counter

#1 Post by ZZZZZ » Wed Oct 24, 2012 3:53 am

Hello,

Im just trying to figure out how to increment a counter.
eg

Code: Select all

<onLoad>
	local count1 = RoMScript("Daily_count()");
</onLoad>	
        <!-- #  1 --><waypoint x="-20796" z="-22649" y="591">	</waypoint>
	<!-- #  2 --><waypoint x="-21125" z="-22420" y="618">	</waypoint>
	<!-- #  3 --><waypoint x="-21483" z="-22037" y="597">	</waypoint>
	<!-- #  4 --><waypoint x="-21605" z="-21973" y="591">	</waypoint>
        <!-- #  5 --><waypoint x="-20393" z="-21331" y="804" tag='Main'>
	if 10 > count1 then   
            queststate = getQuestStatus("Concerned Note");
        if queststate == "complete" then
            -- Complete quest
               player:target_NPC("Shar Talos");
               CompleteQuestByName("Concerned Note");
		local count1 = local count1 + 1
            __WPL:setWaypointIndex(__WPL:findWaypointTag("Main"));   
        else
            -- Accept quest
               player:target_NPC("Shar Talos");
               AcceptQuestByName("Concerned Note");
            __WPL:setWaypointIndex(__WPL:findWaypointTag("Quest"));
        else
	    -- Do Quest
		__WPL:setWaypointIndex(__WPL:findWaypointTag("Quest"));
  	end
else
		inventory:update();
		player:update();
		-- note #202434 is the daily reset card
		if inventory:itemTotalCount(202434) >= 1 then
  		 	 inventory:useItem(202434);
		local count1 = 0
            __WPL:setWaypointIndex(__WPL:findWaypointTag("Main"));
 		else
 			error("No Daily Reset Cards left!")
 			player:sleep();
		end
end
local count1 = local count1 + 1 <- not sure if that works, lol

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Local counter

#2 Post by lisa » Wed Oct 24, 2012 3:57 am

Code: Select all

count1 = count1 + 1
you already assigned it as local in the onload.

Not sure if there is something about the onload of the WP being changed into a "function" so the local might make it only local to that onload.
So if it doesn't work then just change it to not be local.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

ZZZZZ
Posts: 513
Joined: Sun Oct 21, 2012 1:42 am

Re: Local counter

#3 Post by ZZZZZ » Wed Oct 24, 2012 4:19 am

Changed it, but still getting error "Failed to compile and run Lua code for waypoint #6"

It either something wrong with the whole 'count1' or with

Code: Select all

else
      inventory:update();
      player:update();
      -- note #202434 is the daily reset card
      if inventory:itemTotalCount(202434) >= 1 then
             inventory:useItem(202434);
      count1 = 0
            __WPL:setWaypointIndex(__WPL:findWaypointTag("Main"));
       else
          error("No Daily Reset Cards left!")
          player:sleep();
      end
end
as it all worked fine before i started adding extra's >.<

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Local counter

#4 Post by lisa » Wed Oct 24, 2012 4:44 am

if you are going to make up your own code, which is great, I find this tip useful.

Create a file in userfunctions folder, name it userfunction_whateveryouwant.lua
I use
userfunction_lisafunctions.lua

In that file add any code you want to test in WP as a function.

Code: Select all

function wptester()
   if 10 > count1 then   
            queststate = getQuestStatus("Concerned Note");
        if queststate == "complete" then
            -- Complete quest
               player:target_NPC("Shar Talos");
               CompleteQuestByName("Concerned Note");
      local count1 = local count1 + 1
            __WPL:setWaypointIndex(__WPL:findWaypointTag("Main"));   
        else
            -- Accept quest
               player:target_NPC("Shar Talos");
               AcceptQuestByName("Concerned Note");
            __WPL:setWaypointIndex(__WPL:findWaypointTag("Quest"));
        else
       -- Do Quest
      __WPL:setWaypointIndex(__WPL:findWaypointTag("Quest"));
     end
else
      inventory:update();
      player:update();
      -- note #202434 is the daily reset card
      if inventory:itemTotalCount(202434) >= 1 then
             inventory:useItem(202434);
      local count1 = 0
            __WPL:setWaypointIndex(__WPL:findWaypointTag("Main"));
       else
          error("No Daily Reset Cards left!")
          player:sleep();
      end
end
end
then in the waypoint just call the function.

Code: Select all

<!-- #  5 --><waypoint x="-20393" z="-21331" y="804" tag='Main'>
wptester()
</waypoint>
What this does is give you an actual error message, in the error message it will tell you the line and what is wrong with it.

Once you have the code working the way you want, then just copy it back to that waypoint and you can delete the function.

Doing this will help you solve a lot of the issues you come up against.

Don't make count1 local while testing though as the function will say it is nil.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

ZZZZZ
Posts: 513
Joined: Sun Oct 21, 2012 1:42 am

Re: Local counter

#5 Post by ZZZZZ » Wed Oct 24, 2012 6:15 am

Will give it a shot, didn't know about that, thanks :)

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Local counter

#6 Post by rock5 » Wed Oct 24, 2012 7:12 am

First off, if you are going to increment a variable like that then you shouldn't use 'local' at all.

Secondly, you know you don't have to count the times you do the daily? There is a convenient command for that in game. It's mentioned in many posts and is in many daily waypoint files
http://www.theromwiki.com/API:Daily_count

So you could do something like

Code: Select all

if 10 > RoMScript("Daily_count()") then
  • 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

jalcara
Posts: 1
Joined: Fri Feb 08, 2013 11:09 pm

Re: Local counter

#7 Post by jalcara » Fri Feb 08, 2013 11:13 pm

Hi, can u pls up the wp for that quest (concerned note), thx...

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest