Someone gave me this script to convert to Mush, said it was mostly Lua so that it wouldn't be to difficult. I think I understand, just have never done IF before. S1 is variable for one sword, S2 for the second. Trying to get something together that will allow me to be able to quickly set up venom combos on the fly. Any and all help is appreciated. Thanks in advance.
Mudlet - Mush converting
Posted by Kresslack on Thu 21 Jan 2010 11:25 PM — 6 posts, 25,956 views.
Hullos, Kresslack! Good to see you, but it might be helpful if you could post some/all of the code Vadi gave you for everyone else here to reference - either as a link, or pasted directly with [code] tags, please.
As for 'if' statements, that's basic Lua - you might want to look at the online (free) Programming in Lua book if you plan on doing much scripting: http://www.lua.org/pil/
As for 'if' statements, that's basic Lua - you might want to look at the online (free) Programming in Lua book if you plan on doing much scripting: http://www.lua.org/pil/
Ah yes, terribly sorry about that. I'm doing about 50 things at once it seems and forgetting things.
http://pastebin.com/m2611f949
http://pastebin.com/m2611f949
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE MudletPackage (View Source for full doctype...)>
- <MudletPackage version="1.0">
<TriggerPackage />
- <AliasPackage>
- <AliasGroup isActive="yes" isFolder="yes">
<name>Offensive</name>
<script />
<command />
<regex />
- <Alias isActive="yes" isFolder="no">
<name>envenom</name>
<script>-- first sword for alias,name in pairs(venoms) do if (alias == matches[2]) then envenom(s1, name) end if (alias == matches[3]) then envenom(s2, name) end end</script>
<command />
<regex>^e(\w{1})(\w{1})$</regex>
</Alias>
</AliasGroup>
</AliasPackage>
<ActionPackage />
- <ScriptPackage>
- <ScriptGroup isActive="yes" isFolder="yes">
<name>General</name>
<script>------------------------------------------------- -- Put your Lua functions here. -- -- -- -- Note that you can also use external Scripts -- -------------------------------------------------</script>
<eventHandlerList />
- <Script isActive="yes" isFolder="no">
<name>SETTINGS</name>
<script>s1 = "sword#####" s2 = "sword#####" -- venom mappings venoms = {} venoms.a = "aconite" venoms.c = "curare" venoms.d = "delphinium" venoms.x = "xentio" venoms.k = "kalmia" venoms.g = "gecko" venoms.i = "slike" venoms.t = "epteth" -- arms venoms.s = "epseth" -- legs venoms.v = "vernalius" venoms.g = "digitalis" venoms.m = "monkshood"</script>
<eventHandlerList />
</Script>
- <Script isActive="yes" isFolder="no">
<name>envenom</name>
<script>function envenom (rapier, venom) if rapier == nil or venom == nil then return end send ("envenom " .. rapier .. " with " .. venom) end</script>
<eventHandlerList />
</Script>
</ScriptGroup>
</ScriptPackage>
</MudletPackage>
You seem to have lost the line breaks that must be in the original. Something like:
must really be:
It won't be too hard, but a basic knowledge of Lua would help.
The first thing is, the Mudlet author has used a similar style to MUSHclient, but not identical. For example, something like:
would become, in MUSHclient:
Similar-looking, but as you can see quite a bit different, too.
You would probably want to automate the conversion, and if you aren't familiar with scripting, this could be tedious.
Then there the script itself. Certainly they both use Lua, but it is like trying to convert zMud Lua to MUSHclient (or vice-versa). Lua is the structure, but what "makes things happen" is the functions provided by the client.
For example, in MUSHclient, to send stuff to the MUD you use:
Now in Mudlet it might be:
Without reading their documentation, I can't say.
-- first sword for alias,name in pairs(venoms) do if
must really be:
-- first sword
for alias,name in pairs(venoms) do
if
Kresslack said:
Someone gave me this script to convert to Mush, said it was mostly Lua so that it wouldn't be to difficult. I think I understand, just have never done IF before.
Someone gave me this script to convert to Mush, said it was mostly Lua so that it wouldn't be to difficult. I think I understand, just have never done IF before.
It won't be too hard, but a basic knowledge of Lua would help.
The first thing is, the Mudlet author has used a similar style to MUSHclient, but not identical. For example, something like:
<AliasPackage>
<Alias isActive="yes" isFolder="no">
<name>envenom</name>
<script>-- script here</script>
<command />
<regex>^e(\w{1})(\w{1})$</regex>
</Alias>
</AliasPackage>
would become, in MUSHclient:
<aliases>
<alias
enabled="y"
name="envenom"
send_to="12"
match="^e(\w{1})(\w{1})$"
>
<send>-- script here</send>
</alias>
</aliases>
Similar-looking, but as you can see quite a bit different, too.
You would probably want to automate the conversion, and if you aren't familiar with scripting, this could be tedious.
Then there the script itself. Certainly they both use Lua, but it is like trying to convert zMud Lua to MUSHclient (or vice-versa). Lua is the structure, but what "makes things happen" is the functions provided by the client.
For example, in MUSHclient, to send stuff to the MUD you use:
Send ("inventory")
Now in Mudlet it might be:
send ("inventory")
-- or:
output ("inventory")
-- or:
mud:send ("inventory")
Without reading their documentation, I can't say.
I can see what you're talking about such as Active on Mudlet being Enabled on Mush. On the lower part, are these things case sensitive? The Mush one was Send "inventory" and the mudlet was just send "inventory".
In Lua, functions are case-sensitive, yes. Mudlet named their send-ing functions differently, even though it's just a difference in capitalization.