[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Using a stringlist

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Using a stringlist
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please).
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Pages: 1 2  

Posted by Deladan   (40 posts)  [Biography] bio
Date Thu 09 Sep 2010 02:27 AM (UTC)  quote  ]
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.
[Go to top] top

Posted by Nick Gammon   Australia  (18,800 posts)  [Biography] bio   Forum Administrator
Date Thu 09 Sep 2010 12:54 AM (UTC)  quote  ]
Message
OK, good. Now can you clarify something?

You have this for removing the old stuff, right?


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?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Deladan   (40 posts)  [Biography] bio
Date Wed 08 Sep 2010 10:16 PM (UTC)  quote  ]
Message
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.....
[Go to top] top

Posted by Nick Gammon   Australia  (18,800 posts)  [Biography] bio   Forum Administrator
Date Wed 08 Sep 2010 09:55 PM (UTC)  quote  ]

Amended on Wed 08 Sep 2010 09:56 PM (UTC) by Nick Gammon

Message
Deladan said:

Something like this ?



No.

Forget scripting. Forget aliases. Forget variables.

Just show me what you type to do stuff. Actually type into the MUD.

I can't help think this is getting more complicated than it needs to be, I want to see what problem we are solving, not the partial solution.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Deladan   (40 posts)  [Biography] bio
Date Wed 08 Sep 2010 09:46 PM (UTC)  quote  ]

Amended on Wed 08 Sep 2010 10:09 PM (UTC) by Deladan

Message
Something like this ?

mysets={
["speed"]={left="rapier 1",right="rapier 2"}, ["bow"]={left="bow 1",right=nil},
--etc.

}

mygear={
["rapier 1"]={
name="rapier110---",
damage=0,
container="bagXXXXX",
},
["rapier 2"]={
name="rapier3340---",
damage=0,
container="bagXXXXX",
},
["rapier 3"]={
name="rapier2492--",
damage=0,
container="bagXXXXX",
},
["rapier 4"]={
name="rapier289--",
damage=0,
container="bagXXXXX",
},
["scimitar 1"]={
name="scimitar30---",
damage=0,
container="bagXXXXX",
},
["scimitar 2"]={
name="scimitar360---",
damage=0,
container="bagXXXXX",
},
["flail 1"]={
name="flail106---",
damage=0,
container="bagXXXXX",
},
["broadsword 1"]={
name="broadsword142---",
damage=0,
container="bagXXXXX",
},
["bow 1"]={
name="bow410897",
damage=0,
container="bagXXXXX", },
}

pattern:
^wieldgear (\w+)$

script:

local set=matches[2]
if mysets[set]~=nil then

send("unwield left")
send("unwield right")

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

send("grip")

end
[Go to top] top

Posted by Nick Gammon   Australia  (18,800 posts)  [Biography] bio   Forum Administrator
Date Wed 08 Sep 2010 08:16 PM (UTC)  quote  ]
Message
What I'm asking here is for you to tell me what you would type into Achaea to equip one set, and then remove that set and equip another one.

Not using variables, not using aliases, just what you would actually type.

You can change the names a bit if you want to hide what you actually own.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Deladan   (40 posts)  [Biography] bio
Date Wed 08 Sep 2010 03:10 PM (UTC)  quote  ]
Message
and the @bag ones are my bags of stasis to reduce decay rate.
[Go to top] top

Posted by Twisol   USA  (2,230 posts)  [Biography] bio
Date Wed 08 Sep 2010 06:33 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Nick Gammon   Australia  (18,800 posts)  [Biography] bio   Forum Administrator
Date Wed 08 Sep 2010 05:05 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Deladan   (40 posts)  [Biography] bio
Date Wed 08 Sep 2010 03:18 AM (UTC)  quote  ]
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>

[Go to top] top

Posted by Nick Gammon   Australia  (18,800 posts)  [Biography] bio   Forum Administrator
Date Tue 07 Sep 2010 09:16 PM (UTC)  quote  ]
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
[Go to top] top

Posted by Dontarion   USA  (62 posts)  [Biography] bio
Date Tue 07 Sep 2010 03:20 PM (UTC)  quote  ]
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
[Go to top] top

Posted by Deladan   (40 posts)  [Biography] bio
Date Tue 07 Sep 2010 03:07 PM (UTC)  quote  ]
Message
So I'd be better of making a table of sets and then calling from the table to wield and put up.
[Go to top] top

Posted by Nick Gammon   Australia  (18,800 posts)  [Biography] bio   Forum Administrator
Date Tue 07 Sep 2010 04:55 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Nick Gammon   Australia  (18,800 posts)  [Biography] bio   Forum Administrator
Date Tue 07 Sep 2010 04:32 AM (UTC)  quote  ]

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
[Go to top] 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.


3,265 views.

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

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]