Figuring age?
Figuring age?
the mud I am playing dosent tell you your age, just gives you the date of birth and another command for the current date. is there some way I can get mudlet to calculate my age for me without making to much noise?
Re: Figuring age?
Without showing us some output, no chance
-
- Posts: 186
- Joined: Sun Nov 14, 2010 5:57 am
Re: Figuring age?
daemoen is correct, we'll need a sample birth date, current date, and the calendar scheme to to do anything.
Re: Figuring age?
sorry, apparently I was just ignorant to the correct command.
I would still like to know the commands for making mudlet do math though
I would still like to know the commands for making mudlet do math though
Re: Figuring age?
You make Mudlet do math simply by using mathematical operators.
If you write in your script echo(2*(3+5/4)), it will evaluate just that and output the result 8.5
The same works with variables of course. So you could write in a script:
For instance:
echo("The sine of pi/2 is "..math.sin(math.pi/2))
If you write in your script echo(2*(3+5/4)), it will evaluate just that and output the result 8.5
The same works with variables of course. So you could write in a script:
If you want to use some extended mathematical operations, you may have too look at Lua's math library.
For instance:
echo("The sine of pi/2 is "..math.sin(math.pi/2))
Re: Figuring age?
NEAT! thank you very very much!
but just to make sure I do this right maybe you could help me with my first one?
(5*C)/T
so I will need 5 apples per person and then I want to subtract it by the number of apples I already have to see how many I need or dont need?
and I want to be able to grab the amount of apples I already have and the people im feeding from the game
but just to make sure I do this right maybe you could help me with my first one?
(5*C)/T
so I will need 5 apples per person and then I want to subtract it by the number of apples I already have to see how many I need or dont need?
and I want to be able to grab the amount of apples I already have and the people im feeding from the game
Re: Figuring age?
http://lua-users.org/wiki/MathLibraryTutorial has all the math functions you can use. Particular favourites of mine are floor and random... Hope they help!
Re: Figuring age?
Let's say your game displays the following two lines:ella wrote:NEAT! thank you very very much!
but just to make sure I do this right maybe you could help me with my first one?
(5*C)/T
so I will need 5 apples per person and then I want to subtract it by the number of apples I already have to see how many I need or dont need?
and I want to be able to grab the amount of apples I already have and the people im feeding from the game
Now you want to capture those two lines with triggers and store the amount of apples you have and the amount of people you need to feed. Then, when you type in "calculate apples", you want Mudlet to calculate how many apples you still need if you want to give everyone 5 apples, then display this number on screen.You are currently holding 22 apples.
You must feed 7 people.
First trigger (regular expression):
^You are currently holding (\d+) apples\.$
Executes:
my_apples = matches[2]
matches[2] refers to whatever the first wildcard in brackets () captures in that trigger. In this case, the number represented in the trigger by (\d+). Since the game displays, per above, "You are holding 22 apples.", this will set your variable my_apples to 22.
Second trigger (regular expression):
^You must feed (\d+) people\.$
Executes:
people_to_feed = matches[2]
This works exactly like the trigger above.
Now you create an alias to check how many apples you still need:
Alias pattern:
^calculate apples$
Executes:
Of course you could just shorten this to a single line, without needing the extra variable "apples_still_needed":
In both cases, typing "calculate apples" should display the following thing on screen:
I still need to gather 13 apples.