Has anyone here made a game saving macro for Sugarcane? I don't want to switch to sugarcube as my game relies heavily on L's macros and (AFAIK) they aren't all compatible. I know Mike Snyder's Hallowmoor does this superbly, and the source is available, but I can't quite seem to get it working. I need it to store all the variables so the player can resume the game, I don't need multiple slots or anything fancy.
Thanks!
Comments
I'm guessing I'm not the only one who'd like this feature? In my head it seems like an incredibly useful thing to have. I don't know javascript at all, but would writing code to store the current passage name and all variables in a cookie when you click "save" and dump them back out when you press "load" be difficult to do?
Also, from the StorySettings passage:
[quote]--(If the player can't undo, bookmarks are always disabled.)
I don't see why that should be the case. I definitely don't want to let my player undo, just to be able to stop playing and carry on later.
I don't see why that should be the case. I definitely don't want to let my player undo, just to be able to stop playing and carry on later.
If the player has bookmarks, then they can undo moves as many times as they want, just by doing this:
* Bookmarking the current passage
* Making a move
* Restoring from the bookmark if they didn't like the move.
There's been more than one request for something like a bookmark() function, which I believe I can add for 1.4.2.
- a bookmark in the web browser
- a passage tagged as "bookmark"
Maybe the latter could be renamed to for example "checkpoint" or "milestone" to avoid confusion?Just to be clear, is accessing bookmark without the sidebar currently not possible? If so, is there some way I can just include that link of the sidebar and put it somewhere else on the webpage? Sorry to be a pain as usual, and thanks again for your help!
If saved game functionality is important to you, SugarCube offers that functionality in various configurations (based on browser storage, not cookies), without reliance on whether you allow undos or are using bookmarks. I have it set up to autosave the reader's progress, and offer to load that progress on restart, which sounds like it's close to what you are after.
Edit: Bit of a snag - is either() not supported?
If you really wanted to use a function by that name, you could always write a shim. For example:
I thought the bookmark link in the Sugarcane sidebar meant to put the page into Chrome and/or Firefox's bookmarks for a long time. I guess IE calls bookmarks favorites. If I thought that, then there is probably a large percentage of casual Twine users who do as well. Well, maybe I'm just in the idiot minority. Okay, that's probably the case.
Do passage tags work differently in Sugarcube? I have a few different looks for sections of my story and in Sugarcube elements of all of my tagged CSS seem to be applied at once, so things like the background pictures aren't changing when they should. This is probably causing the font issue and background colour issue I mentioned briefly earlier.
There's a slowly growing set of documentation that should help. Specifically, you should look at the HTML Layout section of the basic reference docs for more info on SugarCube's HTML structure.
You could also post a snippet of the CSS that isn't working and I'll see if I can help you out.
So I have a passage tagged "stairs", and this in a stylesheet with the same tag: This links to a passage tagged "forest", and I have a separate stylesheet with the forest tag containing this: I also have an untagged stylesheet modified from one of L's with this: In Sugarcane, both passages have the CSS from the untagged stylesheet, with elements replaced by the ones in the stylesheets they are tagged to. So the "stairs" tagged passage has a black page background with the stairs image and a transparent black passage background. When the story moves to the "forest" tagged passage, the stairs image is replaced by the two images in the "forest" stylesheet and the page and passage background colour become white and grey respectively.
In Sugarcube however both passages display the "stairs" image, and both have a black page background and a white passage background. So maybe I've messed up the ordering of the stylesheets, which doesn't matter in Sugarcane but does in Sugarcube?
Thanks so much for reading, sorry to be a nuisance!
Also, I was intending "bookmark" to do something else: cause the Bookmark link to appear conditionally when Bookmark is off. This would enable a "limited undo" that could only send you to certain specific prior passages. (Which is basically what Rewind already does...)
It's not the ordering, it's the fact that you're providing the same selectors with different rules. Obviously, that was working for you in Sugarcane, so it seems that the vanilla headers are doing something "interesting" again (/sigh). I'll have to look at the code to see what's going on, because what you have there isn't how you'd normally go about doing what you're trying to do.
As for as the data-tags, yes and no. Yes, you'd need to add the tags to your CSS selectors, so that the styles only affect what they're supposed to. However, SugarCube doesn't use the data-tags attribute itself, it flags elements directly with IDs and classes. In particular, SugarCube adds passage tags to the <body> element as classes.
So, in the case of your "stairs" and "forest" tagged passages, for example, what you'd normally do in SugarCube is something like this: Question: Where's the "dream" data-tag on the links coming from?
Regarding the "dream" tag, that stylesheet was pulled out of another story that had a "dream" section and then added to. So I've left it in through sheer messiness, but it's not doing anything in this story.
Regardless, background colours and images are changing when they should, which is awesome!
There's a few more issues, though. Firstly, the link colours aren't showing as they do in Sugarcane. I've attached a screenshot to illustrate this.
Secondly, everything is bigger in Sugarcube! By which I mean all text and the passage width and height itself. I'm guessing this is something I'm doing wrong in the CSS again.
Below is my updated stylesheet. I simplified the stairs image thing before, there's actually a few different images. Again, that's all working perfectly now. Between the html and body stuff is bits of code which I didn't know where to put, but seem to work where they are besides the hide sidebar code. Where should I put the hide sidebar code? Also, where should I put the CSS for the Sugarcube version of the revision macro? Right now I have it in a separate stylesheet.
Sorry to bombard you like this!
Stylesheet:
Depends. Were you trying to refer to the <body> element in the first one there and accidentally added a period to the front of it, which transforms it into a class named "body"?
If you actually meant to refer to the body element, then the answer is: Yes, there is a difference in specificity, but it's very minor. So minor, in fact, that I wouldn't worry about prefacing .passage with it.
All instances of the class selectors .internalLink and .externalLink should be replaced with .link-internal and .link-external respectively.
I believe SugarCube's base font size might be a little bigger or maybe using a slightly different font. (Checking Sugarcane) Yes, it looks like SugarCube base font size for the body ends up being about 2px larger. That will need adjusted.
The #sidebar selector will need to be changed to #ui-bar.
A separate stylesheet tagged passage is fine for that.
Anyway, I've integrated the changes noted above into your latest CSS and I also rearranged things a bit. You definitely have some conflicts in there, with the base link styles in particular, and I'm not sure if those flavor selectors are going to work, but this should at least be closer to what you want.
Give it a try:
Oh, there is one teensy appearance difference, while font size and passage width are now identical, the line spacing is a pixel or two greater in Sugarcube. This doesn't bother me at all, just thought I'd let you know in case it was helpful.
Now, I've only found one mechanical problem so far, but it's a biggie. Variables are acting all skewy, and things are misfiring as a result. Is it at all possible there's a bug caused by the either() shim provided earlier in the thread? It seems very unlikely that it's a problem with Sugarcube itself, so I'm going to have a look at replacing eithers with arrays and see if that fixes it.
Mad, I owe you one HUGE credit, and a beverage of your choice, when this thing is done. ;D
I'd rate that as unlikely, the shim is pretty simple. You using any scripts? 3rd-party macros? Where are things going screwy?
Oh yeah, dropbox! I'll PM you a link momentarily if you don't mind taking a look.
Variables must be initialised in Sugarcube
You can't have a space in <<else if...>> clauses
Switching everything over was completely painless, purely thanks to TheMadExile's boundless helpfulness!
Now, on to the reason I went to Sugarcube in the first place. I want to have a save link in my game (without using the ui/sidebar). I'm sure there was a thread about this, but I can't find it now. So how can I call the save function?
They're in a larger thread that might also be useful.
For anyone else looking, Erik's code is this:
I'd like to set a variable and display some text when the menu is used. Would it be possible to trigger the saves menu from inside a <<replacelink>>?
A $variable in general or the same $variable? Same question for the text.
I don't believe so, no.