I play a game called Achaea, in it my character is a runewarden and I have a lot of weapons for said character. Currently I use an alias system to switch weapons, but that has over 20 variables per alias. What I'm wanting to do is take all the variables I have for weapons and combine them into the stringlist and then pull the info from the stringlist to my alias. Is there a simpler way of doing it than the way I'm thinking about doing it, or is there a more efficient way of doing it?
This is what I'm currently doing to switch between weapons
<aliases>
<alias
match="speed"
enabled="y"
expand_variables="y"
group="Weapons"
sequence="100"
>
<send>relax grip
unwield left
unwield right
put @broadsword1 in @bag2
put @broadsword2 in @bag2
put @totem1 in @bag1
put @scimitar1 in @bag2
put @scimitar2 in @bag2
put @rapier3 in @bag3
put @rapier4 in @bag3
wear @bow1
put @battleaxe1 in @loop1
put @battleaxe2 in @loop2
put @battleaxe3 in @loop3
put @battleaxe4 in @loop4
put @battleaxe5 in @loop5
get @rapier1 from @bag3
get @rapier2 from @bag3
wield left @rapier1
wield right @rapier2
grip
vconfig_weaponone 80
vconfig_weapontwo 84</send>
</alias>
</aliases>
And in all honesty using the way I do it wouldn't be so bad but when you have 10 or so aliases for switching weapons it get to be a big mess keeping up with what weapon goes in what bag.... I went for like a month without a battleaxe because I manually put it in the wrong loop, then by the time I cleaned my scripting up and found out what was wrong with it, it had decayed :(
Can you clarify why you need 10 aliases? Do you have 10 combinations of weapons and gear you wear?
So roughly you want to do this ...
For a given situation (eg. you want your tanking gear) you want to remove whatever you have equipped and put that in your bag, and then get other stuff from your bag and equip it?
So your stringlist, as you call it, would be a list of what-goes-where?
Exactly. I have 17 or so combinations of weapons. And while some weapons are repeated in these combinations they're wielded in differing hands.
Also they're not all store in the same locations either, so I'd love if I could combine all of them into one variable too then pull it like that. Really just want the code for what I'm doing to be as clean as it can be.
Also another thing I'm hoping will happen is the reduction of spam on my screen, without having to gag anything out
You send your falcon winging away to a safe haven.
5720h, 4477m, 23400e, 17400w, 24% cexkdb|0/0|0/4|0/0|10- (23:48:41:117)
Your grip is already relaxed.
5720h, 4477m, 23400e, 17400w, 24% cexkdb|0/0|0/4|0/0|10- (23:48:42:117)
You cease wielding an ornate steel rapier in your left hand.
5720h, 4477m, 23400e, 17400w, 24% cexkdb|0/0|0/4|0/0|10- (23:48:42:122)
You cease wielding an ornate steel rapier in your right hand.
5720h, 4477m, 23400e, 17400w, 24% cexkdb|0/0|0/4|0/0|10- (23:48:42:128)
You hold no "broadsword6sfafa".
5720h, 4477m, 23400e, 17400w, 24% cexkdb|0/0|0/4|0/0|10- (23:48:42:133)
You hold no "broadswordasagfasfa".
5720h, 4477m, 23400e, 17400w, 24% cexkdb|0/0|0/4|0/0|10- (23:48:42:139)
You hold no "totemsssss".
5720h, 4477m, 23400e, 17400w, 24% cexkdb|0/0|0/4|0/0|10- (23:48:42:145)
You hold no "scimitarssss".
5720h, 4477m, 23400e, 17400w, 24% cexkdb|0/0|0/4|0/0|10- (23:48:42:146)
You hold no "scimitar36ssss".
5720h, 4477m, 23400e, 17400w, 24% cexkdb|0/0|0/4|0/0|10- (23:48:42:147)
You put an ornate steel rapier into a bag of stasis.
5720h, 4477m, 23400e, 17400w, 24% cexkdb|0/0|0/4|0/0|10- (23:48:42:148)
You hold no "rapiergggg".
5720h, 4477m, 23400e, 17400w, 24% cexkdb|0/0|0/4|0/0|10- (23:48:42:149)
You put an ornate steel rapier into a bag of stasis.
5720h, 4477m, 23400e, 17400w, 24% cexkdb|0/0|0/4|0/0|10- (23:48:42:150)
5720h, 4477m, 23400e, 17400w, 24% cexkdb|0/0|0/4|0/0|10- (23:48:42:151)
You hold no "battleaxe4gasga".
5720h, 4477m, 23400e, 17400w, 24% cexkdb|0/0|0/4|0/0|10- (23:48:42:152)
You hold no "battleaxesagsg".
5720h, 4477m, 23400e, 17400w, 24% cexkdb|0/0|0/4|0/0|10- (23:48:42:153)
You hold no "battleaxegsaga".
5720h, 4477m, 23400e, 17400w, 24% cexkdb|0/0|0/4|0/0|10- (23:48:42:154)
You take an ornate steel rapier marred with char marks from a bag of stasis.
5720h, 4477m, 23400e, 17400w, 24% cexkdb|0/0|0/4|0/0|10- (23:48:42:155)
You take an ornate steel rapier from a bag of stasis.
5720h, 4477m, 23400e, 17400w, 24% cexkdb|0/0|0/4|0/0|10- (23:48:42:156)
You begin to wield an ornate steel rapier marred with char marks in your left
hand.
5720h, 4477m, 23400e, 17400w, 24% cexkdb|0/0|0/4|0/0|10- (23:48:42:157)
You begin to wield an ornate steel rapier in your right hand.
5720h, 4477m, 23400e, 17400w, 24% cexkdb|0/0|0/4|0/0|10- (23:48:42:158)
You concentrate on gripping tightly with your hands.
5720h, 4477m, 23400e, 17400w, 24% cexkdb|0/0|0/4|0/0|10- (23:48:42:160)
You relax your grip.
5720h, 4477m, 23400e, 17400w, 24% cexkdb|0/0|0/4|0/0|10- (23:48:42:161)
You put an ornate steel rapier marred with char marks into a bag of stasis.
5720h, 4477m, 23400e, 17400w, 24% cexkdb|0/0|0/4|0/0|10- (23:48:42:163)
You put an ornate steel rapier into a bag of stasis.
5720h, 4477m, 23400e, 17400w, 24% cexkdb|0/0|0/4|0/0|10- (23:48:42:164)
You hold no "flailgaggag".
5720h, 4477m, 23400e, 17400w, 24% cexkdb|0/0|0/4|0/0|10- (23:48:42:165)
You concentrate on gripping tightly with your hands.
5720h, 4477m, 23400e, 17400w, 24% cexkdb|0/0|0/4|0/0|10- (23:48:42:357)
that's how much my screen is filled from one alias
So your alias is too generic? It wields things that aren't there?
A simple approach would be to make a list of things per set, simply as strings. One to equip, and one to remove. Then after the "remove" set you have nothing equipped, and you can equip a different lot.
eg.
equip_set1 = [[
get bow from bag4
wear bow
put battleaxe1 in loop1
put battleaxe2 in loop2
put battleaxe3 in loop3
put battleaxe4 in loop4
put battleaxe5 in loop5
get rapier1 from bag3
get rapier2 from bag3
wield left rapier1
wield right rapier2
grip
]]
remove_set1 = [[
relax grip
unwield left
unwield right
remove bow
put battleaxe1 in bag2
put battleaxe2 in bag2
put battleaxe3 in bag1
put battleaxe4 in bag2
put battleaxe5 in bag2
put rapier1 in bag3
put rapier2 in bag3
put bow in bag4
]]
You would have actual items here, not variables. So this is what you send to the MUD to get a particular set equipped or removed. Note the multi-line string variable in Lua.
So then the alias does something like this:
-- remove old set
if old_set then
Send (old_set) -- how to remove the last set I was wearing
end -- if
-- now wear this one
Send (equip_set2)
-- how to remove it later
old_set = remove_set2
The other thing you can do is make a table of sets. Something like this:
equip_set = {
[1] = [[ ... stuff to equip set 1 ... ]] ,
[2] = [[ ... stuff to equip set 2 ... ]] ,
[3] = [[ ... stuff to equip set 3 ... ]] ,
[4] = [[ ... stuff to equip set 4 ... ]] ,
}
remove_set = {
[1] = [[ ... stuff to remove set 1 ... ]] ,
[2] = [[ ... stuff to remove set 2 ... ]] ,
[3] = [[ ... stuff to remove set 3 ... ]] ,
[4] = [[ ... stuff to remove set 4 ... ]] ,
}
Now all you have to do is have an alias to "equip x" where x is a number (eg. 1, 2, 3, 4) and the alias indexes into those tables, pulling out the relevant things.
function unwieldWeapon(unwielded) -- inside aliases that need things unwielded
--Note(xbat[unwielded .. "hand"])
if xbat[unwielded .. "hand"] == "Dirk" then
Send("sheathe " .. DirkNumber)
elseif xbat[unwielded .. "hand"] == "Whip" then
Send("sheathe " .. WhipNumber)
elseif xbat[unwielded .. "hand"] == "Haxe" then
Send("sheathe " .. HaxeNumber)
elseif xbat[unwielded .. "hand"] == "Baxe" then
Send("sheathe " .. BaxeNumber)
elseif xbat[unwielded .. "hand"] == "SoA" then
Send("unwield " .. ShieldNumber)
else
Send("unwield " .. unwielded)
end
end
function sheathedWeapon(weapon) -- inside you sheathe trigger
if weapon == "Dirk" then
xbat.righthand = "nothing"
xbat.WeaponLoc.Dirk = "sheathed"
elseif weapon == "Whip" then
xbat.righthand = "nothing"
xbat.WeaponLoc.Whip = "sheathed"
elseif weapon == "Haxe" then
xbat.righthand = "nothing"
xbat.WeaponLoc.Hax = "sheathed"
elseif weapon == "Baxe" then
xbat.righthand = "nothing"
xbat.WeaponLoc.Baxe = "sheathed"
elseif weapon == "Bow" then
xbat.righthand = "nothing"
xbat.lefthand = "nothing"
elseif weapon == "SoA" then
xbat.lefthand = "nothing"
end
end
function Unwield(hand) -- inside unwield trigger(s).
if hand == "left" then
xbat.WeaponLoc[string.proper(xbat[hand .. "hand"])] = "inventory"
lefthand = "nothing"
elseif hand == "right" then
xbat.WeaponLoc[string.proper(xbat[hand .. "hand"])] = "inventory"
righthand = "nothing"
elseif hand == "both" then
xbat.WeaponLoc[string.proper(xbat.lefthand)] = "inventory"
lefthand = "nothing"
righthand = "nothing"
end
end
That's not quite what I suggested. If you give me a couple of full sets and the actual commands you use to equip and unequip them, I can try to do a better demonstration.
<aliases>
<alias
match="speed"
enabled="y"
expand_variables="y"
group="Weapons"
sequence="100"
>
<send>relax grip
unwield left <------------ Unequiping
unwield right <----------- Unequiping
put @broadsword1 in @bag2
put @broadsword2 in @bag2
put @totem1 in @bag1
put @scimitar1 in @bag2
put @scimitar2 in @bag2
put @rapier3 in @bag3
put @rapier4 in @bag3
wear @bow1
put @battleaxe1 in @loop1
put @battleaxe2 in @loop2
put @battleaxe3 in @loop3
put @battleaxe4 in @loop4
put @battleaxe5 in @loop5
get @rapier1 from @bag3
get @rapier2 from @bag3
wield left @rapier1 <--------- Equiping
wield right @rapier2 <-------- Equiping
grip
vconfig_weaponone 80
vconfig_weapontwo 84</send>
</alias>
</aliases>
----------------------------------------------
<aliases>
<alias
match="bash"
enabled="y"
expand_variables="y"
group="Weapons"
sequence="100"
>
<send>relax grip
unwield left <----------------- unequiping
unwield right <---------------- unequiping
put @broadsword1 in @bag2
put @broadsword2 in @bag2
put @battleaxe1 in @loop1
put @battleaxe2 in @loop2
put @battleaxe3 in @loop3
put @battleaxe4 in @loop4
put @battleaxe5 in @loop5
put @scimitar1 in @bag2
put @scimitar2 in @bag2
put @rapier1 in @bag3
put @rapier2 in @bag3
put @totem1 in @bag1
put @rapier3 in @bag3
put @rapier4 in @bag3
wear @bow1
draw @loop2 salute right
get @rapier1 from @bag3
wield right @battleaxe2 <-------- Equiping
wield left @rapier1 <------------ Equiping
grip</send>
</alias>
</aliases>
No weapons in Achaea have numbers in the single digits, so it's a pretty safe bet that that's what he intended. Some fighters carry a ton of weapons around. (And they decay, too, hence the need to be able to update your weapon variables.)
--put all the other gear away
for k,v in pairs(mygear) do
if k~=mysets[set].left and k~=mysets[set].right then
send("put "..v.name.." in "..v.container)
end
end
--take out the gear
local weaponone=mygear[mysets[set].left]
local weapontwo=mygear[mysets[set].right]
if weaponone~=nil then
send("take "..weaponone.name.." from "..weaponone.container)
send("wield "..weaponone.name.." left")
send("vconfig_weaponone "..weaponone.damage)
end
if weapontwo~=nil then
send("take "..weapontwo.name.." from "..weapontwo.container)
send("wield "..weapontwo.name.." right")
send("vconfig_weapontwo "..weapontwo.damage)
end
relax grip
unwield left
unwield right
put broadsword12345 in bag2345
put broadsword23456 in bag2345
put scimitar12345 in bag2345
put scimitar23456 in bag2345
put rapier12345 in bag3456
put rapier23456 in bag3456
put totem12345 in bag1234
put rapier34567 in bag3456
put rapier45678 in bag3456
put rapier56789 in bag3456
put battleaxe12345 in loop1234
put battleaxe23456 in loop2345
put battleaxe34567 in loop3456
wear bow12345
get scimitar1 from bag2
get scimitar2 from bag2
wield right scimitar23456
wield left scimitar12345
grip
vconfig_weaponone 120
vconfig_weapontwo 132
Thats the exact commands with the weapon and bag numbers masked for my protection.....
unwield left
unwield right
put broadsword12345 in bag2345
put broadsword23456 in bag2345
put scimitar12345 in bag2345
put scimitar23456 in bag2345
put rapier12345 in bag3456
put rapier23456 in bag3456
put totem12345 in bag1234
put rapier34567 in bag3456
put rapier45678 in bag3456
put rapier56789 in bag3456
But do you really remove all that? Or are you just putting every weapon away in the hope that one of them is there, and the others just give an error message?
Exactly. The thing with Achaea is that there are a great number of things that can cause you not to wield a weapon correctly. The same can be said for you not putting a weapon up as well. Basically I'm trying to make sure that everything is put away correctly ,and I have the weapons out that I want to have out at the time. And I also want to make sure that the ones I have out are wielded, so I do an alias like that to cover everything.