Small Coding Questions

12357

Comments

  • then I dont know what you two are doing as I followed the above step and my cmud one is working fine :/ .. @Moirean @Saybre‌ Sorry tried to help..
    Mudlet Bashing System for sale. Message if interested
  • Does table.index_of() actually work in Mudlet? It's on the wiki, but it keeps throwing me an error when I try to use it.

    Arbre-Today at 7:27 PM

    You're a vindictive lil unicorn
    ---------------------------

    Lartus-Today at 7:16 PM

    oh wait, toz is famous

    Karhast-Today at 7:01 PM

    You're a singularity of fucking awfulness Toz
    ---------------------------
    Didi's voice resonates across the land, "Yay tox."
    ---------------------------

    Ictinus11/01/2021

    Block Toz
    ---------------------------

    limToday at 10:38 PM


    you disgust me
    ---------------------------
    (Web): Bryn says, "Toz is why we can't have nice things."

  • Toz said:
    Does table.index_of() actually work in Mudlet? It's on the wiki, but it keeps throwing me an error when I try to use it.
    Seems to work for me; I'm using it in my next-aff picking script and not getting any errors. You sure you're using a simple indexed table? Please inspect the results of display(that_table) And maybe post the line (or a few lines) of the code where you are using it?
  • TozToz
    edited May 2014
    edit: Fixed, don't name your variable 'table'.

    Arbre-Today at 7:27 PM

    You're a vindictive lil unicorn
    ---------------------------

    Lartus-Today at 7:16 PM

    oh wait, toz is famous

    Karhast-Today at 7:01 PM

    You're a singularity of fucking awfulness Toz
    ---------------------------
    Didi's voice resonates across the land, "Yay tox."
    ---------------------------

    Ictinus11/01/2021

    Block Toz
    ---------------------------

    limToday at 10:38 PM


    you disgust me
    ---------------------------
    (Web): Bryn says, "Toz is why we can't have nice things."

    IshinOmeiAshmer
  • I use my own function for that sort of thing: --itable script itable = itable or {} function itable:remove(t,n) local temp = {} local n = tonumber(n) local newcount = 0 for num,val in ipairs(t) do if num ~= n then newcount = newcount + 1 temp[newcount] = val end end return temp end function itable:removeall(t,v) local temp = {} local newcount = 0 for _,val in ipairs(t) do if val ~= v then newcount = newcount + 1 temp[newcount] = val end end return temp end --[[ temptable = {"item1", "item2", "item3", "item2",} display(temptable) --temptable = itable:remove(temptable,2) temptable = itable:removeall(temptable,"item3") display(temptable) ]]--
  • LimLim
    edited May 2014
    Hi, I've been snooping around TW and found what I -think- is a half-alive auto-chameleon script.

    This:
    local cham_number = math.random(#tw.chamlist)

    send(tw.settings.defs.chameleon .. " " .. tw.chamlist[cham_number], false)
    send("touch chameleon", false)

    My question is: How do I populate tw.chamlist and have it cycle through it? I've tried

    local tw.chamlist = {
    "name1",
    "name2",
    }

    but that doesn't seem to work.


    Edit: Nevermind, I got it. Turns out lists have to be defined in scripts, not aliases.
  • ye @ Lim and dont use local, just put

    tw.chamlist = {"king", "bob", "batman"} .... and so on :P
    Mudlet Bashing System for sale. Message if interested
    Xenia
  • Okay, I'm Bob the Batman King now.
    KikonSheirosiaXenia
  • MoireanMoirean Chairmander Portland
    edited June 2014
    Running a script to math stuff and the numbers are weird. I put in some echoes to spit out each step and here's what I get:


    add: 47499
    47499
    add: 750
    48249
    add: 750
    48999
    add: 750
    49749
    add: 750
    50499
    add: 750
    51249
    add: 750
    51999
    add: 820
    52819
    add: 750
    53569
    add: 750
    54319
    add: 750
    55069
    add: 508
    55577
    add: 284
    55861
    add: 36
    55897
    add: 474
    56371
    add: 5 <-------- This is where stuff weirdly goes wrong.
    56371
    add: 447
    56371447
    add: 248
    56371447248
    add: 19
    5637144724819
    add: 24
    5637144724819
    add: 3751
    56371447248193751
    add: 198
    56371447248193751198
    add: 147
    56371447248193751198147
    Total:5.63714472481937529E22


    $sum=0
    #loo 1,%numitems(%1) {$sum=$sum+%eval(%1.%i);#say add: %1.%i;#say $sum}
    #return %ansi(grey)%format("&10.0n", $sum)

    Edit: It's just randomly dropping the value of one key from the dbvar sometimes. This is soooo weird. The variable itself still has all the values, it's just when I run it through the function it'll drop one of the values.

    Edit2: It has to do with the actual amount in the value. 1-9 it hates. It's cool with 10. 10 is a nice number. But no way to 11, 21, 22, 23 or 24.
  • It's been too long for me to really help.

    It looks like a type error, where it comes across a string instead of a number, and rather than returning an error, it concatenates instead of adding, which makes the whole thing a string.

    That said, try doing the adding within %eval:
    $sum = %eval($sum + %1.%i)

    Failing that, this may be a good one for the cmud forum, as it may be a genuine bug.


  • MoireanMoirean Chairmander Portland
    Yeah I think that might be what's going on. For now, I was able to workaround by just dropping the %eval and it adds fine, but then it does the same issue for OTHER strings. I think it may have to do with how the variable is created, so I'll play with trying to set the type more explicitly.
  • look into whether there is a zscript equivalent of lua's: tonumber(var)
  • SheirosiaSheirosia Sheffield, UK.
    Could also see if zscript can coerce a variable. Something like ("5" + 0) would hopefully coerce it into an integer.
  • From memory, which isn't great as it's been about 6 years now, %eval ought to achieve that coercing. It is the equivalent of the #math call, so nothing that happens inside it can be anything but a number.
  • RiluoRiluo The Doctor
    Hi guys I have been trying to track down a few lines for my system, but have meet an impasse with this set. Therefore is anyone willing to pm or post the trigger (affliction) lines, so I can begin adding them myself later.

    Pyrolum A simple resin that releases toxic fumes when burnt.
    Combust Instantly ignite resins in your presence.
    Corsin A heavy resin that barely burns, but hardens rapidly.
    Trientia A thin resin that ignites at a moment's notice.
    Harimel A slow-burning resin that sticks to the skin.
    Glauxe An adhesive resin that emits a thick smoke when burned.
    Badulem An unpredictable resin that mimics venoms.
    Lysirine A resin with a pleasant and sleep-inducing aroma.

    Abhorash says, "Ve'kahi has proved that even bastards can earn their place."

  • So I've been pondering over this for a while now, and it's probably a really easy solution I just can't see the answer.

    So I want to take and compare one table with another table. Now the first table will have 2 columns IE, affliction + true/false. The second table has nothing but one curing tree afflictions. Like all tree or all focus.

    How would I go about comparing the affliction from the first table with all of the afflictions in the second single table so I can set another variable.
    'Those that do not attempt are those with the least stories to tell.'
  • MoireanMoirean Chairmander Portland
    Depends what client you are on.
  • Oh crap, forgot that part. I'm using Mudlet.
    'Those that do not attempt are those with the least stories to tell.'
  • MoireanMoirean Chairmander Portland
  • ElyniElyni New Zealand
    edited August 2014
    Daegon said:

    So I've been pondering over this for a while now, and it's probably a really easy solution I just can't see the answer.

    So I want to take and compare one table with another table. Now the first table will have 2 columns IE, affliction + true/false. The second table has nothing but one curing tree afflictions. Like all tree or all focus.

    How would I go about comparing the affliction from the first table with all of the afflictions in the second single table so I can set another variable.

    if table1.stupidity == true and table.contains(table2, "stupidity") then
    send("whatever")
    do whatever
    end

    Like that?
  • NalorNalor UK
    edited August 2014
    Elyni said:

    Daegon said:

    So I've been pondering over this for a while now, and it's probably a really easy solution I just can't see the answer.

    So I want to take and compare one table with another table. Now the first table will have 2 columns IE, affliction + true/false. The second table has nothing but one curing tree afflictions. Like all tree or all focus.

    How would I go about comparing the affliction from the first table with all of the afflictions in the second single table so I can set another variable.

    if table1.stupidity == true and table.contains(table2, "stupidity") then
    send("whatever")
    do whatever
    end

    Like that?

    for aff, v in pairs(tabletwo) do -- being a list of affs like "stupidity", "paresis" etc

    if tableone[aff] then -- tableone being true.false table
    send("thisthatway")

    end
    end

    ^^ is for mudlet
    Mudlet Bashing System for sale. Message if interested
  • I tried yours Nalor. But I had to alter it. Cause I need to compare the true/false table with the other table. Not the other way around.

    So it would be something like this

    for aff,i in pairs(player.affs) do if i then if d.afftypes.focus[aff] then d.reclamation = d.reclamation + 1 end end end

    Now what I was hoping that would do is check the enemy affs, find out if the aff is true, then compare it with the focus list. If the player has the aff, and it is also a focus aff then it would add 1 point to reclamation variable.

    Though thinking on it I'd have to also add in a check so it's not comparing the same affliction every time so I don't get a false reading of something like 3 from one focus affliction being on there.

    But back to this problem. I tried this and it doesn't do anything at all.

    I don't know if it makes a difference but here's what the focus table looks like, and the player aff table.

    d.afftypes.focus = { "stupidity", "anorexia", "epilepsy", "mirroring", "paranoia", "hallucinations", "shyness", "stuttering", "dizziness", "indifference", "berserking", "pacifism", "loverseffect", "hatred", "generosity", "claustrophobia", "vertigo", "loneliness", "agoraphobia", "superstition", "masochism", "recklessness", "weariness", "impatience", "confusion", "dementia", "premonition", } player.affs(Has to be done via IG since there is no actual table, just adds and removes.) { insulation = true, rebounding = false, sileris = true }
    'Those that do not attempt are those with the least stories to tell.'
  • NalorNalor UK
    edited August 2014
    check your inbox @daegon Send you my script for what your after, its much easier
    Mudlet Bashing System for sale. Message if interested
  • In Mudlet, is there any way to accept input from a miniconsole/label other than clicking? Ideally, a little box blips up and has text boxes you can type stuff into.

    Arbre-Today at 7:27 PM

    You're a vindictive lil unicorn
    ---------------------------

    Lartus-Today at 7:16 PM

    oh wait, toz is famous

    Karhast-Today at 7:01 PM

    You're a singularity of fucking awfulness Toz
    ---------------------------
    Didi's voice resonates across the land, "Yay tox."
    ---------------------------

    Ictinus11/01/2021

    Block Toz
    ---------------------------

    limToday at 10:38 PM


    you disgust me
    ---------------------------
    (Web): Bryn says, "Toz is why we can't have nice things."

  • SetneSetne The Grand Tyrant
    Toz said:

    In Mudlet, is there any way to accept input from a miniconsole/label other than clicking? Ideally, a little box blips up and has text boxes you can type stuff into.

    Not really, no.

    Ingram said:
    "Oh my arms are suddenly lubed"
  • Hello, I'm trying to set up a key binding for my sdk ucp ucp combo, this is what I am using
    send("combo " .. target " sdk ucp ucp ")
    But it will not fire. Would someone be able to tell me what I am doing wrong?
    (I do have a targeting alias set up, it looks like this:
    ^t (\w+)$

    target = matches[2]:lower():title()
    cecho("\n\ntarget = " .. target)

    Just in case the problem might be in my targeting alias.
  • The problem is that you're not concatenating correctly.
    send("combo " .. target " sdk ucp ucp ")
    should be
    send("combo " .. target .. " sdk ucp ucp ")
    image
    RiluoHaven
  • Logically speaking. If I use table.concat to sort a table with \n to separate the values into their own lines. Shouldn't using echo in a geyser label then spit back out the new string, with the table values sorted properly? Instead I'm just getting the string sent back as if I never used table.concat- Except there are spaces between each value.
    'Those that do not attempt are those with the least stories to tell.'
  • CylanoCylano Phoenix, AZ
    Could you post the code you're using to do that? Could be a small syntax error.
  • Yeah, there are a few things that could be happening. We'd have to see your code.
Sign In or Register to comment.