Mudlet Scripting

2456717

Comments

  • JimeryJimery Member Posts: 41
    not of top of my head, as I not got a clue about Imperian and what it has in it, I just been told you can fish in it... I just thought people might have scripts which are not on them sites you mentioned..
  • DelrayneDelrayne Member Posts: 457 ✭✭✭
    I put a limb counter and a toxin preserver for mudlet on the IRE site. Outside of that, most things start to become to player specific to port around like that.

  • JimeryJimery Member Posts: 41
    I have a Mudlet Scripting question, its not about a script but more how to do a trigger..

    How would I trigger this as I haven't a clue on how to do the spacing..


    *********************************[ Pipe List ]*********************************
    Pipe                 Herb                 Puffs      Months Left    
    -------------------------------------------------------------------------------
    pipe223274           laurel               9          123
    pipe223809           (empty)              (none)     123
    pipe224302           lovage               1          123
    *******************************************************************************

  • LionasLionas Member, Historian Posts: 765 ✭✭✭✭✭
    edited April 2013
    Assuming you're using regex triggers, you can use \s+ to handle 1 or more spaces.

    ETA: http://www.cheatography.com/davechild/cheat-sheets/regular-expressions/
    I am the righteous one... 
    the claims are stated - it's the world I've created 
    Delrayne
  • DelrayneDelrayne Member Posts: 457 ✭✭✭
    Also you'll Have to escape the parenthesis with a backslash '\' since otherwise it will think of it as a matches group.

  • JimeryJimery Member Posts: 41
    Thanks, So what would you do about the (empty) and (none) ? it doesn't seem to be picking them up :/
  • DelrayneDelrayne Member Posts: 457 ✭✭✭
    (\(\w+\)) should capture either one of those.

  • JimeryJimery Member Posts: 41
    thank you :)
  • JimeryJimery Member Posts: 41
    This is more of a coding help then script but, others might be able to use it (if i can figure it out)

    for k,_ in pairs(Imperian.deflist) do

    if not k == stats.defences then

    echo(string.title(k) .. ", ")

    end

    end



    I want it to check a table of 'imperian.defences' with stats.defences. and if an imperian defences is not true on stats.defences (where I store my active defencces) for it to echo it its missing.. Would anyone know a way to get this to work? it doesn't bring back errors but, it also doesn't show...



  • EustoEusto Member, Moderator Posts: 123 mod
    I would be sure of two things:

    1) Make sure you're checking the Mudlet error console. By default, Mudlet does not echo its Lua errors to main window. This can make errors difficult to notice. Apologies if you already knew this.

    2) I would simplify your logic here. Your IF is most likely translating to IF !A == B, when you're trying to do something more like IF A != B. Lua's inequality operator is ~=, so I'd do:

    if k ~= stats.defences then

    That said, I'm not familiar with how you're handling defences. If the two tips above don't solve your woes, one would have to dig deeper into how you're storing information to better assist you in testing it properly.

    Hope that helps!
  • JimeryJimery Member Posts: 41
    well imperian.defences is just imperian.defenes {"deaf", }

    and stats.defenecs is deaf = true ...

    I checked all ways of finding errors its not finding none.. but so I guess its the coding which is wrong..
  • EustoEusto Member, Moderator Posts: 123 mod
    edited April 2013
    In your IF, you don't access a specific element of stats.defences, but rather the entire thing. If K is a key from your imperian.defences table ("deaf", "mass") but you check it against the stats.defences table itself, you'll never get equality.

    Assuming that stats.defences is set up in a DEFENCE=TRUE manner, like I think you said above, I'd do

    if not stats.defences[k] then

    That takes your defence name (k) and checks to see if stats.defences contains an entry for that defence.

    So if imperian.defences = {deaf = true, mass = true, insomnia = true}
    and stats.defences = {deaf = true, insomnia = true} then

    stats.defences[k] will be true where k = "deaf" and nil where k = "mass".
  • JimeryJimery Member Posts: 41
    edited April 2013
    from display(Imperian.defences) I get

    {
      "deaf",
      "batman"
    }

    from display(stats.defences) I get ..

    {
      insomnia = true,
      deaf = true,
      blind = true,
      bandages = true,
      caloric = true,
      levitation = true,
      mindseye = true,
      frost = true,
      fenugreek = true,
      mass = true,
      speed = true,
      immunity = true,
      quince = true,
      cloak = true
    }

    trigger is -

    for k,_ in pairs(Imperian.defence) do

    if not stats.defences[k] then

    echo(" " .. k)

    end

    end



    its showing. which seems funny..


    1 2





    I'm so much better at cmud then mudlet.. :/
    Orm
  • DelrayneDelrayne Member Posts: 457 ✭✭✭
    You need to change it from pairs to ipairs. Tables that are set up like so '{"bob", "John", "bill"} use ipairs. Tables that are set up like this '{"foo" = "bar", "apple" = "orange"} uses pairs. In other words use pairs when looping through key and value, use ipairs when looping through indexed values.

  • JimeryJimery Member Posts: 41
    ah, I fixed it. Thanks guys :)
  • JuranJuran OhioMember, Beta Testers Posts: 909 ✭✭✭✭✭
    You can use pairs for an indexed table, and I would unless you need them in order for some reason because it's (slightly) faster.
  • DelrayneDelrayne Member Posts: 457 ✭✭✭
    edited April 2013
    While script optimization is great and all, the .00001 of a second, if that, isn't going make a single difference. I have yet to hear of anyone bogging down mudlet to any varying degree. I'd prefer he follow standard coding methods, considering he's graduating from zscript.

    Not saying that people shouldn't optimize if they want. If you feel like you need to shave it down to a bare minimum then by all means go for it.

    Edit: and most indexed tables curing system wise are used for their specific order.

  • JimeryJimery Member Posts: 41
    well the code in question only gets fired when I use DEF.. so its not going to lag/mess mudlet up... plus it works now so.. dont want to break it :P
  • IniarIniar AustraliaMember Posts: 3,204 ✭✭✭✭✭
    edited April 2013
    Made a dirty multitarget system for the scriptless players among us

    multitarget mpackage

    It saves your targets between sessions (to \targets.lua)
    The alias "t <target>" assigns target to t1/t2/t3 up till targm defined in the script then cycles back down to t1
    The alias "t3 <target>" assigns target directly to t3, replacing the current contents
    The alias "t3" assigns the table value to your current variable
    You can modify colors/presentation of the echoes fairly easily up the top of the script.

    You can set high numbers for your favourite enemies and never worry about spelling their name again. 
    i.e. "t99 tsing" log off, go to work, sleep, eat, play, log on, "t99" -->> current target now tsing

    All you have to do is set the first of rendition.target in line 82 in the main script to your current variable and it should pass it on to your current system.
    i.e. MyTargetVariable = rendition.target

    Hope you find it useful
    wit beyond measure is a Sidhe's greatest treasure
  • DiceneDicene Member Posts: 913 ✭✭✭✭
    I'm playing with Mudlet a little bit and I'm trying to figure out how much better of a time I'll have with Tables than with Cmud's screwy DB module. Is there a built in way to sort simple lists, or will I have to find/write custom sort functions?
    image
  • IniarIniar AustraliaMember Posts: 3,204 ✭✭✭✭✭

    Mostly self-written.
    wit beyond measure is a Sidhe's greatest treasure
  • DiceneDicene Member Posts: 913 ✭✭✭✭
    Found out Mudlet has SQL database support. Now I just need to learn to SQL.
    image
  • IniarIniar AustraliaMember Posts: 3,204 ✭✭✭✭✭
    Hahaha *thumbsup. Teach me after. Kthx
    wit beyond measure is a Sidhe's greatest treasure
  • DiceneDicene Member Posts: 913 ✭✭✭✭
    Is there some hidden capability to save the profile from a script that I'm not seeing? This miserable laptop likes to die whenever the power cord is wiggled, and I would love to have a way to back everything up regularly so I don't lose stuff because I'm not pressing Save Profile often enough.
    image
  • DelrayneDelrayne Member Posts: 457 ✭✭✭
    I haven't been on to play, so I've sort of lost track of the mudlet community, but everyone who isn't a mudlet builder has been wanting a save profile function for as long as I can remember and they haven't implemented one that I'm aware of. I'm about six months behind though, so that isn't to say they haven't made one.

  • AkumuAkumu Member Posts: 21
    I hit "Save profile" basically every time I've made a change because it's hell making even small changes, have something go bad and lose that. Make it a habbit and then just delete the rather old profiles in your profile folder so it doesn't grow out of control.
  • DiceneDicene Member Posts: 913 ✭✭✭✭
    Yeah. I'm getting into the habit, just sucked when I didn't do that the first few times.
    image
  • DelrayneDelrayne Member Posts: 457 ✭✭✭
    If I'm not mistaken, newer versions of mudlet auto deletes profiles older than 30 days. If you don't feel like upgrading I'm sure the code for it is floating around on their forums somewhere.

  • IluvIluv Member Posts: 703 ✭✭✭✭
    Anyone having trouble with Mudlet Mapper and the Coliseum? My mapper just blanks when I enter it.
    image
  • LabilLabil Member Posts: 355 ✭✭✭
    Have you downloaded the new imperian.xml? Jeremy said that he worked a bit on the Coliseum.
Sign In or Register to comment.