Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ Using a stringlist

Using a stringlist

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1 2  

Posted by Deladan   (40 posts)  Bio
Date Mon 06 Sep 2010 10:05 PM (UTC)

Amended on Mon 06 Sep 2010 10:07 PM (UTC) by Deladan

Message
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>
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #1 on Mon 06 Sep 2010 10:07 PM (UTC)
Message
Hullos Deladan!

Could you post what you have currently for us?

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Deladan   (40 posts)  Bio
Date Reply #2 on Mon 06 Sep 2010 10:10 PM (UTC)
Message
Yeah I thought about that after I'd already saved the message hopefully the edit will help clear up things some
Top

Posted by Deladan   (40 posts)  Bio
Date Reply #3 on Mon 06 Sep 2010 10:12 PM (UTC)
Message
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 :(
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #4 on Tue 07 Sep 2010 03:10 AM (UTC)
Message
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?

eg.

green sword -> left hand
blue sword -> right hand

That sort of thing?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Deladan   (40 posts)  Bio
Date Reply #5 on Tue 07 Sep 2010 03:21 AM (UTC)

Amended on Tue 07 Sep 2010 03:25 AM (UTC) by Deladan

Message
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.
Top

Posted by Deladan   (40 posts)  Bio
Date Reply #6 on Tue 07 Sep 2010 03:53 AM (UTC)
Message
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
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #7 on Tue 07 Sep 2010 04:32 AM (UTC)

Amended on Tue 07 Sep 2010 04:36 AM (UTC) by Nick Gammon

Message
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



[EDIT] Edited to make it more consistent.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #8 on Tue 07 Sep 2010 04:55 AM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Deladan   (40 posts)  Bio
Date Reply #9 on Tue 07 Sep 2010 03:07 PM (UTC)
Message
So I'd be better of making a table of sets and then calling from the table to wield and put up.
Top

Posted by Dontarion   USA  (62 posts)  Bio
Date Reply #10 on Tue 07 Sep 2010 03:20 PM (UTC)
Message
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
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #11 on Tue 07 Sep 2010 09:16 PM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Deladan   (40 posts)  Bio
Date Reply #12 on Wed 08 Sep 2010 03:18 AM (UTC)
Message
<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>

Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #13 on Wed 08 Sep 2010 05:05 AM (UTC)
Message
Unless I am misunderstanding what you are doing, these are variables:


put @broadsword1 in @bag2
put @broadsword2 in @bag2
put @totem1 in @bag1


Since you put @ there, it tries to find a variable called @broadsword1 - is that what you intend?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #14 on Wed 08 Sep 2010 06:33 AM (UTC)
Message
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.)

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


72,562 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.