Howdy, Stranger!

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

widget help

Hi,

I am using sugarcube and have a problem. I created a clothing system. That means you stand up in the morning you can choose which clothes you want to wear. When you go to bed I run the script <<undress>>
<<widget "undress">>
<<set $top = 0>>
<<set $pant =0>>
<<set $socks = 0>>
<<set $shoes = 0>>
<</widget>>
At the next day you choose your clothes again. But now I stuck at a problem. You are at the swimming pool.  You are a a medical examination. So I run my <<undress>> widget. When that is done I want to make that you wear that clothes that you removed before you undressed the last time. Is that possible. I tryed it with remember but stuck at it. Please help me.

Comments

  • Zulu wrote:

    At the next day you choose your clothes again. But now I stuck at a problem. You are at the swimming pool.  You are a a medical examination. So I run my <<undress>> widget. When that is done I want to make that you wear that clothes that you removed before you undressed the last time. Is that possible.


    Since you're setting them to zero in your code sample, I assume that your clothing values are also integers?  If so, you simply need to create another set of $variables for the last worn clothing and set them in &lt;&lt;undress&gt;&gt;.  For example:

    <<widget "undress">>\
    <<set
    /* Preserve the IDs of the last worn clothing set. */
    $lastTop = $top,
    $lastPant = $pant,
    $lastSocks = $socks,
    $lastShoes = $shoes
    >>\
    <<set
    /* Remove all clothing. */
    $top = 0,
    $pant = 0,
    $socks = 0,
    $shoes = 0
    >>\
    <</widget>>
    Then you could use a widget (e.g. &lt;&lt;redress&gt;&gt;) to restore any existing last worn clothing set.  For example:

    <<widget "redress">>\
    <<if $lastTop neq 0 or $lastPant neq 0 or $lastSocks neq 0 or $lastShoes neq 0>>\
    <<set
    /* Restore the last worn clothing set. */
    $top = $lastTop,
    $pant = $lastPant,
    $socks = $lastSocks,
    $shoes = $lastShoes
    >>\
    <<set
    /* Discard the last worn clothing set now that it's been restored. */
    $lastTop = 0,
    $lastPant = 0,
    $lastSocks = 0,
    $lastShoes = 0
    >>\
    <</if>>\
    <</widget>>

    Zulu wrote:
    I tryed it with remember but stuck at it.


    My standard mantra about the use of &lt;&lt;remember&gt;&gt; is like the trite aphorism about regular expressions:
    [quote]Some people, when confronted with a problem, think "I know, I'll use &lt;&lt;remember&gt;&gt;".  Now they have two problems.

    Basically, &lt;&lt;remember&gt;&gt; is almost never the solution to anyone's problem.
  • Thank you. It worked very great.

    Now I stuck at another point. Maybe someone can help there to.

    First:
    Im plan to add a skill system. Skills like cooking and so on are easy to code. They improve by doing it but some other raise with time. Let us take high heels as example. The skills improve when you wear them and that over time. Now Im searching for a way that improves the skill when you wear heels and walk. I tried it with a widget:
    <<widget "skill">>
    <<if $Shoes is 1 Heels>>
    <<set $skill.heels += 0,1>>
    <<endif>>
    <</widget>>
    But now I have to write at every passage <<skill>>
    Is there an easier way?

    Second:
    I want that it increase the skill to a maximum point. If you wear low heels you cant walk in high heels. So it would be the best:
    <<if ($Shoes is 1 Heels) + ($skill.heels lt 1)>>
    <<set $skill.heels += 0,1>>
    <<if ($Shoes is 3 Heels) + ($skill.heels lt 3)>>
    <<set $skill.heels += 0,1>>
  • If you want the code run in every passage, then it sounds like you could simply put your conditionals in the PassageDone special passage, which is executed just after the rendering of each passage.  For example:

    <<if $Shoes is "1 Heels">>
    <<if $skill.heels lt 1>><<set $skill.heels += 0.1>><</if>>
    <<elseif $Shoes is "3 Heels">>
    <<if $skill.heels lt 3>><<set $skill.heels += 0.1>><</if>>
    <</if>>
    A couple of notes:
    • You appear to be quoting things with smart/curly quotes in code parts.  Don't do that, at least not within code parts.  It's okay in normal passage text.
    • If I'm not mistaken, you also cannot use your local radix/decimal point character in code parts (at least with actual numbers).  Only the period (dot, full stop) character is allowed as the radix point in code parts.
Sign In or Register to comment.