Scripting for vibes

I have mudlet and svof, and I am a magi, of course, for background info.

I've been working on them for about two days now, trying to figure out how to do what... finally got enough down to get individual vibes down:

Pattern:^e (.+)$

local vibes={

dissipate="outr pentagon;spin pentagon;embed dissipate",

palpitation="outr cylinder;spin cylinder;embed palpitation",

heat="outr pyramid;spin pyramid;embed heat",

alarm="outr spiral;spin spiral;embed alarm",

tremors="outr disc;outr egg;spin disc;spin egg;embed tremors;inr disc",

reverberation="outr disc;outr pentagon;spin disc;spin pentagon;embed reverberation",

adduction="outr disc;outr polyhedron;spin disc;spin polyhedron;embed adduction",

harmonyheal="outr egg;outr sphere;spin egg;spin sphere;embead harmony;tune harmony healing",

harmonyrestoration="outr egg;outr sphere;spin egg;spin sphere;embead harmony;tune harmony restoration",

creeps="outr torus;spin torus;embed creeps",

silence="outr egg;spin egg;embed silence",

revelation="outr cube;outr diamond;embed revelation",

grounding="outr sphere;spin sphere;embed grounding",

oscillate="outr diamond;spin diamond;embed oscillate",

focus="outr pyramid;spin pyramid;embed focus",

disorentation="outr spiral;spin spiral;embed disorentation",

damage="outr pentagon;outr cylinder;spin pentagon;spin cylinder; embed dissipate;queue add eq embed palpitation",

}

if matches[2] then

send(vibes[matches[2]])

end

I have only scripted what I have up to at the moment. Wondering if there was an easier way to do this, or if this is genrally it?

I have dampen in a separate alias workup, generally the same as above, but shorter, again dampening individually.

