It looks like you're new here. If you want to get involved, click one of these buttons!
#sidebar {
top: 240px;
}
#map {
position:fixed;
left: 20px;
top: 20px;
width: 200px;
height: 200px;
overflow: hidden;
}
#map img {
position: absolute;
left: 0px;
top: 0px;
transition: all 2s;
-webkit-transition: all 2s;
}
Script:
macros['map'] =
{
handler: function(place,macroName,params)
{
var a = $("map").firstChild.style;
a.left=-params[0]+"px"; a.top=-params[1]+"px";
}
};
var li = document.createElement("li");
li.id = "map";
li.innerHTML = '<img src="ImageName.png" style="">';
$("sidebar").insertBefore(li,$("storyMenu"));
Usage:
<<map 200 200>>
You'll have to fiddle around with the coordinates to get mini-map to move to exactly where you want it on your map, and you will have to set a default starting position in the stylesheet.
Comments
I just tried running this in sugarcube too, no image displays in the sidebar and it threw this error Would some sugarcube-guru be able to show to how fix these errors?
This code, which includes the minimap overlay, will work in both SugarCube and Sugarcane (it should also work in Jonah and Responsive, though you'll likely need to change the CSS a bit). You'll also need to enable jQuery in the vanilla headers via the StorySettings special passage.
1. Put this in a
script
tagged passage: ReplacingMINIMAP_IMAGE_URL
in the minimap image source setup with the URL of the image you're using. If you wanted to use an image passage, then you'd change the minimap image source setup code to: ReplacingMINIMAP_IMAGE_PASSAGE
with the title of your minimap image passage.2. Put this in a
stylesheet
tagged passage: ReplacingOVERLAY_IMAGE_SOURCE
in the#minimap-overlay
style with either the URL of the image you're using (e.g.url(http://some.place/minimap-overlay.png)
) or the wiki image syntax for the minimap overlay image passage you're using (e.g.[img[MinimapOverlay]]
).I tried adjusting settings in the stylesheet, but even though i could resize the image the broken line was still there.
It's not broken, the two pieces are simply no longer connected. ;D (Despite the smiley, I am serious.)
SugarCube's border there actually comes in two pieces, one on the right-hand side of #ui-bar and the other on the left-hand side of #passages. Normally, this provides a better look than having it only on one of them (IMO). In this case, however, since you've moved the #ui-bar down and your passage is so short, you're seeing both borders separately.
Possible solutions: (you only need one)
1. A longer passage would solve the issue. So, if you have no short passages in your real project, then doing nothing would work.
2. Make the #ui-bar (or #sidebar) underpin the minimap (the minimap will not be harmed). For instance, change this style: To something like this:
3. Remove the #ui-bar's border. Like so:
Personally, if #1 isn't viable, I'd choose #2 (it's probably what you want).
Can you swap that map on the fly by clicking a passage link?
Yes, easily. For example, using the same code that you initially set the minimap source with (but using a different image).
URL version: Image passage version:
You could also switch minimaps via tags, so it would be automatic.
For example, with image passages, if you named your image passages like
minimap-NAME
(e.g. minimap-swamp, minimap-forest), tagged your passages with similar tags, and swapped out the<<map>>
macro for this one: Then calling<<map>>
would update the map's source automatically based on a passage'sminimap-*
tag, if it needed to be updated.The URL version would be similar, you'd simply need a tagURL mapping.
Personally, if #1 isn't viable, I'd choose #2 (it's probably what you want).
Thanks again MadExile, solution two was perfect. And with your addition thanks to Wraithbane's suggestion to being able to swap the map on the fly makes it even better.
*Update*
Concerning the swap map addition. In regards to using the img method, where do we assign the image/path?
So erm..we have two methods suggested here? the line below is for the previous script version?? and updating the image through the passage link. The #minimap img refers to the css attribute?, we have the src and the next bit im not sure about, is this suppose to be a variable which stores the imagefile name?
Then the other method is a new script which updates when a tag triggers it- which ideally sounds better, but same problem can't figure out where to put the imagename.png that it is swapping with. Brain imploding..
Not working, no starting image is displaying. Can you be a little more specific or maybe upload an example?
And it would be <<map x y>> as per normal.
This is what I have
Start: swamp1:
Tag: minimap-swamp (have tried minimap-swamp.png as a tag too) image file name being swamp.png
<<map 200 200>>
What did you do for your border for your map?
Are you able to upload a tws of your demo for it? I must be doing something wrong.
The border, sorry i forgot to reply to that before. I made the border in paint.net and the center was filled blue and i set that to be transparent so its basically a window, saved as a png.
MANUALLY CHANGING THE MINIMAP URL:
If you want to change the minimap manually, then do something like this: (the setter is the important bit) Replacing
MINIMAP_IMAGE_URL
with the URL of the appropriate minimap image.AUTOMATICALLY CHANGING THE MINIMAP URL (VIA: TAG -> URL MAPPING):
If you want to have
<<map>>
change the minimap automatically based on passage tags, put this in ascript
tagged passage: (includes all necessary scripting) ReplacingMINIMAP_IMAGE_URL_FOR_*
andMINIMAP_IMAGE_URL
with the URLs of the appropriate minimap images.You must also tag your passages with tags like
minimap-*
(e.g.minimap-forest
,minimap-plains
,minimap-swamp
).Thanks for your patience and making this mini-map even better
Are you referring to the
map
property of the macro? You don't setup images there, you don't touch that at all, it's only for use by the macro itself. The macro uses it to see if the minimap image requires updating, so that it can update it only when required.You setup the tag -> image mapping in the
setup.maps
object (right at the top of the script in my previous reply), the one with the comment just before it that says:How is she doing that map graphic around her map?
The same way Dazakiwi38 is doing theirs, with a partially transparent overlay image. Its edges are painted opaque, while the interior is allowed to be transparent or, if you wanted a hazier look, translucent. The overlay image sits directly over top of the minimap image, which would completely obscure it normally, however, since the overlay is partially transparent you can still see the minimap underneath through the transparent parts.
All of the example scripts and CSS that I've given in this thread, starting with this post, have included support for an overlay.
In the example
stylesheet
, it's this part: You simply replaceOVERLAY_IMAGE_SOURCE
with either the URL of the image or the wiki image syntax for the minimap overlay image passage that you're using. For example: If you didn't want the overlay, then you could change its style to: