Looking For a Command help..
-
- Posts: 2
- Joined: Fri Aug 26, 2011 8:38 pm
Looking For a Command help..
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
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
Re: Looking For a Command help..
Something like this will probably do what you want.
Obviously the waypoint coords arn't the ones you want, just did that to show where the code goes.
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>
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
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
-
- Posts: 2
- Joined: Fri Aug 26, 2011 8:38 pm
Re: Looking For a Command help..
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
Thanks For The Response
Re: Looking For a Command help..
until not player:haveTarget()
the until ends the loop, so you can make the until what ever you want.
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
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Re: Looking For a Command help..
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:
Save this in the "rom\userfunctions" folder as something like "userfunction_KillWhileWaiting.lua". In your waypoint file you would use this like:
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.
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
Code: Select all
<!-- # 5 --><waypoint x="-7308" z="45008" y="620">
KillWhileWaiting(30)
</waypoint>
Scout/Knight/Rogue 70/66/66
Re: Looking For a Command help..
of course a good idea to do that =)
If I could add a suguestion, make a default value for the waittime.
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
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Re: Looking For a Command help..
Cool, I'd forgotten how to add a default value. I think I'm actually gonna keep this one
Scout/Knight/Rogue 70/66/66
Re: Looking For a Command help..
I would also suggest checking localizations. 'starttime' in particular could very easily be used elsewhere. So to avoid conflict use
Of course you don't have to indent like this but I just have a pet peeve about indents.
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
- 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
Re: Looking For a Command help..
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
Scout/Knight/Rogue 70/66/66
Re: Looking For a Command help..
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
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
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Re: Looking For a Command help..
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.
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
Re: Looking For a Command help..
seems using this type of code
doesn't work if done as local
Been testing some code for party heals and have this
If I do
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.
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.
Code: Select all
something = something or somethingelse
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
Code: Select all
local _firsttimes = _firsttimes or 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
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
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Re: Looking For a Command help..
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
Re: Looking For a Command help..
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.
the reason is simple the time can only be found if the current value is compared with the previous which must be stored permanently.
- Administrator
- Site Admin
- Posts: 5313
- Joined: Sat Jan 05, 2008 4:21 pm
Re: Looking For a Command help..
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).
Re: Looking For a Command help..
lol that just makes to much sense =)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).
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
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Who is online
Users browsing this forum: Google [Bot] and 2 guests