Howdy, Stranger!

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

Getting the replace macro to play nicely with other scripts...

Using Sugarcane.

I'm experimenting with xax's awesome multi-panel design. Unfortunately, I don't seem able to use L's usual replace macros in it. If I include both scripts in the file, opening the game produces Error 1 (see screenshots below). The replace macro will actually function properly within the passage, but when I try to click on a link after that, it produces Error 2.

Does anyone know why they conflict? Is it something to do with the fact that the multi-panel script came from twee?

I'm attaching the tws file with both scripts included.

Comments

  • Oh hey! I'm glad you're enjoying my macro set! This problem is probably my fault! :V

    After a little digging it looks like that while the actual cause of the problem is still mysterious to me, it goes away if you separate out the macro sets into two different passages -- instead of having one "script" passage tagged script, have "panes" and "replace" passages (or whatever), both tagged script. Which... seems to fix it?
  • Hmmm... Separating them did fix Error 1, but I'm still getting Error 2, after the timedcontinue macro runs and I try to click the first passage link. Thanks for coming in to help! Hopefully we can figure this out...
  • Alright, I should have mentioned: that error comes from trying to open it in Opera. Firefox shows a different error:

    " reshowAll@file:///C:/Users/Logan/Desktop/pane%20test.html line 87 > eval:1:27
    macros.linkTo.handler/link.onclick@file:///C:/Users/Logan/Desktop/pane%20test.html line 87 > eval:1:1995
    You may be able to continue playing, but some parts may not work properly. "

    For quick comparison, the Opera error:
    "Uncaught exception: TypeError: Cannot convert 'e' to object."

    and Chrome error:
    "TypeError: Cannot read property 'replace' of undefined at reshowAll, <anonymous>:1:69)
    at HTMLAnchorElement.link.onclick, <anonymous:1:1995)"

    Does any of that...clarify anything? .___.



    edit and wholly unrelated, is there a way to do external links with this design?
    <<link "passage name" "visible text">> is the basic link you have set up, but if I want to open another site rather than a passage... what should I write in place of the passage name?
  • Hmm... so I've been mostly fruitlessly digging in the code for a solution to this, and then had a sudden flash of insight that I was going about trying to solve this in the wrong way. So, the short version is: &lt;&lt;link&gt;&gt; macros won't work inside timed code, due to some fairly fundamental problems between the two macro sets and how javascript handles asynchronous code. However! What's happening (and I really should have put a macro error message there, rather than just some silent broken code -- it's the same issue in all browsers, just the specific part where the code stumbles and falls is different) is that &lt;&lt;link&gt;&gt; can't figure out what pane it's in. If you change the &lt;&lt;link &quot;next left&quot; &quot;click me&quot;&gt;&gt; line to &lt;&lt;linkTo &quot;left&quot; &quot;next left&quot; &quot;click me&quot;&gt;&gt;, that should work!

    Also external links... If you want a standard external link, then you can use the usual twine link format, even inside a pane. If you want an external link but inside a pane... that's definitely not something I was thinking of when I wrote this. What you could do, I think, is make a passage that had an iframe HTML element in it -- &lt;iframe src=&quot;url here&quot;&gt;&lt;/iframe&gt; and then link to that passage.
  • Magnifique! Thanks so much for all your time trying to work this out. :D And in the end, it's such an easy fix too! Excellent news all around, eh?

    So thanks again for designing this and helping me out. If it's possible, you might want to add this explanation to the original thread that documents the layout. I think it'd be useful for future Twiners to know this little trick as well, as most of us use L's macros.
Sign In or Register to comment.