Here's a little diddy I wrote...

Scripts and support for your favorite MUD client.
Afu
Sojourner
Posts: 82
Joined: Sun Oct 01, 2017 3:58 pm

Here's a little diddy I wrote...

Postby Afu » Sat Jun 23, 2018 5:01 am

I'm going to start this new thread,how to code basic things, so that people
can code these things for themselves, once you see a few examples of how this works, it will be
much easier for you to write more complicated triggers.

today someone asked me,
i am sick of having to type put x portable.hole
how do i make an alias that puts everything in my portable.hole when i type put x in portable.hole
warning, once u enable this alias every time you type ph in any line, it will not type the rest of the line behind it

so the syntax would be

put all.coin ph

regex:

Code: Select all

^(.*)ph$


Code: Select all

--echo(matches[2] .. "portable.hole\n") -- debug
send(matches[2] .. "portable.hole")


now this does have one problem, when you type l in ph, nyss has an alias that does l and it catches this, so maybe use caps when using it...

you can alternatively get much more complicated with your variables,

his could be set to bash target etc..

and do
regex:

Code: Select all

^(.*)ph(.*)$


and refer to this as

Code: Select all

--echo(matches[2] .. "portable.hole" .. matches[3]) -- debug
send(matches[2] .. "portable.hole" .. matches[3])


we may need to add spaces there, but thats what the debug is for

--echo(matches[2] .. " " .. "portable.hole" .. " " .. matches[3]) -- debug
send(matches[2] .. " " .. "portable.hole" .. " " .. matches[3]) -- debug
Last edited by Afu on Sat Jun 23, 2018 5:08 am, edited 1 time in total.
Afu
Sojourner
Posts: 82
Joined: Sun Oct 01, 2017 3:58 pm

Re: Here's a little diddy I wrote...

Postby Afu » Sat Jun 23, 2018 5:04 am

This code can be combined...

Regex

Code: Select all

^(.*)ph(.*)$


Code: Select all

if matches[3] == nil then
--echo(matches[2]  .. " " .. "portable.hole"  .. " " .. matches[3]) -- debug
send(matches[2]  .. " " .. "portable.hole"  .. " " .. matches[3])
else
--echo(matches[2] .. " " .. "portable.hole" .. " " ..  matches[3]) -- debug
send(matches[2] .. " " .. "portable.hole")
end


could then empty ph bag
Afu
Sojourner
Posts: 82
Joined: Sun Oct 01, 2017 3:58 pm

Re: Here's a little diddy I wrote...

Postby Afu » Tue Jul 24, 2018 8:57 pm

this one is to gamble with, gambles all money, records all winnings, stops on jackpot

init alias - resets the counters and starts the gambling session

name: @greset
regex: ^@greset$
code

Code: Select all

charData:set("jackpot", 0)
charData:set("won_thou", 0)
charData:set("won_fivehun", 0)
charData:set("won_hun", 0)
charData:set("won_fifty", 0)
charData:set("won_twentyfive", 0)
charData:set("won_ten", 0)
charData:set("won_five", 0)
charData:set("won_two", 0)
charData:set("wonmoney", 0)
charData:set("spentmoney", 0)

expandAlias("@gamble", false)
mud:send("gamble 1")


display alias
-- displays the stats of the session at any time

name: @gamble
regex: ^@gamble$
code

Code: Select all

