Howdy, Stranger!

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

in the sidebar (SugarCane)

I want to add a textinput to the sidebar so that people can add notes to themselves, to be collected in a notebook, during the game. However, it does not seem to actually send it to the variable, instead sending 0 or "".
<<textinput $journaladd [[Add to Notebook|Notebook]]>>
However, when I put this same code inside a passage, it works. Is there something simple I'm missing, or a workaround for this? Thank you very much!

Comments

  • Hi, I don't want to take over thread, as I have same issue, I figured it would be better to post here instead of making a whole new thread. I want to do something very similar, but have "Notebook" in left menu which takes you to a page with a <<textinput $typemantra [[Add entry a|notebook]] >> or something like that, and each time you hit Add entry it would add the text to a new line, and with a back button that would take you back to the page where you clicked on Notebook in menu.

    Edit>> Using Twine 1.4.2, with SugarCube
  • I can fix your problem! Send the text-input to "$journaladd" and then use this code on the passage it refers to:
    <<if $journaladd is 0>><<set $journaladd to "">>Everything in the journal:<<set $journalfull to ($journalfull + "<br>") + $journaladd>><<endif>>
    <<print $journalfull>>
    This will add an extra line every time.

    However, I still can't figure out how to work around the Sidebar Restriction. Can anyone comment on why I can't process forms that are located in the sidebar?
  • @gregkarber:

    gregkarber wrote:

    I want to add a textinput to the sidebar []


    The way Sugarcane is currently written does not allow for using its &lt;&lt;textinput&gt;&gt; macro outside of the main passage display area (there are a few macros like that, actually).


    @Karmina:

    Karmina wrote:
    Edit>> Using Twine 1.4.2, with SugarCube


    SugarCube does not have a &lt;&lt;textinput&gt;&gt; macro.  Its text input macros are &lt;&lt;textbox&gt;&gt; and &lt;&lt;textarea&gt;&gt;.  So, you're either a little confused (i.e. actually using Sugarcane) or doing something you probably shouldn't be (i.e. trying to add a moldy copy of &lt;&lt;textinput&gt;&gt; to SugarCube).
  • @ TheMadExile, yea my bad, I just finished a big story in sugarcube, started a new one and forgot to set it to sugarcube, so I was using cane >.< Guess I will be doing this in sugarcane then.

    I am still having trouble with gregkarber's advice however. I don't know if I am following it correctly. Can someone step me through it slowly? I have: A passage linking to "Notebook" in the sidebar.

    On the Notebook page I have only:
    <<textinput $journaladd [[Add to Notebook|$journaladd]]>>
    Then that links to a passage called $journaladd, and on this page I have:
    <<if $journaladd is 0>><<set $journaladd to "">>Your journal:<<set $journalfull to ($journalfull + "<br>") + $journaladd>><<endif>>
    <<print $journalfull>>
    This page prints only "0", and then there is no more text input to add more lines (i added one but it just wrote over whatever I had previously typed in.)

    I have basic twine coding skills, and I have tried messing around with several different options but I still can't figure it out.

    Also how would I get the story back to the page where I clicked on Notebook?

    Also, thank you guys for the responses :)
  • Karmina wrote:

    @ TheMadExile, yea my bad, I just finished a big story in sugarcube, started a new one and forgot to set it to sugarcube, so I was using cane >.< Guess I will be doing this in sugarcane then.


    Or, you could simply change the story format to SugarCube (you can change formats at any time).  SugarCube's &lt;&lt;textbox&gt;&gt; macro serves the same purpose as the vanilla format's &lt;&lt;textinput&gt;&gt; macro.


    Anyway, I've attached two examples.  One for SugarCube and one for Sugarcane.
  • Using SugarCube, it is also possible to do it all within a single passage without needing to reload the passage:

    In your StoryInit passage set you a $journal variable:

    <<set $journal to []>>
    Then in your Notepad passage do the following:

    <<return>>

    New Entry: <<textbox "$entry" "">><<button "Add">>
    /% If the user entered a value %/
    <<if $entry>>
    /% Add new entry to end of the journal %/
    /% or if you prefer to add the entry to the start/top, then replace the following push() with a unshift() %/
    <<set $journal.push($entry)>>

    /% reset the variable and textbox so it wont automatically add the same entry if the Add button is pressed %/
    <<set $entry to "">>
    <<run $("#textbox-entry").val("")>>

    /% Display the updated journal %/
    <<replace "#journal">><<print $journal.join("\n")>><</replace>>
    <</if>>
    <</button>>

    Your Journal:
    <span id="journal"><<print $journal.join("\n")>></span>
  • Thanks guys, got it working.  ;D
Sign In or Register to comment.