Howdy, Stranger!

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

Slow Page Load Times

So I am pretty new to Twine but I have had some experience programming. Not much but some. Now I was working on a small project where the player randomly encounters different creatures and traps and treasure while dungeon crawling. It is basically a rougelike. I know I could have done this in other programs but I wanted to challenge myself and do it in Twine.

My problem is that I have a page of code that seems to choke up twine. It works but only after a 20-40 second freeze up. What could be causing this? Is my code wrong? Am I doing something that is causing it to slow up? Here is the code:
<<nobr>>
<<if $Combat > 0>>
<<print "You did <<$Attack>> damage!">>
<br>
<<print "The <<$Monster_T1>> did <<$Monster_T1_Attack>> damage!">>
<br>
<<endif>>

<<if $Defense < 1>>
<<print "You have been defeated! You wake up back at the [[Shop]]">>
<<endif>>

<<if $Monster_T1_Defense < 1>>
<br>
<<print "You have defeated the <<$Monster_T1>>">>
<br>
[[Return to the Shop|Shop]]
<<endif>>

<<endnobr>>
<<nobr>>
<<if $Defense > 0>>
<<if $Monster_T1_Defense > 0>>
Attack: <<print $Attack>><br>
Defense: <<print $Defense>><br>
Money: <<print $Money>>
<br>
<br>
<<$Monster_T1>><br>
Mosnter Attack: <<$Monster_T1_Attack>><br>
Monster Defense: <<$Monster_T1_Defense>>
<br>
<br>
[[Attack the <<$Monster_T1>>|Fight_T1][$Monster_T1_Defense -=$Attack, $Defense -= $Monster_T1_Attack, $Combat += 1]]<br>
[[Flee to the Shop|Shop]]
<<endif>>
<<endif>>
<<endnobr>>
Please let me know what is going on here again I am pretty new to this program.

Comments

  • The slow down is caused by your <<print>> macro calls with embed display shorthand form macros. eg. <<$variable>>

    When you write <<$variable>> the parser has to work out what you want it to do, are you calling a <<macro>>, are you asking it to <<display>> a passage, or are you asking it to <<print>> a variable's value, and working this out takes a while. Once it worked out that you wanted to <<print>> a variable it then notices that you have embed a <<print>> macro within a <<print>> macro and this causes some recursive magic which it eventually works out. Times this by four instances in your code and it takes a while. I suggest not using the display shorthand form.

    Instead of doing it the way you have, try the following:

    <<print "You did <<$Attack>> damage!">>
    becomes
    <<print "You did " + $Attack + " damage!">>

    <<print "The <<$Monster_T1>> did <<$Monster_T1_Attack>> damage!">>
    becomes
    <<print "The " + $Monster_T1 + " did " + $Monster_T1_Attack + " damage!">>

    <<print "You have defeated the <<$Monster_T1>>">>
    becomes
    <<print "You have defeated the " + $Monster_T1>>
  • Thank you very much for this piece of information. My story runs very smooth now. I had no idea that using the <<>> to declare my variables inside a print macro would cause this problem.
Sign In or Register to comment.