Looking For a Command help..

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
Pranjal1234
Posts: 2
Joined: Fri Aug 26, 2011 8:38 pm

Looking For a Command help..

#1 Post by Pranjal1234 » Fri Aug 26, 2011 8:46 pm

OK so this is the issue i want the player to stop at the way point but it to still attack the mobs and a range that can be set..

I tried using player:rest(600) but it just stands there and doesn't attack near by moobs

Also i saw a post with this guy talking about a scanning type functions where it cld scan around for mobs from that waypoint for a certain amt of time.

Thanks For Read , Any Comment is Accepted :D

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

Re: Looking For a Command help..

#2 Post by lisa » Fri Aug 26, 2011 9:02 pm

Something like this will probably do what you want.

Code: Select all

<!-- #  1 --><waypoint x="4810" z="-1888" y="107">
repeat
player:clearTarget();
player:target(player:findEnemy())
if player:haveTarget() then
player:fight();
end
until not player:haveTarget()
</waypoint>
Obviously the waypoint coords arn't the ones you want, just did that to show where the code goes.
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

Pranjal1234
Posts: 2
Joined: Fri Aug 26, 2011 8:38 pm

Re: Looking For a Command help..

#3 Post by Pranjal1234 » Fri Aug 26, 2011 9:06 pm

Could i put a time for that so that it stands at that waypoint and if some mob comes close it will attack it and will go back to the same waypoint untill the time is up?

Thanks For The Response :D

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

Re: Looking For a Command help..

#4 Post by lisa » Fri Aug 26, 2011 9:36 pm

until not player:haveTarget()

the until ends the loop, so you can make the until what ever you want.

Code: Select all

<!-- #  1 --><waypoint x="4810" z="-1888" y="107">
starttime = os.time()
repeat
player:clearTarget();
player:target(player:findEnemy())
if player:haveTarget() then
player:fight();
end
until os.time() - starttime >= 60 -- so will stay at waypoint for 60 seconds.
</waypoint>
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

kanta
Posts: 424
Joined: Thu Nov 11, 2010 4:08 pm

Re: Looking For a Command help..

#5 Post by kanta » Sat Aug 27, 2011 10:58 am

If this is something you are going to do many times through your waypoint file you could make it into a userfunction so any changes you make to the base coding only needs to be changed once and not have to search through and change many instances of it.

Open a text editor (such as notepad or whatever editor you use) and put the following code in:

Code: Select all

function KillWhileWaiting(timetowait)
starttime = os.time()
repeat
player:clearTarget();
player:target(player:findEnemy())
if player:haveTarget() then
player:fight();
end
until os.time() - starttime >= timetowait
end
Save this in the "rom\userfunctions" folder as something like "userfunction_KillWhileWaiting.lua". In your waypoint file you would use this like:

Code: Select all

	<!-- #  5 --><waypoint x="-7308" z="45008" y="620">
	KillWhileWaiting(30)
	</waypoint>
The number in the () will tell the bot how long you want to wait. It can be any value, where the value is the number of seconds you want to wait.
Scout/Knight/Rogue 70/66/66

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

Re: Looking For a Command help..

#6 Post by lisa » Sat Aug 27, 2011 8:05 pm

of course a good idea to do that =)

If I could add a suguestion, make a default value for the waittime.

Code: Select all

function KillWhileWaiting(timetowait)
timetowait = timetowait or 60 --sets to 60 if no value for timetowait
starttime = os.time()
repeat
player:clearTarget();
player:target(player:findEnemy())
if player:haveTarget() then
player:fight();
end
until os.time() - starttime >= timetowait
end

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

kanta
Posts: 424
Joined: Thu Nov 11, 2010 4:08 pm

Re: Looking For a Command help..

#7 Post by kanta » Sat Aug 27, 2011 10:08 pm

Cool, I'd forgotten how to add a default value. I think I'm actually gonna keep this one :D
Scout/Knight/Rogue 70/66/66

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

Re: Looking For a Command help..

#8 Post by rock5 » Sat Aug 27, 2011 10:32 pm

