Diku Mud Stat roller

Post Reply
Strachan
Posts: 6
Joined: Wed Jul 26, 2017 6:39 am

Diku Mud Stat roller

Post by Strachan »

Hi all,

Any help with the script will be appreciated. I have recently started with mudding again, and want to roll a decent character. I'm not very good at setting "code script".

Diku mud, and the screen result with stats will look something like this, as an example:

Str: 16/0 Int:15 Wis:14 Dex:12 Con:17 Cha: 5

Keep this character (y/n)?


So how do I set a trigger that make each of Str, Int, Wis, Dex etc variable? Perhaps using *?? Not sure.
Then to set an "if" condition, with a minimum number for each. In other words something like:

If Str>17 and Int>16 and Wis>16 and Dex>15 and Con>19 and Cha<8
Then
Send("y")

How do I actually word this? The script?
Any help will be greatly appreciated. Thank you.

User avatar
demonnic
Posts: 884
Joined: Sat Dec 05, 2009 3:19 pm

Re: Diku Mud Stat roller

Post by demonnic »

So you would make a trigger, type of perl regex, with a pattern of

^Str: (\d+)/(\d+) Int:(\d+) Wis:(\d+) Dex:(\d+) Con:(\d+) Cha: (\d+)

Then put the code in the box like so:
Code: [show] | [select all] lua
myStr = tonumber(matches[2])
myStr2 = tonumber(matches[3])
myInt = tonumber(matches[4])
myWis = tonumber(matches[5])
myDex = tonumber(matches[6])
myCon = tonumbeer(matches[7]
myCha = tonumber(matches[8])

if myStr >= 17 and myInt >= 16 and myWis >= 16  and myDex => 15 and myCon => 19 and myCha >= 8 then
  acceptableStats = true
end
Then make another trigger, exact match, and copy paste the "Keep this character (y/n)?" from the mud itself into it. Make the script be:
Code: [show] | [select all] lua
if acceptableStats then
  send("y")
else
  send("n")
end
And that should do it for you. The above would accept any stats where Str was 17 or higher, Int was 16 or higher, etc. Otherwise it'll send n to roll up some more stats.

Strachan
Posts: 6
Joined: Wed Jul 26, 2017 6:39 am

Re: Diku Mud Stat roller

Post by Strachan »

Wow! Thanks so much, exactly what i was after. Will give it a go. Thank you.

Strachan
Posts: 6
Joined: Wed Jul 26, 2017 6:39 am

Re: Diku Mud Stat roller

Post by Strachan »

Sorry, working on an iPad in response. On the PC, it doesn't work for line 10:

acceptableStats = true

It reads: Lua Sytax error:[string "Trigger: Regex"]:10: 'then' expected near '='

Sorry, i am not sure what is actually wrong or how to fix it. Can someone perhaps advise please? Thank you.

User avatar
SlySven
Posts: 1019
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Diku Mud Stat roller

Post by SlySven »

I'm not entirely sure that a couple of those conditions are put right:

... and myDex => 15 and myCon => 19 and ...

I suspect you might need to change "=>" to ">=" See section 2.1 of the Lua 5.1 manual !

Strachan
Posts: 6
Joined: Wed Jul 26, 2017 6:39 am

Re: Diku Mud Stat roller

Post by Strachan »

All, thanks for all the help. However as a total newbie here I am struggling and can't get this to work. I suspect I am missing some critical very basic concepts. I can simplify and get a "test" to work? Let's say something basic, such as:

Ab 5 and Bc 7 -- so if we take a scenario that the numbers become variable, how do I set a very simple trigger in a Mud to say something if the number of Ab is greater than Bc? I will test with 'You say hello.'

My thoughts were on trigger line to enter: Ab (\d+) and Cd (\d+) -- and to select perl regex setting
Then in the block below:
Ab = tonumber(matches[2])
Cd = tonumber(matches[3])

If tonumber(matches[2]) > tonumber(matches[3])
then
send(say hello)
end


Except I can't even get this basic trigger on a variable to work. Any help will be greatly appreciated. I have the character say Ab 7 Cd 5 in expectation that I will see the character also then say "hello". Doesn't work

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Diku Mud Stat roller

Post by Vadi »

Just one thing - actual text you'd like to use needs to go into quotes, so send("say hello"). Checkout this introduction http://www.youtube.com/view_play_list?p ... xt_from=PL. Did it work then? Just note that you need to go "Ab 7 and Cd 5" according to your pattern, not "Ab 7 Cd 5".

Strachan
Posts: 6
Joined: Wed Jul 26, 2017 6:39 am

Re: Diku Mud Stat roller

Post by Strachan »

Yes, thanks. Sorry, typo in my example. I did do send("say hello")
Did try Ab 7 and Cd 5.

Doesn't work. I will have a look at the link, thanks.

EpicWiz
Posts: 1
Joined: Tue Jul 28, 2020 2:36 am

Re: Diku Mud Stat roller

Post by EpicWiz »

For anyone still trying to work this out...this seems to be working for me:

MUD outputs:

Rolling...
Strength: 13 Intelligence: 14 Wisdom: 18 Dexterity: 13 Constitution: 13

Do these reflect your training (Y/N)?

trigger1:
^Strength: (\d+) Intelligence:(\d+) Wisdom:(\d+) Dexterity:(\d+) Constitution:(\d+)
Type: perl regex

Code: Select all

myStr = tonumber(matches[2])
myInt = tonumber(matches[3])
myWis = tonumber(matches[4])
myDex = tonumber(matches[5])
myCon = tonumber(matches[6])

if myStr >= 20 and myInt >= 17 and myWis >= 19  and myDex >= 18 and myCon >= 21 then
  acceptableStats = true
end
trigger2:
Do these reflect your training (Y/N)?
Type: exact match

Code: Select all

if acceptableStats then
  send("y")
else
  send("n")
end
Those worked for me. The answer the user gave above had some syntax issues.

Post Reply