Open brazilofmux opened 9 years ago
Comment #1 originally posted by brazilofmux on 2008-12-23T07:48:39.000Z:
Current functionality of RhostMUSH's strmath() function, which is functionally equivalent of this:
strmath()
Function: strmath(
The strmath function is used to apply math to the entire string. Numbers
in the string are modified based on the math chosen applied to the number.
You may specify optional input and output seperators. You may also specify
the word to start (
Valid math arguments are:
Examples:
strmath(1 fish 2 fish green fish blue fish,10,+) (default) You say "11 fish 12 fish green fish blue fish" strmath(1 fish 2 fish green fish blue fish,10,*) You say "10 fish 20 fish green fish blue fish" strmath(1 fish 2 fish 3 shoe 4 shoe,10,+,,,3,2) You say "1 fish 12 fish 13 shoe 4 shoe"
Actually, it'd be more similar to strfunc, not strmath :)
STRFUNC()
Function: strfunc(<function>, <list of arguments>[,<delim>])
The strfunc (string function) function is used to transform a string of arguments into separate identified arguments and feed them into the specified function. If you do not have access to the function or if you give the target function an invalid number of arguments, an error message will be displayed.
This in effect will turn any function in the game into a string oriented function. Thus the name, 'strfunc'.
Examples:
> say add(1,2,3,4)
You say "10"
> say strfunc(add,1 2 3 4)
You say "10"
> say strfunc(add,1@2@3@4,@)
You say "10"
> say hastype(me,player)
You say "1"
> say strfunc(hastype,me player)
You say "1"
> say switch(add(1,1),2,match,1,nope,0,nope,nope)
You say "match"
> say strfunc(switch,add(1,1) 2 match 1 nope 0 nope nope)
You say "match"
See Also: strmath(), ladd(), lsub(), ldiv(), lmul()
Original issue 550 created by brazilofmux on 2008-12-23T07:45:38.000Z:
There is a generic way of list-i-fying math functions in PennMUSH and Rhost.