Howdy, Stranger!

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

...Slice is undefined in SugarCube (instead of 'i')

I restarted in a different browser, and a similar problem. I cannot play anything I create, the error starts out as 'slice' undefined, but if I refresh it becomes 'i' undefined.
As previously, I did nothing crazy, just changed background colour and added a couple of Google Fonts. Nothing at all with variables.
See attached error messages from when I open the inspector.

Comments

  • Hmm. It's odd that it's followed on to another browser.

    Is this something for your eyes only or is it something you would be willing to share? I can take a look at it to see if it will compile or explode for me (n.b. I'm the developer of SugarCube).
  • See attached for an archived version.
    it won't let me export it.
  • Well that was an interesting 30 minutes. Browser vendors are terrible, terrible people.

    Quick fix: Either change the name of your title image to anything other than title.png or quote it. For example:
    /* Quoting the image name. */
    [img[here is my title image.|"title.png"]]
    
    /* Changing the image name to something else.*/
    [img[here is my title image.|splash.png]]
    

    Long term: I'll add a workaround to SugarCube.
  • What was happening??
  • First a little background.
    There's been a "feature" for some years in which "named" elements in the DOM (mostly those bearing an id attribute or select others bearing a name attribute) were added to the document object. It's a daft feature which should never have seen the light of day, since it pollutes the document namespace (property-space, really, but the concept is the same) and can cause collisions with native document properties.

    Enter Microsoft, who decide that adding these "element properties" to document isn't enough. Oh no. They decide to add them to window as well (with the same namespace pollution issues as before). Also, as you may know, properties on window are also auto-globals, so now these "element properties" are accessible globally. Go Microsoft!

    But wait, it gets better! In the last few years the other browser vendors (and the W3) have decided to implement and standardize both "features", so now all browsers implement this insanity.


    What does that mean for you?
    SugarCube has an element with the ID title, which, as explained above, is globally accessible as the auto-global title. So, the text title.png was being interpolated as an attempt to access the property png on the auto-global title, rather than simply some text.

    The "quick fix" I mentioned in my previous post forces interpolation as text, so everything works as it should.
Sign In or Register to comment.