local percent = (charData:get("jackpot") / charData:get("spentmoney")) * 100
cecho("\n<green>Jackpot:" .. charData:get("jackpot") .. " " .. percent .. "%")
percent = (charData:get("won_fivehun") / charData:get("spentmoney")) * 100
cecho("\n<green>Five Hundred:" .. charData:get("won_fivehun") .. " " .. percent .. "%")
percent = (charData:get("won_hun") / charData:get("spentmoney")) * 100
cecho("\n<green>Hundred:" .. charData:get("won_hun") .. " " .. percent .. "%")
percent = (charData:get("won_fifty") / charData:get("spentmoney")) * 100
cecho("\n<green>Fifty:" .. charData:get("won_fifty") .. " " .. percent .. "%")
percent = (charData:get("won_twentyfive") / charData:get("spentmoney")) * 100
cecho("\n<green>Twenty Five:" .. charData:get("won_twentyfive") .. " " .. percent .. "%")
percent = (charData:get("won_ten") / charData:get("spentmoney")) * 100
cecho("\n<green>Ten:" .. charData:get("won_ten") .. " " .. percent .. "%")
percent = (charData:get("won_two") / charData:get("spentmoney")) * 100
cecho("\n<green>Two:" .. charData:get("won_two") .. " " .. percent .. "%")
cecho("\n<green>Won:" .. charData:get("wonmoney"))
cecho("\n<green>Spent:" .. charData:get("spentmoney"))


triggers --

name: count coins
substring: When the wheels finally all come to rest you see the results

Code: Select all

charData:set("spentmoney", charData:get("spentmoney")+1)
if charData:get("jackpot") < 1 then
  send("gamble 1")
end


name: count winnings
regex: You won (.*) platinum coin.*

Code: Select all

--cecho("\n<cyan>" .. "fired" .. "\n")
charData:set("winnings", 0+matches[2])
charData:set("wonmoney", charData:get("wonmoney")+matches[2])
cecho("\n<cyan>Won: " .. charData:get("wonmoney") .. "\n<red>Spent: " .. charData:get("spentmoney") .. "\n<green>Win:" .. matches[2])
if charData:get("winnings") > 0 then
  --mud:send("say woohoo " .. matches[2] .. " plat!")


   if charData:get("winnings") == 2 then
     charData:set("won_two", charData:get("won_two")+1)
      
   end

   if charData:get("winnings") == 5 then
     charData:set("won_five", charData:get("won_five")+1)
   end


   if charData:get("winnings") == 10 then
     charData:set("won_ten", charData:get("won_ten")+1)
   end

   if charData:get("winnings") == 25 then
     charData:set("won_twentyfive", charData:get("won_twentyfive")+1)
   end

   if charData:get("winnings") == 50 then
     charData:set("won_fifty", charData:get("won_fifty")+1)
   end

   if charData:get("winnings") == 100 then
     charData:set("won_hun", charData:get("won_hun")+1)
   end

   if charData:get("winnings") == 500 then
     charData:set("won_fivehun", charData:get("won_fivehun")+1)
   end

   if charData:get("winnings") == 1000 then
     charData:set("won_thou", charData:get("won_thou")+1)
   end

   if charData:get("winnings") > 1000 then
     charData:set("jackpot", charData:get("jackpot")+1)
   end

end

Afu
Sojourner
Posts: 82
Joined: Sun Oct 01, 2017 3:58 pm

Re: Here's a little diddy I wrote...

Postby Afu » Wed Jul 25, 2018 5:34 am

I started like 12 hours ago with 10k
have around 8k left and script still running

current results:

Jackpot:3 - 0.0074796180408387%
Five Hundred:5 - 0.012466030068065%
Hundred:15 - 0.037398090204194%
Fifty:26 - 0.064823356353936%
Twenty Five:42 - 0.10471465257174%
Ten:337 - 0.84021042658755%
Two:6130 - 15.283352863447%
Won:34851
Spent:40109
Afu
Sojourner
Posts: 82
Joined: Sun Oct 01, 2017 3:58 pm

Re: Here's a little diddy I wrote...

Postby Afu » Wed Jul 25, 2018 5:16 pm

total invested: 10k plats ran it till i ran out, but i knew the house always wins, took like a whole day
final results

Jackpot:3 0.0055268975681651%
Five Hundred:7 0.012896094325718%
Hundred:23 0.042372881355932%
Fifty:36 0.066322770817981%
Twenty Five:57 0.10501105379514%
Ten:473 0.87140751658069%
Two:8427 15.525055268976%
Won:44280
Spent:54280

Return to “MUD Client Help”

Who is online

Users browsing this forum: No registered users and 14 guests