-
Questionmark
- Posts: 31
- Joined: Mon Apr 11, 2011 3:06 am
#1
Post
by Questionmark » Mon Apr 11, 2011 3:15 am
Is there a way to display the bot's running time ingame? I've been trying the following, but I do get an error and I can't seem to fix it.
Code: Select all
<onLeaveCombat>
addMessage ( "Gevecht #" .. player.Fights );
if ( player.free_counter1 == 0 ) then
player.free_counter1 = os.time();
local uren, minuten, seconden = 0;
else
local uur, minuten, seconden = 0;
seconden = os.difftime(os.time(), player.free_counter1);
if ( seconden < 60 ) then
addMessage("Duur: " .. seconden .. "seconden");
elseif( seconden >= 60 ) then
min = floor(seconden/60);
addMessage("Duur: " .. minuten .. " minuten " .. seconden .. "seconden");
elseif( sec >= 3600 ) then
min = floor(sec/60);
uur = floor(min/60);
addMessage("Duur: " .. uren .. " uren, " .. minuten .. " minuten " .. seconden .. "seconden");
end;
end;
</onLeaveCombat>
The error should be at this line...
and the error is...
Code: Select all
Message: not well-formed (invalid token)
Could someone help me with this?
-
Administrator
- Site Admin
- Posts: 5307
- Joined: Sat Jan 05, 2008 4:21 pm
#2
Post
by Administrator » Mon Apr 11, 2011 3:25 am
Use the CDATA tags to surround the code. Look at the default code provided in some of the events for an example.
-
JackBlonder
- Posts: 99
- Joined: Sat Dec 18, 2010 6:55 am
#3
Post
by JackBlonder » Mon Apr 11, 2011 1:12 pm
It's because of the
He could also do
to solve it, right?
-
rock5
- Posts: 12173
- Joined: Tue Jan 05, 2010 3:30 am
- Location: Australia
#4
Post
by rock5 » Mon Apr 11, 2011 9:20 pm
Yes, that's another solution, probably the easiest solution. The third solution that some people use is an escape sequence that I don't know off the top of my head. It's basically a string of 5 or 6 characters that represents the '<' symbol.
- 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.”
-
Questionmark
- Posts: 31
- Joined: Mon Apr 11, 2011 3:06 am
#5
Post
by Questionmark » Tue Apr 12, 2011 12:49 am
Using the CDATA tags worked for me.
This is what I got so far and it's working. I haven't been using the bot for over an hour, so I don't know if the part for running more than an hour works, but I think it does.
Code: Select all
<onLeaveCombat><![CDATA[
if (player.free_counter1 == 0) then
player.free_counter1 = os.time();
local tijd = os.difftime(os.time(), player.free_counter1);
addMessage(player.Fights .. " Gevecht in " .. tijd .. "s");
else
local tijd = os.difftime(os.time(), player.free_counter1);
if (tijd < 60) then
addMessage(player.Fights .. " Gevechten in " .. tijd .. "s");
elseif(tijd >= 60) then
local minuten = math.floor(tijd / 60);
local seconden = tijd - (minuten * 60);
addMessage(player.Fights .. " Gevechten in " .. minuten .. "m " .. seconden .. "s");
elseif(tijd >= 3600) then
local uren = math.floor(tijd / 3600);
local minuten = math.floor(tijd / 60) - (uren * 60);
local seconden = tijd - (minuten * 60);
addMessage(player.Fights .. " Gevechten in " .. uren .. "u " .. minuten .. "m " .. seconden .. "s");
end;
end;
]]></onLeaveCombat>
Thanks for the advice.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 4 guests