Comments

  • I guess it depends what you're looking to do,  you could automate (gasp) all your vibes to be spun for you with a single alias, and having an alias to stop it for whatever reason, and utilise the trigger line of the vibe being embeded to enable to next vibration to be spun/embeded.


  • edited October 2016
    i had svof auto all my harmonics for me but then i realized usually i just wanted one or two harmonics for most rooms and situations, so i made aliases for each one and now i just use those aliases if i want all the harmonics in one room as well

    one suggestion is that you shorten the name for the vibe so e dissipate becomes e dis or whatever is easy for you to remember
    spread positivity
  • Aylek said:
    you could automate (gasp) all your vibes to be spun for you with a single alias
    That seems like a waste of crystals, but I could see how it may be useful..
    I mean I have already started to build the damage vibes into one summoning and working on affliction.
  • edited October 2016
    You've got a typo in the spelling of disorientation. Also, unless I'm mistaken, the lines should be more of:

      ["grounding"] = "outr sphere;spin sphere;embed grounding",


    since doing:

      grounding = "outr sphere;spin sphere;embed grounding",


    would be equivalent to setting:

      vibes[grounding] = "outr sphere;spin sphere;embed grounding",


    If you don't have a variable called grounding set up already, that should be throwing an error because vibes[nil] can't be assigned a value.


    Syntax/spelling aside, that seems to be a pretty efficient way to handle it, although since efficiency isn't really vital in an alias you're running at most a few times a second, you could change it to the following if you found that it improved readability for you:

    if matches[2]=="heat" then<br>&nbsp; send(<span>"outr pyramid;spin pyramid;embed heat")<br>elseif matches[2]=="</span><span>alarm" then<br>&nbsp; send("</span><span>outr spiral;spin spiral;embed alarm")<br>etc...</span>


    Not sure there is an objectively best way to do this particular task really.
  • No, the way she's doing it is fine.

    { star = "star" } is equivalent to { ["star"] = "star" }

    You can test it to see.
  • {["thing"] = thing} is only really needed for stuff that has multiple words, like limb counters for example:

    limbC = {["right leg"] = 6, ["right arm"] = 3, head = 0}

    etc. All function the same way, but now you can, for example have a trigger that does:
     You swing giant weapon at victim's right leg.
     You swing giant weapon at victim's head.
    Use a catch-all trigger of: ^You swing (.+) at \w+'s (.+).$
    Then rather searching the table, you can just do limbC[matches[3]] = limbC[matches[3]] + 1

  • Kaylalee said:
    Aylek said:
    you could automate (gasp) all your vibes to be spun for you with a single alias
    That seems like a waste of crystals, but I could see how it may be useful..
    I mean I have already started to build the damage vibes into one summoning and working on affliction.
    Oh I thought this was to put up all vibes when you log in then muffle them
  • edited October 2016
    Vessil said:
    Also, unless I'm mistaken, the lines should be more of:

    &nbsp; ["grounding"] = "outr sphere;spin sphere;embed grounding",


    since doing:

    &nbsp; grounding =&nbsp;"outr sphere;spin sphere;embed grounding",


    would be equivalent to setting:

    &nbsp; vibes[grounding] = "outr sphere;spin sphere;embed grounding",


    If you don't have a variable called grounding set up already, that should be throwing an error because vibes[nil] can't be assigned a value.
    You are mistaken. Doing {x = y} for a table initialiser isn't the same as doing tablename = {}; tablename[x] = y. The only time you need to use the {["x"] = y} syntax is when you're using a key that's not a valid identifier (e.g. it includes spaces, or is a Lua keyword such as for, if or while). Always using the {["x"] = y} syntax isn't necessarily a bad habit to get into if you're not aware of when it is and isn't required, and don't think you'll be able to remember, but the syntax they have is fine.

    I'm really, really not a fan of when people define tables inside an alias/trigger/etc. Initialising a table every single time you run the alias just seems wasteful; create a script object that initialises the table and actually stores it in memory, and use that every time. I'm also a fan of namespaces since they reduce the chances of conflicts with other people's scripts and their variables.

    I'd likely do something like this:
    vibes = vibes or {}
    
    vibes.crystals = vibes.crystals or {
    	dissipate = {"pentagon"},
    	adduction = {"disc", "polyhedron"},
    }
    
    vibes.shortnames = {
    	diss = "dissipate",
    	add = "adduction",
    	gr = "grounding"
    }
    
    vibes.embed = function(vibe)
    	local vibe = vibes.shortnames[vibe] or vibe
    	
    	local crystals = vibes.crystals[vibe]
    	
    	local commands = {}
    	
    	for _, crystal in ipairs(crystals) do
    		table.insert(commands, "outr " .. crystal)
    		table.insert(commands, "spin " .. crystal)
    	end
    	
    	table.insert(commands, "embed " .. vibe)
    	
    	send(table.concat(commands, ";")) -- I'd actually call a function to queue it here
    end
    

    Uses a namespace, keeps the list of crystals around (this is useful information for other things you might want to do, such as determining which vibe(s) an opponent Magi is embedding), and also allows mapping shortnames to full vibe names easily. Your alias would just have vibes.embed(matches[2]) as the code.

  • I can certainly work with that @Antonius

    though I'm trying to figure out if I can work with that on multiple step ones.. Like Harmony where it requires tuning:

    harmonyheal="outr egg;outr sphere;spin egg;spin sphere;embead harmony;tune harmony healing",

  • I have separate aliases for each vibe. My script for it (credit to Amranu) just calls a table for each function. I'll post it up later for you. Also, just make an alias to switch between healing and restoration
  • oh, alias, derp.

    Thank you :)
  • edited October 2016
    Having the ones added after not working for me now, unsure what I've done wrong,

    
    
    vibes = vibes or {}
    
    vibes.crystals = vibes.crystals or {
    	dissipate = {"pentagon"},
    	adduction = {"disc", "polyhedron"},
    	palpitation = {"cylinder"},
    	heat = {"pyramid"},
    	alarm = {"spiral"},
    	tremors = {"disc", "egg"},
    	reverberation = {"disc", "pentagon"},
    	harmony = {"egg", "sphere"},
    	creeps = {"torus"},
    	silence = {"egg"},
    	revelation = {"cube", "diamond"},
    	grounding = {"sphere"},
    	oscillate = {"diamond"},
    	focus = {"pyramid"},
    	disorientation = {"spiral"},
    
    }
    
    vibes.shortnames = {
    	diss = "dissipate",
    	add = "adduction",
        pal = "palpitation",
        he = "heat",
    	al = "alarm",
    	tr = "tremors",
    	reverb = "reverberation",
    	har = "harmony",
    	cre = "creeps",
    	sil = "silence",
    	gr = "grounding",
    	osc = "oscillate",
    	fo = "focus",
    	diso = "disorientation",
    
    }
    
    vibes.embed = function(vibe)
    	local vibe = vibes.shortnames[vibe] or vibe
    	
    	local crystals = vibes.crystals[vibe]
    	
    	local commands = {}
    	
    	for _, crystal in ipairs(crystals) do
    		table.insert(commands, "outr " .. crystal)
    		table.insert(commands, "spin " .. crystal)
    	end
    	
    	table.insert(commands, "embed " .. vibe)
    	
    	send(table.concat(commands, ";")) -- I'd actually call a function to queue it here
    end

  • saving profile and restarting mudlet was the answer.
  • @Kaylalee Oh, should probably explain the x = x or y syntax. If the variable x doesn't exist (i.e. is nil) then it will give it the value y, otherwise it will just be the existing value (x). That means that it will only initialise the table once, so any changes to the contents of the table in the script object after the first time that script executes won't be reflected until you restart Mudlet (or manually set x to nil, then save the script object again).
  • edited October 2016
    Here's my script:

    magi={}

    cmd_sep="|"

    function magi.embed(vibe, misc)

    local command = ""

    for i, crystal in ipairs(magi.crystals[vibe]) do

    command = command.."outr "..crystal..cmd_sep.."spin "..crystal..cmd_sep

    end

    if misc ~= nil and vibe == "sonicportal" then

    command = command.."embed "..vibe.." "..misc

    else

    command = command.."embed "..vibe

    end

    send("queue add eqbal stand"..cmd_sep..command)

    end

    magi.crystals = {

    ["dissipate"] = { "pentagon" },

    ["palpitation"] = { "cylinder" },

    ["heat"] = { "pyramid" },

    ["alarm"] = { "spiral" },

    ["tremors"] = { "disc", "egg" },

    ["reverberation"] = { "disc", "pentagon" },

    ["sonicportal"] = { "sphere", "torus" },

    ["adduction"] = { "disc", "polyhedron" },

    ["harmony"] = { "egg", "sphere" },

    ["creeps"] = { "torus" },

    ["silence"] = { "egg" },

    ["revelation"] = { "cube", "diamond" },

    ["grounding"] = { "sphere" },

    ["oscillate"] = { "diamond" },

    ["focus"] = { "pyramid" },

    ["energise"] = { "polyhedron"},

    ["stridulation"] = { "cylinder", "polyhedron" },

    ["gravity"] = { "egg", "torus" },

    ["forest"] = { "diamond", "pyramid" },

    ["dissonance"] = { "cylinder", "sphere", "spiral" },

    ["plague"] = { "cube", "pyramid", "spiral" },

    ["lullaby"] = { "pyramid" },

    ["retardation"] = { "disc" },

    ["disorientation"] = { "spiral" },

    ["forest"] = { "diamond", "pyramid" },

    }


Sign In or Register to comment.