Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

[Sugarcube 2] Getting started with macro set: Undefined is not a function

Having successfully used Leon's <<replace>> macro set with Twine 2, Sugarcube 1 for a previous project, I upgraded to Sugarcube 2 for what I'm working on now, but find myself unable to use the Sugarcube 2 <<replacelink>> macro set.

I'm using the downloaded version of Twine 2.0.8, and a local/offline version of SugarCube 2 (2.0.0-beta.7), with a freshly downloaded copy of the <<replacelink>> macro set from http://www.motoslave.net/sugarcube/2/, which I dropped into my story using Edit Story Javascript. It's the only thing I've added to my story's Javascript, so it's not a conflict, at least.

When I try to use any of the macros in the <<replacelink>> set, I get an "undefined is not a function" error. For example, both of the following fail:
<<replacelink "Start">>Finish<<endreplacelink>>
<<replacelink>>Start<<becomes>>Finish<<endreplacelink>>

...with the message, "Error: cannot execute macro <<replacelink>>: undefined is not a function". (The "Start" links appear, but do nothing when clicked).

Likewise, attempting to use this:
<<revision changethis>>Start<<becomes>>Finish<<endrevision>>
<<reviselink changethis "Click me to change it!">>

...results in the message, "Error: cannot execute macro <<reviselink>>: State is not defined"

So I'm guessing I've made some really fundamental mistake somewhere, but I can't figure out what I might be doing wrong. Thank you for any guidance you can provide.

Comments

  • edited October 2015
    SugarCube v2.0.0-beta.8 was recently released which included changes to how the internals of SugarCube work, I believe that the downloads like replacelink were also updated to work with the new beta.8

    So you may need to update to the latest SugarCube 2, because I tested you code with beta.8 and they worked correctly.
  • edited October 2015
    greyelf is correct. Due to the recent Chromium v45 inanity, SugarCube 2.x received a major refactor of some of its internals. Overall, the refactor was a good thing, but not being forced into it would have been nice.

    If you only recently downloaded the <<replacelink>> macro set, then the version you have is only compatible with SugarCube v2.0.0-beta.8 and onward, so you'll need to grab beta.8 as well.
  • Finally had a chance to try this and, yup, that was the problem. The "updated 6 days ago" flag on the macroset download probably should have clued me in, but I just didn't think to update to the latest copy of Sugarcube.

    Thank you so much!
Sign In or Register to comment.