Increasable/decreasable variables?

Hi! Noob here
I'm making my first game ussing Quest, and I'm trying to figure out how to have something that can increase or decrease in value by script relative to the previous value
What I mean by that is I'd like to have something like money where instead of just using scripts to set an attribute or variable value to a certain number, you can increase it by a certain amount. I'm trying to create lots of these "variables" for my first game where I'm going to have the player's actions/commands/items in inventory/etc. influence these variables to change NPCs' responses and actions to suit them. For example, I'd like a variable named 'Trust' that increases or decreases based on how you interact with a certain NPC, and I can use that to change the NPC's responses with if scripts and such.
So yeah
Thanks for helping uwu


Are you using the desktop Quest or the online Quest?


First, you need to make sure all your attributes have an initial value set (otherwise when you increase or decrease them you will get complains that you cannot add ints to objects or something like that).

To increase an attribute "count" on the player object, add a new script, and go to the "Variables" bit; select "Set a variable or attribute". Then fill it in like this (the square brackets are to indicate the boxes#):

Set variable [player.count] = [expression] [player.count + 1]


I'm using the desktop version of Quest

Thanks! does it have to be named "count" or can it be named something else?


Hello.

You can name it whatever you like. (Just remember it's case-sensitive.)


Thanks! It works beautifully now :3


here's some links/guides to get you started (ask if you need help with anything and/or don't understand something):

http://textadventures.co.uk/forum/general/topic/ljjm32av4e2t9ot49k478g/help#710be61e-eae1-4af1-8363-520cc718ba1c

(see my 'HK's Attribute and IF Script Guide' link, scroll down a bit within it to get to the Attributes and 'if' Script sections, as the top half of it covers some basic stuff with quest and basic coding stuff - though you might want to read it as well, for help on using Attributes and the 'if' Script, these to things, especially used together, let's you do 90% of everything you want to do within your game, they're not easy to learn if you're totally new to coding, but in learning them, they allow you to do nearly everything you want to do within your game)


Log in to post a reply.

Support

Forums