I would also suggest checking localizations. 'starttime' in particular could very easily be used elsewhere. So to avoid conflict use

Code: Select all

function KillWhileWaiting(timetowait)
	local timetowait = timetowait or 60 --sets to 60 if no value for timetowait
	local starttime = os.time()
	repeat
		player:clearTarget();
		player:target(player:findEnemy())
		if player:haveTarget() then
			player:fight();
		end
	until os.time() - starttime >= timetowait
end
Of course you don't have to indent like this but I just have a pet peeve about indents. :)
  • 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

kanta
Posts: 424
Joined: Thu Nov 11, 2010 4:08 pm

Re: Looking For a Command help..

#9 Post by kanta » Sat Aug 27, 2011 11:24 pm

I thought about the local thing but wasn't sure if it would be necessary.... Kinda avoided asking about it because I thought it would be a noob question :roll:
Scout/Knight/Rogue 70/66/66

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

Re: Looking For a Command help..

#10 Post by lisa » Sat Aug 27, 2011 11:53 pm

Yeah when I test code I generally have it as local first and if it doesn't work then I remove the local.

I obviously hadn't tested this code ;)
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

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

Re: Looking For a Command help..

#11 Post by rock5 » Sun Aug 28, 2011 4:35 am

You should always use 'local' unless you want the variable to be global or it was already declared 'local' earlier.

Just because not declaring it local doesn't cause any problems, is no excuse for not declaring it. It may well cause problems in the future if someone else unwittingly uses the same global variable.
  • 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

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

Re: Looking For a Command help..

#12 Post by lisa » Sun Aug 28, 2011 11:51 am

seems using this type of code

Code: Select all

something = something or somethingelse
doesn't work if done as local

Been testing some code for party heals and have this

Code: Select all

_firsttimes = _firsttimes or false
if _firsttimes == false then
cprintf(cli.yellow,"Party member "..i.." has the name of ")
cprintf(cli.red, GetPartyMemberName(i).."\n")
_firsttimes = true
end
If I do

Code: Select all

local  _firsttimes = _firsttimes or false
it doesn't work and always says it is false

--=== Update ===--
Actually minor correction, it does work but you can't change the value with
_firsttimes = true, so if it is going to be that value without alteration then it works just fine. If you want to be able to change it later then you will probably have to make it not local.

In the end I gave up trying to make it a local, in my case anyway.

Code: Select all

	if _firsttimes == nil then -- post party names when bot started
			if GetPartyMemberName(i) ~= nil then
			cprintf(cli.yellow,"Party member "..i.." has the name of ")
			cprintf(cli.red, GetPartyMemberName(i).."\n")
			_firsttimes = true
			end
	end
So I have a global which i only use just once and never use anywhere else, can't think of how else to do it. This code is within a loop and I only want the prints done the first time code us done.
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

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

Re: Looking For a Command help..

#13 Post by rock5 » Sun Aug 28, 2011 8:32 pm

Actually I think that's working as intended. Using 'local' would initialise the value. If you want to check it again at a later time, it would have to be global I think. In most cases 'something = something or somrthingelse' would assume a global variable.
  • 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

SpiralV
Posts: 72
Joined: Sat Jun 25, 2011 10:37 am
Location: Germany

Re: Looking For a Command help..

#14 Post by SpiralV » Tue Aug 30, 2011 6:23 pm

let me note something, whenever the time in which a value changes is needed, then a global is necessary. Thats a simple rule that I do often use.
the reason is simple the time can only be found if the current value is compared with the previous which must be stored permanently.

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Looking For a Command help..

#15 Post by Administrator » Wed Aug 31, 2011 12:37 am

I think the problem is that false is, well, false, so in the or statement, it is ignored (as it needs to be true to be returned).

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

Re: Looking For a Command help..

#16 Post by lisa » Wed Aug 31, 2011 1:35 am

Administrator wrote:I think the problem is that false is, well, false, so in the or statement, it is ignored (as it needs to be true to be returned).
lol that just makes to much sense =)
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

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 2 guests