Now all regex functions use ScriptRule.

The *_rule functions can now be considered deprecated
Documented this by removing mentions of the rule functions, except for a mention of backwards compatibility.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@997 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2008-06-19 00:37:48 +00:00
parent 5ece2dbb86
commit 158ecf67ad
19 changed files with 110 additions and 114 deletions
+6 -3
View File
@@ -23,12 +23,15 @@ Instead define a function in the init script.
>field:
> script: flubble_script()
--Use rule form--
If a function is available in [[script:rule form]] use it where possible.
--Use default arguments--
Many rules can be chained together using the @+@ operator.
Many functions can be chained together using the @+@ operator.
For these functions [[script:default arguments]] can be given.
Have a look at @text_filter@ in the magic game file for an example.
Using default arguments is especially important for functions that work on [[type:regex|regular expressions]],
since it allows MSE to compile the regular expressions just once instead of for every call.
--Don't be afraid to nest--
Don't be afraid to nest complex things like @if@ expressions inside other expressions.
For example the blend scripts for magic use:
+12 -9
View File
@@ -11,21 +11,24 @@ For determining whether the argument is set only explicit arguments count, not e
> arg := "something else"
> function() == "argument was: default"
//Defaults are evaluated at the time the @@@@ operator is evaluated, so they can be used to simulate static scoping.
Defaults are evaluated at the time the @@@@ operator is evaluated, they will not be overriden later
> default := "old default"
> function := { "argument was: " + arg }@(arg: default)
> default := "new default"
> function() == "argument was: old default"
--Rule functions--
Some functions are available in ''rule form''.
These rule form functions are functions that create a new [[type:function]] with some defaults filled in.
That new function, the rule, applies some transformation to the input and returns the result.
In earlier versions of MSE some functions were available in a special ''rule form''.
A call to for example @replace_rule(match:"abc",replace:"xyz")@ is equivalent to @replace@@(match:"abc",replace:"xyz")@ .
For backwards compatability these functions are still available, but they should not be used for new templates.
Programming in a ''rule style'' is still very useful.
A rule is like a normal function with all parameters given, except for the @input@.
Rules are often combined using the + operator, for example:
These rules can then be combined using the @+@ operator, for example:
> # First all "a"s are replaced, then all "b"s.
> remove_as_and_bs := replace_rule(match: "a", replace: "") +
> replace_rule(match: "b", replace: "")
> remove_as_and_bs := replace@(match: "a", replace: "") +
> replace@(match: "b", replace: "")
>
> text_with_as_and_bs := "bla bla bla"
> text_without_as_and_bs := remove_as_and_bs(text_with_as_and_bs)
+3 -3
View File
@@ -5,9 +5,9 @@ MSE uses a custom scripting language to add complicated behaviour to [[type:fiel
--Topics--
* [[script:introduction|Introduction to scripting]]
* [[script:Operators]]
* [[script:variables|Variables]]
* [[script:functions|Functions]]
* [[script:default_arguments|Default arguments]]
* [[script:Variables]]
* [[script:Functions]]
* [[script:Default arguments]]
* [[script:Control structures]]
* [[script:Predefined variables]]
* [[script:Best practices]]
-17
View File
@@ -1,17 +0,0 @@
Rule form
Some functions are available in ''rule form''.
These rule form functions are functions that create a new [[type:function]].
That new function, the rule, applies some transformation to the input and returns the result.
A rule is like a normal function with all parameters given, except for the @input@.
Rules are often combined using the + operator, for example:
> # First all "a"s are replaced, then all "b"s.
> remove_as_and_bs := replace_rule(match: "a", replace: "") +
> replace_rule(match: "b", replace: "")
>
> text_with_as_and_bs := "bla bla bla"
> text_without_as_and_bs := remove_as_and_bs(text_with_as_and_bs)