World Advanced Methods
Aus EnigmaWiki
Inhaltsverzeichnis |
add
Add Other Objects to the world.
Syntax:
wo:add(tile_declarations)
wo:add(target, tile_declarations)
Description:
-
tile_declarations: One or many other object declarations given as tiles or anonymous tables.
-
target: YIN, YANG or valid Object Reference
Syntax Samples:
wo:add({"ot_rubberband", anchor1="a1", anchor2="w", length=2, strength=80, threshold=0}) wo:add(ti["r"] .. {"ot_wire", anchor1="w1", anchor2="w2"}) wo:add(YIN, {"it_magicwand"}) wo:add(no["mybag"], {"it_magicwand"} .. ti["h"] .. ti["c"])
Details:
Just Other Objects can be directly added to the world. Just non static
Items can be added to the player's inventories YIN and YANG
and to it_bags. No other targets do currently add objects by this method.
drawBorder
Draw a border around a rectangle out of given tiles.
Syntax:
wo:drawBorder(upperleft edge, lowerright edge, tile)
wo:drawBorder(upperleft edge, width, height, tile)
Description:
-
upperleft edge: Upper left anchor position of the rectangle.
-
lowerright edge: Lower right end position of the rectangle.
-
width: Width of the rectangle.
-
height: Height of the rectangle.
Syntax Samples:
wo:drawBorder(po(0, 0), wo["Width"], wo["Height"], ti["#"]) wo:drawBorder(no["myRectUL"], no["myRectLR"], {"st_grate1"})
Details:
None in refman yet.
drawMap
Even if the world is initialized by a map on creation of the world, it is sometime useful to
be able to draw smaller submaps either as part of the initialization or as dynamic level
changes within Callback Function. Of course the main purpose of drawMap is the drawing of
repeating patterns.
Syntax:
wo:drawMap(resolver, anchor, ignore, map, [readdir])
wo:drawMap(resolver, anchor, libmap-map, [readdir])
Description:
-
subresolver: Resolver to which unresolved requests should be forwarded. May betias the final resolver of the resolver chain.
-
anchor: The anchor position where the upper left tile of the map should be drawn.
-
ignore: A tile key string that should be ignored. This key string is mandatory, even if it not used within the map.
-
map: A table of strings. Each string describes a row of tiles by its tile keys.
-
libmap-map: If the map used is created via libmap theignore-string can be omitted. The map’s default key will then be ignored instead.
-
readdir: An optional argument to modify the direction of the map relative to the world. This argument can be any of the constants described in Rotating and Mirroring Maps.
Syntax Samples:
wo:drawMap(ti, po(5, 7), "-", {"abcabc"}) wo:drawMap(ti, anchor_object, "--", {"--##--##","##--##"}) wo:drawMap(ti, 12, 5, " ", {"122 221"}, MAP_ROT_CW)
Details:
The syntax is similar to the world creation call. But there are two essential
differences you need to be aware of. First the map is drawn in the already
existing world. Thus we need to define the position. This is done via the
anchor position, which can be an already existing object, too.
The second difference is in the definition of a tile key string for tiles in the map
that should be ignored. Remember that the world initialization requested a
default tile key string. This default is still valid. But with the given ignore key
string we can draw arbitrary shaped patterns by filling unused grids in the map
with this key.
The length of the ignore key defines the map key length. It is strongly recom-
mended to use the same key length as in the world map.
The rows of the supplied map are drawn from the anchor position. The rows
may be of different length and may start with ignore tile keys. The anchor must
be the position composed of the smallest x and smallest y coordinate within
the pattern.
You can use drawMap anywhere after the world creation. You are even allowed
to use it within the world creation in a resolver.
drawRect
Syntax:
wo:drawRect(upperleft edge, lowerright edge, tile)
wo:drawRect(upperleft edge, width, height, tile)
Description:
-
upperleft edge: Upper left anchor position of the rectangle.
-
lowerright edge: Lower right end position of the rectangle.
-
width: Width of the rectangle.
-
height: Height of the rectangle.
Syntax Samples:
wo:drawRect(po(0, 0), wo["Width"], wo["Height"], ti[" "]) wo:drawRect(no["myRectUL"], no["myRectLR"], {"fl_water"})
Details:
None in refman yet.
shuffleOxyd
Shuffling the color distribution of the st_oxyd makes every level, that is no meditation, a bit generic. On every level start the level looks a little bit different and the user has to solve a modified level. This provides long term amusement. Thus the call of this method is part of most levels. Many levels just call this method without any arguments. This results in a shuffling of all st_oxyd that are not excluded by a noshuffle attribute. But sometimes levels need to influence the shuffling, either for ensuring that the level remains solvable, or simply to ensure fairness. Imagine a level that has two st_oxyds in every corner. If by chance a user gets a distribution where he has in each corner a pair of same colored oxyds, the level might be trivial. Another level may have a passage that the marble can pass just a few times. With 5 or more oxyds on each side of the passage you need to ensure that the marble never needs to pass the passage more often than possible. Both situations can be handled by providing proper rules as arguments to this method.
Syntax:
wo:shuffleOxyd(rules)
Description:
-
rules = rule, rule,...: No rule or as many as you like, all seperated by a comma.
-
rule = {group1, group2, maxrule, minrule, circularrule, linearrule, log}: Each rule is a table with a subset of the listed entries. The group1 entry is mandatory. All other entries are optional and can be added in any combination.
-
group1 = group | objectreference | objectspecifier: A description of oxyd objects that are part of the first rule group. Either a group or a single object reference or a string specifier that resolves to a single or via wildcard to several oxyd objects are legal descriptors.
-
group2 = group | objectreference | objectspecifier: A description of oxyd objects that are part of the second rule group. Either a group or a single object reference or a string specifier that resolves to a single or via wildcard to several oxyd objects are legal descriptors.
-
maxrule = max = number: The maximum number of oxyd pairs.
-
minrule = min = number: The minimum number of oxyd pairs.
-
circularrule = circular = true: Avoid any pair of neighboring oxyds in group1. Avoid an oxyd pair of first and last oxyd in group1, too.
-
linearrule = linear = true: Avoid any pair of neighboring oxyds in group1.
-
log = log = "solution" |"count" |"all": Log additional information to the log stream for debugging purposes and security checks by the level author.
Syntax Samples:
wo:shuffleOxyd() wo:shuffleOxyd({"borderoxyds#*", circular=true}) wo:shuffleOxyd({"leftoxyds#*","rightoxyds#*", min=3}, {"islandoxyds#*", max=0})

