Maps - MrsDarth/Skirt GitHub Wiki
this is a map in case you don't know
A map view %map%
represents a map. It contains an id, x coord, z coord, world, renderers, and a few other settings
Every time a map is created. It will have an id
As you can see in the tooltip of the item, the id for this map is 0
The next maps created will have the ids 1, 2, and so on. This value cannot be changed
This can also be seen from hovering your mouse on the map
The map scale expression allows you to get or change the Level
value between 0 and 4. 0 being most zoomed in and 4 being furthest
The Scale
changes according to the level Scaling at 1:2^level
Maps have a center x and z coordinate to specify where it is in the world
Can be get and set.
You can get or change these values using the expression
[the] ([map] (scale|zoom)|cent(er|re) (x|z)|map id) of %maps%
%maps%'[s] ([map] (scale|zoom)|cent(er|re) (x|z)|map id)
The world the map is in
Can be get and set
[the] [map] world of %maps%
%maps%'[s] [map] world
When true, the map will not continue to explore the world
When true, the cursor will follow the player's position on the map
When true, it will continue to show a smaller position cursor when the cursor is outside of the map's range
You can get and change the states using
[the] [map] (lock[ed]|position tracking|unlimited tracking) [stat(e|us)] of %maps%
%maps%'[s] [map] (lock[ed]|position tracking|unlimited tracking) [stat(e|us)]
Expressions for getting a map:
[the] [event-]map
map from id %number%
[create] [new] map from [world] %world%
first is the map in a map initialise event, second gets a map from the specified id, and last creates a new map in a world
You can get the map of an item using
[the] map of %itemtypes%
%itemtypes%'[s] map
You can also set the map of an item to a mapview or number which is a shorter way of setting it to a map from id
Get a filled map item with map defined using
[[filled] map] item[s] (of|from|with) %maps%
A map canvas is a layer on the map that can be drawn on To get ourselves a map canvas to start customising our map, we first use
[(partially)] (manage|edit) [map] %map% [and store (canvas|it|)] in %objects%
What this does is remove the renderers of the map and add our own layer
The %objects%
represents the variable the canvas will be stored in
Specifying partially
will prevent deleting the previous layers. You can use this to create multiple layers of canvas
Note that this is a delayed effect, meaning it will wait until the specified map begins to render before any code after gets executed
Here are the effects for drawing on map:
draw image %image% at [(][x[ ]]%number%,[ ][y[ ]]%number%[)] [on %mapcanv%]
draw text %string% at [(][x[ ]]%number%,[ ][y[ ]]%number%[)] [on %mapcanv%]
will go into more detail on draw image
in Images
Pixels expression:
pixel at [(][x[ ]]%number%,[ ][y[ ]]%number%[)] [(of|on) %mapcanv%]
pixels (between|within) [(][x[ ]]%number%,[ ][y[ ]]%number%[)] and [(][x[ ]]%number%,[ ][y[ ]]%number%[)] [(of|on) %mapcanv%]
all pixels [(of|on) %mapcanv%]
Map pixels can be set to a color, or a number if you know what the map color numbers are
Maps have 128x128 pixels. ranging from 1 to 128. 1 being top/left and 128 being bottom/right
Let's begin editing our map.
command red:
trigger:
set {_map} to map of player's tool
{_map} is set
edit {_map} and store canvas in {_canvas}
set all pixels on {_canvas} to red
So here we have created a command to color the map the player is holding red
firstly we grab the map from the item the player is holding
next checking if it is set as the player may not even be holding a map and if it isn't set there's no point continuing
we then edit the map and store the canvas so we can draw on it
lastly we set all pixels on the canvas to red. Here is the result:
Using the perlin noise from the addon SKNoise, you can draw some pretty cool stuff on maps
Here we will make a command similar to the example above
command noisemap:
trigger:
set {_map} to map of player's tool
{_map} is set
edit {_map} and store canvas in {_canvas}
add 1 to perlin seed
loop 128 times:
loop 128 times:
set {_x} to loop-value-1
set {_y} to loop-value-2
set {_value} to perlin noise at {_x}/100, {_y}/100
set {_} to round (({_value} + 1) * 127.5)
set pixel at {_x}, {_y} on {_canvas} to rgb({_},{_},{_})
This may look confusing but what we are doing here is getting the noise value and changing the range from -1 ~ 1 to 0 ~ 255
And then using that value to determine the lightness of the rgb color. And then drawing the pixel on the map
Result will look something like this:
An example of a map cursor is the white pointer that indicates where the player is on a map
A cursor has a type, visibility state, x, y, rotation and name
this represents the type of cursor %mapcursortype%
Values:
white pointer, green pointer, red pointer, blue pointer, white cross, red marker,
white circle, small white circle, mansion, temple, banner white, banner orange, banner magenta,
banner light blue, banner yellow, banner lime, banner pink, banner gray, banner light gray, banner cyan,
banner purple, banner blue, banner brown, banner green, banner red, banner black, red x
Needless to say, indicates whether the cursor is visible
x and y position of the cursor on the canvas. 0, 0 being the center
The direction the cursor is facing. ranging from 0 to 15
You can alternatively just set the direction to a direction eg. north
and it will auto convert for you
The caption that appears under the cursor
The syntax to get a new cursor:
[new] [(visible|invisible)] %mapcursortype% map cursor [at [(][x[ ]]%number%,[ ][y[ ]]%number%[)]] [(facing|with rotation) %direction/number%] [(named|with (name|caption)) %string%]
You can get or edit its properties with:
[the] cursor (type|visibility|x|y|direction|rotation|(name|caption)) of %mapcursors%
%mapcursors%'[s] cursor (type|visibility|x|y|direction|rotation|(name|caption))
Get or change the cursors in a map canvas with:
[all][[of] the] map cursors [(of|on) %mapcanv%]
Let us now try to add a spinning cursor to our map
command spin:
trigger:
set {_map} to map of player's tool
{_map} is set
edit {_map} and store canvas in {_canvas}
set {_cursor} to new white pointer map cursor
add {_cursor} to map cursors of {_canvas}
loop 100 times:
add 1 to cursor rotation of {_cursor}
wait for {_canvas} to render
The wait for {_canvas} to render
part is necessary to make sure every rotation is seen
As compared to doing wait a tick
if you edit a canvas multiple times before a render takes place only the last change will be visible