Page 1 of 1
Trying to do more with an alias.
Posted: Wed Aug 22, 2018 5:05 pm
by AHayt
Hello, I am trying to simplify my life and save keystokes on login. I have been plugging along and have learned a good a small amount of lua. But I am trying to make this alias more robust, to add a couple features. But I so far all my attempts have ended in errors:
Code: Select all
local rituals = {"fortification","power","leech","blackheart","rainbow","stormcloud","earthquake","hailstorm"}
rituals_index = rituals_index or 1
GeneralRituals(rituals[rituals_index])
rituals_index = rituals_index + 1
if rituals_index > #rituals then rituals_index = 1 end
The function it is calling is:
Code: Select all
function GeneralRituals( Ritual)
if not ritualsingle then
send("dance "..Ritual.." enemies")
else
send("dance "..Ritual.." "..maintarget)
end
end
It is a simple function to switch the target of my rituals to single or just enemies at large.
There is a couple features I am trying to get to work. And I have tried various way to add them in. But I need this alias to sketch all at various intervals and a couple of the rituals do not need to be targeted. I even tried to get it to not fire when I did not have equilibrium....but that did not work.
Re: Trying to do more with an alias.
Posted: Wed Aug 22, 2018 7:10 pm
by Jor'Mox
Bearing in mind that I don't play whatever game you are playing, so I don't actually know how any of the rituals work or what have you, can you spell out what information you should be able to gather and what you want to do with that information in a step by step sort of way? For example, you mention "equilibrium" and having some issue with not being able to take that into account, but there isn't any reason from a code perspective why you couldn't, you just need to get that bit of info and use it appropriately to... do whatever you do when you have or don't have equilibrium.
But, essentially anything you can think up that you could make a flow chart for, you can do with an alias and a function like this (you may need several functions, but that isn't really important at this stage). And with a decent idea of what it is you want to do, I or someone like me can help walk you through making that happen.
Re: Trying to do more with an alias.
Posted: Thu Aug 23, 2018 2:34 am
by AHayt
I am trying to make a list of rituals to dance on startup of the game. To make this alias more robust there is a couple challenges, I am having as a novice coder. Some of the rituals do not need targets or enemies declared. And the list moves on, even if I pressed it and did not have equilibrium to dance said ritual.
I see the pieces but I am having trouble putting them together:
That is the ingame prompt, I have captured that information in a couple variables. I even use them in a couple other alias. I capture this bit "cev (-)" in a variable called cooldown. Then "e" means I have equilibrium. Ideally, I would like to make this alias not fire unless equilibrium was present.
In an ideal world, it would do something like as follow:
press one:
sketch all
press two:
dance fortification
press three:
dance power
press four:
sketch all
press five:
dance leech enemies
Now, when we get to the one that has enemies declared. I made that function above. Because there have been some niche circumstances were having them target a single person was ideal.
Re: Trying to do more with an alias.
Posted: Thu Aug 23, 2018 11:24 am
by Jor'Mox
To simplify things, I just put everything together as a single script. Your alias would just need to have this as the code: GeneralRituals()
Let me know if this works for you, or if there are issues, or further improvements you would like to implement.
local rituals = {"sketch", "fortification", "power", "sketch", "leech", "blackheart", "rainbow",
"stormcloud", "earthquake", "hailstorm"}
local needs_target = {"leech","blackheart"}
local rituals_index = 1
-- notes:
-- ritualsingle and cooldowns are both global variables that are being set somewhere else,
-- rituals_index will reset any time this script is opened or saved,
-- add any rituals that need a target to the "needs_target" table,
-- any time you want to "sketch all", just add "sketch" to the rituals table in that position
function GeneralRituals()
local eq = string.find(cooldowns,"e") -- looks for equilibrium in cooldowns
if eq then
local ritual = rituals[rituals_index] -- gets ritual from table
if ritual == "sketch" then -- handles "sketch all" instances
send("sketch all")
elseif table.contains(needs_target,ritual) then -- handles rituals that need targets
-- picks ritual target
local target = "enemies"
if ritualsingle then
target = maintarget
end
send(string.format("dance %s %s",ritual,target))
else -- handles rituals that don't need targets
send(string.format("dance %s",ritual))
end
if rituals_index >= #rituals then -- resets rituals_index when at the end of the list
rituals_index = 1
else
rituals_index = rituals_index + 1 -- increments rituals_index
end
end
end