Rauros2008-05-28 19:21:48
I'm trying to add some simple aliases, and I need some help. I've add this code to the .LUA file, uploaded it into MUSHclient, and it returns an error when I try to run the alias.
I haven't added anything else at all, just these lines.
When I try to input "ATAR 11111", it returns this:
CODE
angel="archangel"
AliasFuncTable = {
  F_ak          = "ak",      -- order angel kill target
  F_atar        = "atar",    -- angel target
  --(deleted remaining table)
}
-- order angel kill target
function F_ak (thename, theoutput, wildcards, line)
    Send("order "..angel.." kill "..target)
end
-- sets angel variable
function F_atar (thename, theoutput, wildcards)
    angel=wildcards
    Send ("settarget angel "..wildcards)
end
AliasFuncTable = {
  F_ak          = "ak",      -- order angel kill target
  F_atar        = "atar",    -- angel target
  --(deleted remaining table)
}
-- order angel kill target
function F_ak (thename, theoutput, wildcards, line)
    Send("order "..angel.." kill "..target)
end
-- sets angel variable
function F_atar (thename, theoutput, wildcards)
    angel=wildcards
    Send ("settarget angel "..wildcards)
end
I haven't added anything else at all, just these lines.
When I try to input "ATAR 11111", it returns this:
QUOTE
atar 11111
I don't quite catch your drift.
When I try using "ATAR" by itself, it returns this:I don't quite catch your drift.
QUOTE
:6182: attempt to concatenate global 'angel' (a nil value)
stack traceback:
:6182: in function <:6181>
Called by:
Function/Sub: F_ak called by alias
Reason: processing alias ""
stack traceback:
:6182: in function <:6181>
Called by:
Function/Sub: F_ak called by alias
Reason: processing alias ""
Unknown2008-05-28 19:43:51
Aliases go in your world file. They can call Lua script functions, but you're trying to use Lua functions as aliases directly, and it doesn't work that way.
Rauros2008-05-28 19:46:09
QUOTE(Zarquan @ May 28 2008, 03:43 PM) 516234
Aliases go in your world file. They can call Lua script functions, but you're trying to use Lua functions as aliases directly, and it doesn't work that way.
Where do I find that? The only file I've loaded into MUSHclient is the nezhmet.lua file.
Rauros2008-05-29 00:43:23
I'm trying to find the answer to this question, but the Mush Help files aren't helping. It seems the help files aren't the same language as Nezha's system (coded in Lua). So I'm lost where to find answers to questions when I need to find something.
Add: Is there a way to #gag in Lua? #sub? #alarm? How do I make a timer (to time angel hits, for example)?
Add: Is there a way to #gag in Lua? #sub? #alarm? How do I make a timer (to time angel hits, for example)?
Nezha2008-05-29 01:33:16
alright, I usually dont do this, but just because you seem to be in so much trouble:
Commands:
Edit: there is a way to gag in lua, but i got too lazy about it.. and go look at the codes in my system. the answer to most of your questions are actually in there..
QUOTE
angel="archangel"
AliasFuncTable = {
F_atar = "atar *", -- you need * so you can get a wildcard. i.e. atar 1111
}
-- sets angel variable
function F_atar (thename, theoutput, wildcards)
angel=wildcards -- This will be what we are talking about, before this returns nil as the wildcard is not captured. Hence you get the error.
Send ("settarget angel "..wildcards)
end
AliasFuncTable = {
F_atar = "atar *", -- you need * so you can get a wildcard. i.e. atar 1111
}
-- sets angel variable
function F_atar (thename, theoutput, wildcards)
angel=wildcards -- This will be what we are talking about, before this returns nil as the wildcard is not captured. Hence you get the error.
Send ("settarget angel "..wildcards)
end
Commands:
QUOTE
# atar -- Will invoke "atar" which you previously have
# atar 11111 -- Will invoke "atar *" which you will have if you do that code above
# atar 11111 -- Will invoke "atar *" which you will have if you do that code above
Edit: there is a way to gag in lua, but i got too lazy about it.. and go look at the codes in my system. the answer to most of your questions are actually in there..
Rauros2008-05-29 01:35:03
QUOTE(nezha @ May 28 2008, 09:33 PM) 516322
alright, I usually dont do this, but just because you seem to be in so much trouble:
Commands:
Commands:
Thanks. Put the asterisk in there and works now. I shoulda realized I could have looked at the "tar" function and seen the way it was done.
Rauros2008-05-29 22:38:17
Me again.
I'm attempting to add some absolve code to the nezhmet.lua file, and getting absolutely nowhere.
What I'm trying to do:
1) I type into mush the command ABS
2) sends "CONTEMPLATE "..target , and sets the variable absolve=1
3) triggers off "mana stands at (\\d+)/(\\d+)" and
4) saves variables currentmana=%1 and maxmana=%2
5) checks if target is at below 50% mana
6) if above, chants amissio
7) if below, calls absolve
I just need to know what code I need to copy/paste into the .lua file so that it will allow me to just type in abs and run those steps. I've tried everything I can think of, but I can't figure it out. I can't figure out how to get the LUA script to create a trigger off step 3). Also, I can't figure out how to get MUSHclient to do LUA functions. I had a trigger in MUSHclient set up to send an alias set up with LUA but it doesn't do anything at all.
All I'm missing is the trigger, which I haven't been able to figure out how to make with LUA code. I tried creating a trigger manually with MUSHclient, but didn't work. Oddly enough, if I manually type in the functions, it will run them, but the trigger won't.
This is what I want the trigger to do:
I'm attempting to add some absolve code to the nezhmet.lua file, and getting absolutely nowhere.
What I'm trying to do:
1) I type into mush the command ABS
2) sends "CONTEMPLATE "..target , and sets the variable absolve=1
3) triggers off "mana stands at (\\d+)/(\\d+)" and
4) saves variables currentmana=%1 and maxmana=%2
5) checks if target is at below 50% mana
6) if above, chants amissio
7) if below, calls absolve
I just need to know what code I need to copy/paste into the .lua file so that it will allow me to just type in abs and run those steps. I've tried everything I can think of, but I can't figure it out. I can't figure out how to get the LUA script to create a trigger off step 3). Also, I can't figure out how to get MUSHclient to do LUA functions. I had a trigger in MUSHclient set up to send an alias set up with LUA but it doesn't do anything at all.
CODE
absolve ={
    tcurm=1,
    tmaxm=1,
    mperc=100,
    absolve="on"
}
-- absolve
function F_abs (thename, theoutput, wildcards, line)
    absolve.absolve=on
    Send ("discern "..target)
