Howdy, Stranger!

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

How do I Insert macros into descriptive paragraphs without affecting structure

edited February 2016 in Help! with 2.0
Hi all,

I'm using Sugarcube for twine 2.0 and what I want to do is have a character display sheet that the player can pop in and out of whenever they want as they progress. As the game goes on certain stats will increase which will change the descriptors used in the character display sheet.

rough eg.

<<set $player = {
gender: "man",
age: 42,
class: "warrior",
height: 72,
strength: 1,
magic: 2,
hair: "brown",
eyes: "brown",
}>>

You are a 42 year old male warrior. You are 72 inches tall, have a very thin build and a small amount of magic circulates around you

So the job of inserting "42", "male", "warrior" and "72" is no trouble but the other two are where I have trouble. I want certain descriptors to display depending the characters strength and magic without messing up my paragraph structure.

What I have now is sort of like this:

You are a <<print $player.age>> year old <<print $player.gender>> <<print $player.class>>. You are 72 inches tall, have a <<if $player.strength lte 2>> very thin build <</if>> <<if $player.strength gt 2>> thick build <</if>> ....etc, etc.


Doing it like this ruins the look of the paragraph when I go to play my game. I get something like this:

You are a 42 year old male warrior. You are 72 inches tall, have a __________________________________very thin build and a_____________________________________________________________small amount of magic circulates around you

I know there has to be a better way and I've looked over http://www.motoslave.net/sugarcube/1/docs/special-names.html but I'm very new to all this. I don't really have any dreams of being a coding wizard or anything just wanted to make a simple game. Any and all help is much appreciated!

Thanks,



Comments

  • edited February 2016
    You need to state which Story Format you are using, as answers can be different for each one. I am going to assume you are using SugarCube 1 based on the fact you included a link to it's documentation.

    You can used the <<widget>> macro to create your own set of custom macros to which you can use to output the player information:

    1. Create a new passage, the title is not important but I named mine Widgets. Give this new passage a widget tag as well as a nobr tag.
    Place the following within the widget tagged passage, it creates a widget per player attribute you want to show as well as a widget for constructing and displaying the combined player info:
    <<widget "player-age">>
    	<<print $player.age>>
    <</widget>>
    
    <<widget "player-gender">>
    	<<print $player.gender>>
    <</widget>>
    
    <<widget "player-class">>
    	<<print $player.class>>
    <</widget>>
    
    <<widget "player-height">>
    	<<print $player.height>>
    <</widget>>
    
    <<widget "player-build">>
    	<<if $player.strength lte 2>>
    		<<print "very thin build">>
    	<<else>>
    		<<print "thick build">>
    	<<endif>>
    <</widget>>
    
    <<widget "player-magic">>
    	<<if $player.strength lte 2>>
    		<<print "small amount of magic circulates around you">>
    	<<else>>
    		<<print "some other magically description">>
    	<<endif>>
    <</widget>>
    
    <<widget "player-info">>
    	<<print "You are a <<player-age>> year old <<player-gender>> <<player-class>>. You are <<player-height>> inches tall, have a <<player-build>> and a <<player-magic>>">>
    <</widget>>
    

    To show the player information within a passage do the following:
    <<player-info>>
    
  • You're awesome, thank you so much! Super fast! I'll definitely be sticking around this forum.

    Thanks!
Sign In or Register to comment.