Howdy, Stranger!

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

Stats system (SugarCube)?

edited October 2015 in Help! with 2.0
I suppose this would be the correct place for it since it's still Twine 2.0, but I'm curious if there's been any stats systems implemented for SugarCube in conjunction with inventory systems/item use? Particularly for an RPG type game?

I don't mind writing a scripted thing, but it'd be cool to have different options based on stats at the most to choose from.

http://twinery.org/forum/discussion/2982/basic-stat-system I was looking at this thread but I can't get the code to work in a test environment. I understand what the code is doing and I could use it, but it's not working in SugarCube 1.x.x

Comments

  • Got it nvm.

    Using
    What sort of exercise would you like to do?
    
    <<if $strength === 0>>
    	[[Free Weights]]
        <<set $strength to 1>>
    <<endif>>
    

    Then clicking the according link, it ups strength to 1. Hopefully I can branch out from this and hopefully this is helpful to anyone else.
  • edited October 2015
    Ideally the <<set $strength to 1>> part would be within the Free Weights passage otherwise you are increasing the $strength variable even if the reader does not select the option.

    eg. In your StoryInit passage you would initialize your $strength variable to zero:
    <<set $strength to 0>>
    
    ... next in one of your passages you would have something like the following:
    What sort of exercise would you like to do?
    
    <<if $strength is 0>>[[Free Weights]]<</if>>
    
    ... and finally within the Free Weights passage you would have something like:
    After doing some exercise using the Free Weights you feel a little stronger!
    <<set $strength to $strength + 1>>
    
  • Do you need to stick with Sugarcube? I like Sugarcube a lot, but I tend to use Harlowe and the (datamap:) macro when doing stat systems.
  • Do you need to stick with Sugarcube? I like Sugarcube a lot, but I tend to use Harlowe and the (datamap:) macro when doing stat systems.
    SugarCube 2.x also ensures that authors can use Maps and Sets, which is all Harlowe's datamaps and datasets are in the end. Beyond that, in SugarCube 2.x or 1.x, authors may also use generic objects for the same purpose.

    Additionally, there's nothing wrong with doing each statistic as a separate variable, so what exactly about a few statistics calls out for a Map, specifically I mean? I'm not trying to be antagonistic here. It simply seems like since Maps are pretty much the only data structure Harlowe offers, which would be useful here specifically, you seem to be falling to the notion of Maslow's hammer.

    I'm not saying Maps wouldn't be appropriate here, they would, but they're no more appropriate than using separate variables or other data structures, like generic objects.

    I'm also not saying not to use Harlowe. If you like its syntax, then by all means do so. However, it's a bit disingenuous to imply that SugarCube lacks similar capabilities (or, for SugarCube 2.x, the exact same capability, Maps).
  • Is it hard to learn to equate SugarCube's macros and stuff like that over to Harlowe? Would I even be able to create what I want to create at this point in time in Harlowe as well? (i.e inventory system and stat system)

    At this point in time, unless there's inventory code that I can switch to that works in Harlowe, I have to use SugarCube. The code for SugarCube seems easier to understand anyway @cressidahubris but I'm probably eventually going to move to Harlowe. I just like making RPG-ish stuff, so it made sense for me to start in SugarCube because I needed an inventory system, and I didn't find any working code in Harlowe for that, so, eh. Unless I didn't look hard enough.

    Also thanks @greyelf, I thought the code had to be something like that but I was working on it after 5 or so hours and decided that would be fine. I was planning on having it where a person would be able to choose an option, and it would lead to a passage where the str+1 would be on it, and then they would continue on. Or a cha+1 or dex+1, etc, etc.

    Also I was having trouble with the
    After doing some exercise using the Free Weights you feel a little stronger!
    <<set $strength to $strength + 1>>
    
    bit as well, but this solves it. Thank you!
  • The story format defines the default look of a story, it defines the syntax of the macro language it uses and the default set of macro available to the Author, it also defines the core features available to the Author and if those features are extendible and the methods the Author can use to extend them.

    The choice of which story format to use is a personally one but here are some things to look for when making that choice as a novice.

    a. Documentation:
    Having access to well written documentation with examples can be a major benefit to someone learning, they also help more experienced people as well.

    b. Macro Syntax:
    Flame wars have been started over which programming languages (and that is what the macros are) are easier to use than others, but the simple fact is that some people will find that one syntax makes more sense/feels more comfortable to them than another does and this is normal.

    c. List of Available Macros:
    It is a good idea to read through a story format's documentation to create a mental overview of the sort of macros that are available.

    d. Extendibility:
    Does the story format support the adding of custom macros, does it support extending the built-in features and does it support adding new features. If it does support any of the previous three abilities then does it do so using built-in methods or is resorting to using Javascript the only method available.

    e. Update Frequency and Access to Story Format's Developer:
    How quickly are bugs fixed and new features added? How easy is it to access the Developer to ask questions?
  • Ugh, I can't imagine just using javascript. The macros in SugarCube are really nice.

    Though, honestly, I was looking at another RPG game in Twine 2 and the Harlowe dataset looks really easy to use. I just wish there was an inventory system with some established code or something I could use in Harlowe, cause then I would switch.

    That, and I like being on the cutting-edge of things, lol.
  • Setari wrote: »
    That, and I like being on the cutting-edge of things, lol.
    If by this comment you are saying that you think that Harlowe is more cutting-edge than SugarCube then I think you may be mistaken.

    As TheMadExile stated above, SugarCube supports all the datatypes that Harlowe does:

    a. Harlowe: Array, Set (dataset) and Map (datamap)
    (set: $array to (array: "one", "two", "three"))
    (set: $set to (dataset: "nine", "eight", "seven"))
    (set: $map to (datamap: "name", "John Smith", "age", 18, "health", 100))
    
    array: (print: $array)
    set: (print: Array.from($set))
    map: (print: $map)
    

    b. SugarCube: Array, Set, Map and Object
    <<set $array to ["one", "two", "three"]>>
    <<set $set to new Set(["nine", "eight", "seven"])>>
    <<set $map to new Map([["name", "John Smith"],["age", 18],["health", 100]])>>
    <<set $object to {"name": "Jane Smith", "age": 18, "health": 100}>>
    
    array: <<print $array>>
    set: <<print Array.from($set)>>
    map: <<print $map>>
    object: name: <<print $object.name>> age: <<print $object.age>>
    
  • Whoa... I only asked if they were set on using Sugarcube because I could help them with doing it in Harlowe. I think you read waaaaaaay too much into a simple question.
    Do you need to stick with Sugarcube? I like Sugarcube a lot, but I tend to use Harlowe and the (datamap:) macro when doing stat systems.
    SugarCube 2.x also ensures that authors can use Maps and Sets, which is all Harlowe's datamaps and datasets are in the end. Beyond that, in SugarCube 2.x or 1.x, authors may also use generic objects for the same purpose.

    Additionally, there's nothing wrong with doing each statistic as a separate variable, so what exactly about a few statistics calls out for a Map, specifically I mean? I'm not trying to be antagonistic here. It simply seems like since Maps are pretty much the only data structure Harlowe offers, which would be useful here specifically, you seem to be falling to the notion of Maslow's hammer.

    I'm not saying Maps wouldn't be appropriate here, they would, but they're no more appropriate than using separate variables or other data structures, like generic objects.

    I'm also not saying not to use Harlowe. If you like its syntax, then by all means do so. However, it's a bit disingenuous to imply that SugarCube lacks similar capabilities (or, for SugarCube 2.x, the exact same capability, Maps).

  • edited October 2015
    Not so. The implication may have been unintentional, in fact I believe that it was unintentional, but that doesn't change the fact that it's there (paraphrased, "I like SugarCube, but Harlowe has Maps", thus implying that SugarCube does not).
  • I never said that Harlowe has maps and SugarCube does not. I said, "Do you need to stick with Sugarcube? I like Sugarcube a lot, but I tend to use Harlowe and the (datamap:) macro when doing stat systems."

    Meaning, my personal preference, between the two formats, is to use Harlowe in that situation. It doesn't mean that you can't use SugarCube or that other people don't use SugarCube. It says exactly what I mean for it to say: I prefer to use Harlowe, and if the person asking the question is flexible and would switch to Harlowe to make their stat system, I could personally help them. If not, someone else would hopefully step up to help them.

    And Greyelf came in and helped the person, so thank you.
  • edited October 2015
    I did not say that you said it outright. Beyond that, I have said that I believe that the implication was not made intentionally (i.e. it was done accidentally). It is there, however, and no amount of "nuh uh" on your part is going to change the fact that "I like X, BUT Y has Z" makes an implication about X as related to Z.

    EDIT: To be clear, this isn't about you, nor is this about Harlowe. I don't care which story formats people choose to use (I've given help on Harlowe before, and likely will continue to do so). This also isn't about what you intended to say. It's about your specific wording and the implication therein. I wouldn't have felt the need for my original post on this topic had you said something like, "You can also do this in Harlowe. In particular, I like using (datamap:) for this sort of thing.", which doesn't call out SugarCube or make any implications at all.

    And I'm done with this derailment.
  • edited October 2015
    Hah, I actually learned a lot from that bit of derailment so thank you for that. It's nice that someone expands on something like that for other people to read about, and learn from.

    @TheMadExile it's cool lol

    Oh and @greyelf so it's possible to work with an inventory in Harlowe then? Also by cutting edge, I just meant that Harlowe came with the release of Twine 2 or so I've been given an impression of, so I just meant it's newer.

    Though I wouldn't complain if I could do everything I wanted in Harlowe's macros and never touch Javascript ever again. I'm gonna go look for the Harlowe documentation...

    Edit: Still working in sugarcube, by chance does anyone know how to make an if statement and a link but using a stat? I have:
    <<if $built === 1>>[[Click here to go to the next section!|Built]]<<endif>>
    <<if $pudgy === 1>>[[Click here to go to the next section!|Pudgy]]<<endif>>
    <<if $sickly === 1>>[[Click here to go to the next section!|Sickly]]<<endif>>
    
  • edited October 2015
    I've also used "is", and "eq" in the place of the "===" and nothing. I know it's going to be something simple again -_- Edit: Also tried changing the "1" to "true" and using "is" and "eq" and "===" but nothing still. Hm.
  • edited October 2015
    Setari wrote: »
    […] so it's possible to work with an inventory in Harlowe then?
    Yes, whether you use the (datamap:) macro or not, which as I noted above isn't a bad idea. The only issue is that you wouldn't have inventory macros, but you don't really need them (in Harlowe or SugarCube).

    Setari wrote: »
    Also by cutting edge, I just meant that Harlowe came with the release of Twine 2 or so I've been given an impression of, so I just meant it's newer.
    Newer does not mean better. And, for that matter, SugarCube 2.x is newer (in most respects) than Harlowe, so that must mean it's more cutting edge and better.

    Note: I am not actually saying that SugarCube 2.x is better than Harlowe, they're different and that's about all you can say, outside of personal preference.

    Setari wrote: »
    Though I wouldn't complain if I could do everything I wanted in Harlowe's macros and never touch Javascript ever again. I'm gonna go look for the Harlowe documentation...
    I believe that the Harlowe page on neocities is the most complete source, though I think that it's a little outdated now.

    Setari wrote: »
    Edit: Still working in sugarcube, by chance does anyone know how to make an if statement and a link but using a stat? I have:
    <<if $built === 1>>[[Click here to go to the next section!|Built]]<<endif>>
    <<if $pudgy === 1>>[[Click here to go to the next section!|Pudgy]]<<endif>>
    <<if $sickly === 1>>[[Click here to go to the next section!|Sickly]]<<endif>>
    
    If you haven't already, I'd suggest reading the SugarCube 1.x <<if>> macro documentation.

    What are you setting those story $variables ($built, $pudgy, $sickly) to? What is their purpose? Where are you setting them? What do you actually want to test for in the <<if>> macros?

    Assuming that you've set each of the $variables to the number 1 (not the numeric string "1"), then that should have worked. That said, those conditions will only become true if the $variables are set to exactly 1.

    If you intended to test if they're greater-than-or-equal to 1, or something similar, then you need different operators (as described within the docs I linked).

    Setari wrote: »
    I've also used "is", and "eq" in the place of the "===" and nothing. I know it's going to be something simple again -_- Edit: Also tried changing the "1" to "true" and using "is" and "eq" and "===" but nothing still. Hm.
    Try the following to set your $variables:
    <<set $built to 1>>
    <<set $pudgy to 0>>/% this will disable the Pudgy link %/
    <<set $sickly to 1>>
    
    And the following to test if they're exactly 1:
    <<if $built is 1>>[[Click here to go to the next section!|Built]]<</if>>
    <<if $pudgy is 1>>[[Click here to go to the next section!|Pudgy]]<</if>>
    <<if $sickly is 1>>[[Click here to go to the next section!|Sickly]]<</if>>
    
    Or the following to test if they're greater-than-or-equal to 1:
    <<if $built gte 1>>[[Click here to go to the next section!|Built]]<</if>>
    <<if $pudgy gte 1>>[[Click here to go to the next section!|Pudgy]]<</if>>
    <<if $sickly gte 1>>[[Click here to go to the next section!|Sickly]]<</if>>
    

    Alternatively, if these $variables are supposed to be boolean flags (yes/no, true/false), then instead of using numbers, I'd suggest using actual booleans. For example, to set the $variables:
    <<set $built to true>>
    <<set $pudgy to false>>/% this will disable the Pudgy link %/
    <<set $sickly to true>>
    
    And the following to test if they're true:
    <<if $built>>[[Click here to go to the next section!|Built]]<</if>>
    <<if $pudgy>>[[Click here to go to the next section!|Pudgy]]<</if>>
    <<if $sickly>>[[Click here to go to the next section!|Sickly]]<</if>>
    
  • edited October 2015
    Yeah I'm stupid, I had the right code, I just had to start from the panel before that so I could have it set the correct thing for the story instead of trying to test the link page... I shouldn't work on this stuff after I get home from work... ugh. Thanks @TheMadExile. Ended up figuring out why it wasn't showing up just now. Sorry about that. Tunneling my vision is not good.

    Also thanks for that documentation, I'll go have a gander at that but I'll probably be sticking with SugarCube for this story at least. Also, I have SugarCube 1.0.26, is there a newer version or something somewhere (not a beta version)?

  • There is a newer version of the 1.x series, yes; v1.0.31. The next release of Twine 2 will include it, though it may also be installed as a secondary copy if waiting isn't an option.
Sign In or Register to comment.