end
-- sets tcurm
function F_abssetc (thename, theoutput, wildcards, line)
    absolve.tcurm=wildcards
end
-- sets tmaxm
function F_abssetm (thename, theoutput, wildcards, line)
    absolve.tmaxm=wildcards
end
-- absolve check
function F_abschk (thename, theoutput, wildcards, line)
    absolve.mperc=(absolve.tcurm * 100 )/absolve.tmaxm
    Note ("//___Mana percent="..absolve.mperc.."%___\\\\\\\\")
    Note ("\\\\\\\\  Mana percent="..absolve.mperc.."%  //")
    if absolve.absolve == "on" then
        if absolve.mperc<50 then
              Send ("starcall absolve "..target)
        else
        Send ("chant amissio "..target)
        end
    end
    absolve.absolve="off"
end
    tcurm=1,
    tmaxm=1,
    mperc=100,
    absolve="on"
}
-- absolve
function F_abs (thename, theoutput, wildcards, line)
    absolve.absolve=on
    Send ("discern "..target)
end
-- sets tcurm
function F_abssetc (thename, theoutput, wildcards, line)
    absolve.tcurm=wildcards
end
-- sets tmaxm
function F_abssetm (thename, theoutput, wildcards, line)
    absolve.tmaxm=wildcards
end
-- absolve check
function F_abschk (thename, theoutput, wildcards, line)
    absolve.mperc=(absolve.tcurm * 100 )/absolve.tmaxm
    Note ("//___Mana percent="..absolve.mperc.."%___\\\\\\\\")
    Note ("\\\\\\\\  Mana percent="..absolve.mperc.."%  //")
    if absolve.absolve == "on" then
        if absolve.mperc<50 then
              Send ("starcall absolve "..target)
        else
        Send ("chant amissio "..target)
        end
    end
    absolve.absolve="off"
end
All I'm missing is the trigger, which I haven't been able to figure out how to make with LUA code. I tried creating a trigger manually with MUSHclient, but didn't work. Oddly enough, if I manually type in the functions, it will run them, but the trigger won't.
This is what I want the trigger to do:
CODE
match: "mana stands at (\\d+)/(\\d+)"
do: abssetc %1
    abssetm %2
    abschk
do: abssetc %1
    abssetm %2
    abschk