Working with Multiple Variables

Post Reply
Unverganglich
Posts: 2
Joined: Fri Jul 22, 2016 9:25 pm

Working with Multiple Variables

Post by Unverganglich »

I'm playing a MUD where commodities have a short name such as "iron" and a long name such as "an iron ore". You can get these from infiltrating legions, and I have a basic alias/trigger combo set up to do this, but I have to manually change the commodity type in the trigger, which I'd rather streamline.

I don't know the best way to do this, maybe a variable table? I'm a newcommer to Mudlet and don't really know much about scripting, but if anyone has any ideas or can help that'd be great.

Here's what I have so far. The bolded parts are an example of the variance between the commodity/item labels. I'd like to somehow be able to set the commodity longname to a variable which can be used alongside the shortname, something where "some refined spice" and "spice" are equivalent and interchangeable?

Alias: ^i (dye|wood|salt|gold|silver|wool|iron|tin|bronze|marble|gem|leather|silk|flint|rope|yarriol|spice)$

send("infiltrate "..t.." "..matches[2] )
echo("Infiltrating for: "..matches[2])

Trigger: Your infiltration of the corps "(.*)" is successful and you pilfer some refined spice

send("open pack ")
send("put spice in pack ")
send("close pack ")
send("infiltrate "..t.." spice ")
send("who ")

azure_glass
Posts: 97
Joined: Wed Jul 25, 2012 12:35 pm

Re: Working with Multiple Variables

Post by azure_glass »

(^(|> )Trigger: Your infiltration of the corps "(.*)" is successful and you pilfer some (refinded|unrefined) (.*)$)

send("open pack ")
send("put "..matches[6].." in pack ")
send("close pack ")
send("infiltrate "..matches[6])
send("who ")
cecho("\n<red>"..matches[6])
English is not my native language. If you don't understand what im writing ask. :)
Ubuntu 17.04, Mudlet 3.1

Unverganglich
Posts: 2
Joined: Fri Jul 22, 2016 9:25 pm

Re: Working with Multiple Variables

Post by Unverganglich »

This doesn't work, I'm assuming because of the inability to use the various item long names and item tags interchangeably.

Example:

iron = some iron ore
wax = some wax
flint = a flint stone

And many more. I'm trying to figure out a way that will allow the trigger to recognize the long name and perform the action using the short name.

azure_glass
Posts: 97
Joined: Wed Jul 25, 2012 12:35 pm

Re: Working with Multiple Variables

Post by azure_glass »

(^(|> )Trigger: Your infiltration of the corps "(.*)" is successful and you pilfer (.*)\.$)


if matches[5] == "some iron ore" then ResourcesVariable = "iron ore" end
if matches[5] == "some wax" then ResourcesVariable = "wax" end
if matches[5] == "a flint stone" then ResourcesVariable = "flint" end

send("open pack ")
send("put "..ResourcesVariable.." in pack ")
send("close pack ")
send("infiltrate "..ResourcesVariable)
send("who ")
cecho("\n<red>"..matches[5])
English is not my native language. If you don't understand what im writing ask. :)
Ubuntu 17.04, Mudlet 3.1

Drevarr
Posts: 43
Joined: Tue Aug 06, 2013 12:07 am
Location: GA, USA

Re: Working with Multiple Variables

Post by Drevarr »

You could use a table with the long description as keys.
Code: [show] | [select all] lua
InfTable = {
	["some mineral dust"] = "Stone",
	["a small chunk of stone"] = "Stone",
	["a large, polished stone"] = "Stone",
	["a small piece of meteorite"] = "Stone",
	["a tiny shard of volcanic rock"] = "Stone",
	["a bent adamantium scrap"] = "Adamantium",
	["a small piece of adamantium"] = "Adamantium",
	["a large adamantium fragment"] = "Adamantium",
	["a small chunk of pure adamantium"] = "Adamantium",
	["some ancient adamanntium"] = "Adamantium",
	["some star dust"] = "Dust",
	["some interplanetary dust"] = "Dust",
	["some intergalactic dust"] = "Dust",
	["a clump of cosmic plasma"] = "Dust",
	["an anti-matter nebula"] = "Dust",
	["a bent iron scrap"] = "Iron",
	["a small piece of iron"] = "Iron",
	["a large iron fragment"] = "Iron",
	["some tempered iron"] = "Iron",
	["a rare piece of cold-iron"] = "Iron",
	["a piece of a bone fragment"] = "Bone",
	["a large piece of bone"] = "Bone",
	["a thick chunk of strong bone"] = "Bone",
	["a sparkling bone fragment"] = "Bone",
	["a piece of immortal bone"] = "Bone"
}
Code: [show] | [select all] lua
ResourcesVariable = InfTable[matches[5]]
send("put "..ResourcesVariable.." in pack ")
...

Post Reply