Trying to do more with an alias.

Post Reply
AHayt
Posts: 2
Joined: Mon Jul 09, 2018 12:46 am

Trying to do more with an alias.

Post by AHayt » Wed Aug 22, 2018 5:05 pm

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.

Jor'Mox
Posts: 1089
Joined: Wed Apr 03, 2013 2:19 am

Re: Trying to do more with an alias.

Post by Jor'Mox » Wed Aug 22, 2018 7:10 pm

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.

AHayt
Posts: 2
Joined: Mon Jul 09, 2018 12:46 am

Re: Trying to do more with an alias.

Post by AHayt » Thu Aug 23, 2018 2:34 am

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:

Code: Select all

1289/1289h, 1067/1289m cev (-) 
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.

Jor'Mox
Posts: 1089
Joined: Wed Apr 03, 2013 2:19 am

Re: Trying to do more with an alias.

Post by Jor'Mox » Thu Aug 23, 2018 11:24 am

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.
Code: [show] | [select all] lua
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

Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests