Decrease Money isn't working

J_J

So, I'm just using the built in money feature. It can add money fine, but decrease money doesn't work.
If I have $30 and use the decrease money script (by 7) It ends up looking like this: $3-7. If I subtract another 5 it looks like this $3-12

I haven't changed the code at all. Have other people experience this? Is there a fix?

<showmoney />
    <moneyformat>$30!</moneyformat>

 <object name="air filter credits">
      <inherit name="editor_object" />
      <scenery />
      <displayverbs type="stringlist" />
      <buy type="scriptdictionary">
        <item key="phone">
          firsttime {
            msg ("You add seven dollars.")
            DecreaseMoney (7)
          }
          otherwise {
            msg ("You don't need to add any more money.")
          }
        </item>
      </buy>
    </object>

You have the money format set to $30!. In that format, the ! will be replaced by the player's amount of money (which is initially undefined). So if their money is -7, it will display $30-7. If their money is 10, it will display $3010.


J_J

Thank you so much.


Why use a built-in feature at all for something so simple o_0

game.gold = 0 
game.gold = game.gold + 1
game.gold = game.gold - 1

OR

player.gold = 0 
player.gold = player.gold + 1
player.gold = player.gold - 1
player.gold=!

SHOP

if (player.gold=30) {
 msg ("You buy the thing. Congrations.")
}
else {
msg ("You cannot afford it.")
}

Attribute usage isn't simple for people new to coding/game-making... it takes some time to learn... Attribute (and especially, the 'if' Script) usage.


J_J

Anonynn you are making me a bit nervous. I hope sexy coding isn’t something people look for in the games they play, because I’ve been using the built-in features for everything. As someone who is… not very good at programming, I’ve been really excited by how many complicated things I can do without looking at the coding side of it at all. Quest is the first program that I’ve used where I’ve been able to make it this far into a game. Almost done with my first two room : )
I’m sure I will have so many questions as I get further in.


Don't be nervous ^_^ It takes a long time to start getting comfortable with it. I've been programming now for just about two years, I was exactly where you were at that time. I can tell you, the more you try to learn about coding like writing in code view now and then instead of the GUI, the faster things will get and the more you'll understand :) Give it a try now and then. As for a requirement, not in the least.

Anonynn.


You can do everything you want via the GUI/Editor and can make a simple/basic game, but if you want to make a good/neat (with (cool mechanics and etc) game, you got to at least learn the basics of coding: scripting: Attributes and the 'if' Script usage, which let's you do 90% of everything that you want to do in a game, so, while it's not easy to learn at first, the payoff is enormously large. Though, you can see, that learning further into coding has very diminishing returns, lol. If you want to take your game to the next level, you got to learn scripting: Attribute and the 'if' Script usage.

Also, learning to code, makes everything much faster, allowing you to do more stuff and more cool stuff.

I too found quest, not knowing any coding at all, (5 years ago), and through quest and the people here, I've learned to code, and am currently taking programming classes at college now, for a major/career.


The bigger problem/reason for learning to code, is in learning the 'if/coding' logic needed for game-making, unfortunately. Even if you have no interest in learning to code, game-making requires learning its logic, as it's needed for game-making. You got to train your mind in understanding the logic of 'if/coding/conditionals/etc' for doing what you want for your game, including in using the GUI/Editor and non-coding, and this usually means that you end up learning to code, regardless of whether you wanted to or not.


If/when you're interested in learning to code, let me know, I'll be glad to help.


Otherwise, you can always just ask for help on whatever as you need help, and we'll help through what you need to do and how to do it, without having to learn to code (though you probably will start to learn to code, it's inevitable, as you get help with it, hehe).


J_J

Thanks for the replies, all.

I'm curious about the if script... because I've already been using it for most of the puzzles in my first two rooms. But I've just been using it as it exists in the editor. What are the benefits of coding the if script yourself vs. using it in the editor? So far I've mostly been using it for multidoor lock puzzles and for changing how you can interact with an object or a person based on your actions in the room.

I'm definitely excited to learn more.


"Sexy coding"

The built in features are not always the easiest, however the built in money feature is the only one that at the moment I could not pull of because I don't know how it works.
Anonynn's way is easiest.
If you're interested, here's how I do it.
%Blah...
Start script
Or player attribute. Whatever you use.

player.gold = 0

I make my own commands. Currently it's called "Buy1", because of trouble with the built in buy command, that I'll have to get rid of.

msg ("See something that catches your eye?")
options = Split("Potion (100);Hyper Potion (200)", ";")
ShowMenu ("Shop", options, true) {
  switch (result) {
    case ("Potion (100)") {
      if (player.gold >= 100) {
        player.gold = player.gold - 100
        player.potion = player.potion + 1
        msg ("You bought a Potion.")
      }
      else {
        msg ("You don't have enough gold.")
      }
    }
    case ("Hyper Potion (200)") {
      if (player.gold >= 200) {
        player.gold = player.gold - 200
        player.hyper_potion = player.hyper_potion + 1
        msg ("You bought a Hyper Potion.")
      }
      else {
        msg ("You don't have enough gold.")
      }
    }
  }
}

It's actually easier than it looks! The ShowMenu just has a lot of bells and whistles!


oh, there's nothing different between in-code and using the GUI/Editor with the 'if' Script (or the 'switch' Script: it's the exact same as the 'if' Script but has a different style/look/format to it), if you already understand how to use it, as I was referring to the 'if' logic involved, which takes times for most people to train their brain in doing, for examples (in code):

<object name="room">
  <inherit name="editor_room" />
</object>

<object name="player">
  <inherit name="editor_object" />
  <inherit name="editor_player" />
  <attr name="parent" type="object">room</attr>
  <attr name="experience" type="int">0</attr>
  <attr name="currency" type="int">0</attr>
</object>

<object name="orc">
  <inherit name="editor_object" />
  <attr name="parent" type="object">room</attr>
  <attr name="displayverbs" type="listextend">loot</attr>
  <attr name="dead" type="boolean">false</attr>
  <attr name="experience" type="int">50</attr>
  <attr name="currency" type="int">100</attr>
  <attr name="loot" type="script">
    if (orc.dead) {
      firsttime {
        player.experience = player.experience + orc.experience
        player.currency = player.currency + orc.currency
        msg ("You loot the dead orc's corpse")
      } otherwise {
        msg ("You've already looted the dead orc's corpse, silly.")
      }
    } else {
      msg ("The orc isn't dead yet, silly.")
    }
  </attr>
</object>

<verb>
  <property>loot</property>
  <pattern>loot</pattern>
  <defaultexpression>You can't loot that!</defaultexpression>
</verb>

<!--
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-->

<object name="school">
  <inherit name="editor_room" />
  <object name="math_class">
    <inherit name="editor_room" />
  </object>
</object>

<object name="test">
  <inherit name="editor_object" />
  <attr name="parent" type="object">math_class</attr>
  <attr name="drop" type="boolean">false</attr>
  <attr name="take" type="boolean">false</attr>
  <attr name="score" type="int">-1</attr>
  </attr name="grade" type="string">unknown</attr>
  <attr name="displayverbs" type="listextend">set_score</attr>
  <attr name="set_score" type="script">
    <![CDATA[
      msg ("Score?")
      get input {
        if (IsInt (result)) {
          input_integer_variable = ToInt (result)
          if (input_integer_variable > -1 and input_integer_variable < 101) {
            test.score = input_integer_variable
            do (test, "set_grade")
          } else {
            do (test, "set_score")
          }
      } else {
        do (test, "set_score")
      }
    }
    ]]>
  </attr>
  <attr name="set_grade" type="script">
    <![CDATA[
      if (test.score > 89) {
        test.grade = "A"
      } else if (test.score > 79) {
        test.grade = "B"
      } else if (test.score > 69) {
        test.grade = "C"
      } else if (test.score > 59) {
        test.grade = "D"
      } else {
        test.grade = "F"
      }
    ]]>
  </attr>
</object>

<verb>
  <property>set_score</property>
  <pattern>set_score</pattern>
  <defaultexpression>You can't set the score of that!</defaultexpression>
</verb>

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums