Welcome to the Achaea Forums! Please be sure to read the Forum Rules.
Quick Coding Questions
Comments
-
Keep track of the size of the table of emotes. When you randomly select an emote from the table, move that emote to the last slot of the table and reduce your table size by one.
Example:- You have a table A B C D E. Size of 5.
- You select a random number 1 through 5, you get 3.
- You use C and then you move C to the end of the table, so it is now A B D E C. Record the table size as 4.
- Now you select a number 1 through 4. You get 3 again, which is D
- Use D, and move it to the end of the table. A B E C D. Table size 3.
- Random number between 1 and 3, etc, etc.
Here's some code that uses the same principles: https://repl.it/repls/SameGruesomeLamp<div>t = {"run", "hop", "dance", "skip", "leap", "bounce", "hug", "frolic", "potato", "tomato", "boom"} <span>tsize = #t </span>print(table.concat(t, ','<span>)) </span>for i = tsize, 1, -<span>1 </span> <span>do </span><span> rn = math.random(tsize) </span><span> print(t[rn]) </span><span> table.insert(t, tsize, table.remove(t,rn)) </span> tsize = tsize -<span>1 </span> end</div>
1 -
Thank you guys so much! With your help, and some additional digging, I got everything up and running. I AM SO EXCITED!!
0 -
Pyori said:
The way that works is that it'll continuously create a random number, until it meets a value that hasn't been used yet (isn't in the usedEmotes table). Once it does, it breaks the 'while' loop, and sends it, then adds that emote to the usedEmotes table until you reset it. The first one is probably the easiest.emoteTable = { "hi", "wavehi", "hello", "greet", "smile" }<br>usedEmotes = {}<br><br>--Separate alias for sending the emote itself.<br>emoteSend = false<br>while emoteSend == false do<br> emNum = math.random(1, #emoteTable)<br> if not table.contains(usedEmotes, emoteTable[emNum]) then<br> emoteSend = emoteTable[emNum]<br> end<br>end<br><br>table.insert(usedEmotes, emoteSend)<br>send(emoteSend, false)<br>
--Initialise the tables here; again, have something to revert back to this state.<br>
0 -
Antonius said:Pyori said:
The way that works is that it'll continuously create a random number, until it meets a value that hasn't been used yet (isn't in the usedEmotes table). Once it does, it breaks the 'while' loop, and sends it, then adds that emote to the usedEmotes table until you reset it. The first one is probably the easiest.emoteTable = { "hi", "wavehi", "hello", "greet", "smile" }<br>usedEmotes = {}<br><br>--Separate alias for sending the emote itself.<br>emoteSend = false<br>while emoteSend == false do<br> emNum = math.random(1, #emoteTable)<br> if not table.contains(usedEmotes, emoteTable[emNum]) then<br> emoteSend = emoteTable[emNum]<br> end<br>end<br><br>table.insert(usedEmotes, emoteSend)<br>send(emoteSend, false)<br>
--Initialise the tables here; again, have something to revert back to this state.<br>
0 -
So I'm trying to use the gmcp.Comm dealio for a chat capture script and I figured out how to convert the ANSI data, but I can't figure out how to strip out the backslashes. I don't want to do a general replace in the event that someone, for some reason, uses backslashes in speech, but leaving them in is annoying. Anyone know how I can accomplish this?text = "[0;1;32m(Market): Kriex says, \"Also buying a winductter!\"[0;37m",
0 -
IMO, regardless of the whole variable retyping issue, it's bad form to suggest the "keep track of your random numbers and keep randoming until you get one you haven't gotten yet" method of random selection. It's hugely inefficient and subject to massive RNG tailing problems, and you're better off implementing another solution.
1 -
I've recently returned after a three year hiatus, and in the time away have forgotten the little bit of coding knowledge I had gained before... But what I'm basically trying to do is make a script to pick two random limbs, and also add in the ability to expend or not.
Something like: doublewhirl (target) (limb1) (limb2) (expend)
I know it requires tables of some sort, and that the alias should look something like ^d(\w)(\w)(\w)$
but beyond that, I'm at a loss.0 -
Ivis said:I've recently returned after a three year hiatus, and in the time away have forgotten the little bit of coding knowledge I had gained before... But what I'm basically trying to do is make a script to pick two random limbs, and also add in the ability to expend or not.
Something like: doublewhirl (target) (limb1) (limb2) (expend)
I know it requires tables of some sort, and that the alias should look something like ^d(\w)(\w)(\w)$
but beyond that, I'm at a loss.
I'm kind of confused. Do you want it to pick random limbs, or do you want to be able to specify limbs. You say random, but then your alias makes it seem like it should be specified.
Also, mudlet?0 -
He/She can do both. something like "if matches[3] == "" and matches[4] == "" then <random> else <not random>.And you probably don't need the mention of target in there since it is kind of a given and would require less typing in a fight.And to make it random, you really only need the expend option.Something like ^dw(?: |e)$
local commands = {"hi", "wave", "bye"} local which = math.random(#commands) send(commands[which])
You'd need to iterate over it a couple times filling in gaps. I use something similar where if one variable is empty, it fills it. If it isn't, it moves to the next, then executes the command.Then add something like if matches[2] == "e" then <append the expend command>0 -
Thaisen said:Ivis said:I've recently returned after a three year hiatus, and in the time away have forgotten the little bit of coding knowledge I had gained before... But what I'm basically trying to do is make a script to pick two random limbs, and also add in the ability to expend or not.
Something like: doublewhirl (target) (limb1) (limb2) (expend)
I know it requires tables of some sort, and that the alias should look something like ^d(\w)(\w)(\w)$
but beyond that, I'm at a loss.
I'm kind of confused. Do you want it to pick random limbs, or do you want to be able to specify limbs. You say random, but then your alias makes it seem like it should be specified.
Also, mudlet?
I'm unsure of how to form the tables for those specific limbs.Caelan said:He/She can do both. something like "if matches[3] == "" and matches[4] == "" then <random> else <not random>.And you probably don't need the mention of target in there since it is kind of a given and would require less typing in a fight.And to make it random, you really only need the expend option.Something like ^dw(?: |e)$local commands = {"hi", "wave", "bye"} local which = math.random(#commands) send(commands[which])
You'd need to iterate over it a couple times filling in gaps. I use something similar where if one variable is empty, it fills it. If it isn't, it moves to the next, then executes the command.Then add something like if matches[2] == "e" then <append the expend command>
local commands = {"head", "torso", "right arm", "left arm", "right leg", "left leg"}
local which = math.random(#commands)
send("doublewhirl "..target..[which])
??
I'm not really sure of any of this, so I apologize if I'm butchering your suggestions.0 -
<div>local limbs = {"left leg", "right leg", "left arm", "right arm", "head", "torso"} math.randomseed(os.time()) tsize = #limbs rn = math.random(tsize)</div><div>limb1 = limbs[rn] <span style="background-color: transparent; color: inherit; font-size: inherit; font-family: "lucida grande", "Lucida Sans Unicode", tahoma, sans-serif;">--Uncomment the following two lines to ensure you don't pick the same limb twice </span><span style="background-color: transparent; color: inherit; font-family: "lucida grande", "Lucida Sans Unicode", tahoma, sans-serif; font-size: inherit;">--table.insert(limbs, tsize, table.remove(limbs,rn)) </span><span style="background-color: transparent; color: inherit; font-family: "lucida grande", "Lucida Sans Unicode", tahoma, sans-serif; font-size: inherit;">--tsize = tsize -1</span></div><div>rn = math.random(tsize) limb2 = limbs[rn] print("doublewhirl target "..limb1.." "..limb2)</div>
https://repl.it/repls/SillyFortunateWebsites
There's some code that will select two random limbs, with an option to avoid picking the same limb twice.
However, dwhirling random limbs is, generally speaking, a bad idea and you shouldn't do it. You want to plan when you break limbs and which limbs you are breaking, even when you're just rolling damage on somebody.1 -
Alias: ^d([rfthli])(|x)([rfthli])(|x)$
In this alias, matches[1] is the whole alias (you won't be needing this), matches[2] is one of "rfthli", same for matches[4], and matches[3] and matches[5] are either "" or "x".
You can then hit left leg + right leg with "dfr", head+expend on right leg with "dhrx", expend on left arm+right leg with "dlxr".
Script for the alias:local limbtable = { r = "right leg", f = "left leg", h = "head", t = "torso", l = "left arm", i = "right arm", } local firstlimb = limbtable[matches[2]] local secondlimb = limbtable[matches[4]] local expendfirst = matches[3] local expendsecond = matches[5] if expendfirst == "x" then --this will expend on the first limb you specify, eg. drxf send("doublewhirl "..target.. " "..firstlimb.. " expend "..secondlimb) elseif expendsecond == "x" then --will expend on the second limb, eg. drfx send("doublewhirl "..target.. " "..firstlimb.. " "..secondlimb.." expend") else --no expend send("doublewhirl "..target.. " "..firstlimb.." "..secondlimb) end
1 -
-
-
If I wanted to make a list of some items I use frequently, to reference them across multiple triggers and aliases, would the best way be to make a table to house the variables? Sort of like an equipment list is what I'm going for.
0 -
Depends on how you want to reference them.
Equipment = {sword = "bastard1234", hat = "hat5678"} then call it with Equipment.sword
Equipment = {sword = {desc = "An old rusty bastard sword", ID = "sword1234"}, hat = {desc = "a cute hat", ID = "hat5678"}} and call it with Equipment.sword.ID
Mudlet can save variables across sessions now, or you could hard code it into a script.2 -
Accipiter said:Depends on how you want to reference them.
Equipment = {sword = "bastard1234", hat = "hat5678"} then call it with Equipment.sword
Equipment = {sword = {desc = "An old rusty bastard sword", ID = "sword1234"}, hat = {desc = "a cute hat", ID = "hat5678"}} and call it with Equipment.sword.ID
Mudlet can save variables across sessions now, or you could hard code it into a script.
0 -
The above image illustrates my issue. I want to have a big echo when the wind has blown me in a direction, but NOT if there is a wall blocking.Here's the trigger. What am I doing wrong?Actually, I think I know what's wrong - it's matching "A shrill wind blows you northeast." against the first line and the second line, then it's checking the next line, but it's already matched the first line twice and fired the trigger - but not how to fix it
Tharos, the Announcer of Delos shouts, "It's near the end of the egghunt and I still haven't figured out how to pronounce Clean-dat-hoo."0 -
Sorted it... I changed the trigger to just have the first line as regex:^A shrill wind blows you (\w+).\$Then used the following code:
blownDir = matches[2]<br>tempLineTrigger(<br> 1,<br> 1,<br> [[<br> if not (line == "A wall blocks your way.") then<br> guac.alert("BLOWN " .. blownDir:upper(),1)<br> end<br>]]<br>)
Tharos, the Announcer of Delos shouts, "It's near the end of the egghunt and I still haven't figured out how to pronounce Clean-dat-hoo."0 -
If I remember correctly, you want to have a gate trigger and have the second line in there with logic if you don't match. Cause everything in the triggers will try to match on each line, even if you have match all selected.0
-
-
-
That (.*) should also just be ^ if you want to match literally anything, then use the line variable to do the comparison.0
-
Had a chat about this with a few people and we never really found a true answer so I figure I will post it here.
I want to use gmcp.Room.Info.exits to grab the first exit in the room and store it in a variable so that when I fire my pinshot alias it will grab an exit (makes absolutely no difference what exit) and will toss a lightwall there along with the pinshot on my target. gmcp.Room.Info.exits looks like this:{ne = 11104,u = 11095,e = 12453,d = 11089,w = 13229,nw = 11142}
All I would want to do if I were in that room, would be grab "ne," the key in the first pair. The first thing I tried was to grab it by index, but gmcp.Room.Info.exits[1] didn't work, which I didn't think it would. Moving on from that, the only way I knew how to manipulate a k,v pair is with a for loop. Now the for loop worked, and it tossed a lightwall NE, but it obviously goes through the rest of the pairs and that can be spammy in a room with a bunch of exits such as the room this example is from.
My question is, is there a way to just grab the key from the first pair in that array without running through the whole array and spamming myself?(Holocaust Inc): Taryius says, "Waait *hic* .. Quaff drInks *hic* everything in a bott *hic* lee, I tHouGhf It was just 5sipSh.."0 -
-
-
Cyr said:There's meant to be a break in that loop. Whups
For k, v in pairs (gmcp.Room.Info.exits) do
Send("conjure lightwall "..k)
Break
End(Holocaust Inc): Taryius says, "Waait *hic* .. Quaff drInks *hic* everything in a bott *hic* lee, I tHouGhf It was just 5sipSh.."0 -
HELP WHY IS EVERYTHING GRAYED OUT0 -
Sign In to Comment.
Categories
- 6K All Categories
- 3K Everything Achaea
- 1.5K North of Thera
- 21 Archives of the Terraformer
- 240 The Matsuhama Arena
- 873 The Golden Dais of Creation
- 283 The Scarlattan Theatre
- 144 The Blank Canvas
- 1.9K Getting Help
- 389 General Questions
- 247 Quick Class Questions
- 1.3K Tech Support
- 298 Client Help
- 456 Curing Systems and Scripts
- 829 Off-Topic
- 250 The Wander Inn
- 579 The Universal Membrane
- 280 Class Discussions
- 280 Individual Class Sections
- 20 Alchemist
- 8 Apostate
- 29 Blademaster
- 9 Depthswalker
- 12 Druid
- 4 Infernal
- 20 Jester
- 19 Magi
- 30 Monk
- 9 Occultist
- 7 Paladin
- 7 Priest
- 28 Runewarden
- 17 Sentinel
- 24 Serpent
- 19 Shaman
- 9 Sylvan