duplicate objects and quantity

Evil_int
I'm having a wee bit of a problem with whats probably a very basis function or two.

I'm trying to have multiple copies of common objects in the game, as well as having these objects be purchasable from several locations (shops) and findable in a few spots.

I've read a bunch of posts and come across that I need to add a "property" called quantity to the object, can't figure out where/how to do that.
(embarrassing noob problem, yeah I know, probably mixing a term up. Atttribute maybe?)

The problems I keep running across:
-when the object in question is picked up and used (expended) it vanishes from all vendors in the game
-when "purchased", the object does not get duplicated, and in fact if the player has used/expended the object, it doesn't "exist", so errors errors errors.
-also if the player hasn't picked up the object yet, before purchasing it, same errors.

I'm assuming these are simple syntax errors. but still . . . .Help? What would be the correct way to do this to manage the objects?

Also I can't seem to figure out a way to copy/paste object. Is there a way to accomplish this?

HegemonKhan
an 'item~equipment' system is not simple to design well, and requires a good bit of coding ability to create a good design. I still haven't accomplsihed this yet myself. However, here's some basic things you can do~use to help you:

-------

Cloning Objects:

http://docs.textadventures.co.uk/quest/ ... clone.html
http://docs.textadventures.co.uk/quest/ ... bject.html
http://docs.textadventures.co.uk/quest/ ... dmove.html

-------

Sora's Stackable Library:
viewtopic.php?f=18&t=3515 (this library hasn't been updated, but maybe you can get ideas from it, if you can understand code)

Pixie's Shop Library:
viewtopic.php?f=18&t=2557

------

for crafting better code designs, you need to learn List~Dictionary Attributes, and their useful applications (usage):

http://docs.textadventures.co.uk/quest/ ... lists.html
http://docs.textadventures.co.uk/quest/ ... aries.html

http://docs.textadventures.co.uk/quest/ ... reach.html
http://docs.textadventures.co.uk/quest/scripts/for.html

http://docs.textadventures.co.uk/quest/ ... tions.html
http://docs.textadventures.co.uk/quest/scripts/
http://docs.textadventures.co.uk/quest/scopes.html

Contains, (List~Dictionary)Contains, (List~Dictionary)Count, Scopes, AllObjects(), Got, GetObject, GetDirectChildren, GetAllChildObjects, etc etc etc

--------

in quest:

VARIABLES:
-> Attributes (global ~ 'save-able and thus load-able' ~ 'permanent', so long as the Object that it is: 'attached to; held~contained within', exists, of course): Object_name.Attribute_name = Value_or_Expression // an example: player.strength = 100
-> Variables (local ~ temporary, only can be used by the script block it is within, can *NOT* be used anywhere in the game's scripting, unlike Attributes, which can be): variable_string_name = Value_or_Expression // an example: strength = 100
-> Parameters (used by~in Functions and Commands)

----------

Attributes (a type of VARIABLE, see above):

about Integer Attributes, such as your question about a 'quantity' Integer Attribute:

in GUI~Editor:

'whatever' Object -> 'Attributes' Tab -> Attributes -> Add -> (see below)

(Object Name: whatever)
Attribute Name: quantity (or whatever you want to name~label the Attribute as: count, amount, capacity, number_of_potions, number_of_arrows, etc etc etc)
Attribute Type: int (integer)
Attribute Value: (whatever you want the initial amount to be)

an example:

'life_potion' Object -> > 'Attributes' Tab -> Attributes -> Add -> (see below)

(Object Name: life_potion)
Attribute Name: quantity
Attribute Type: int (integer)
Attribute Value: 0

in GUI~Editor's Scripting, an example:

run as script -> add new script -> variables -> 'set a variable or attribute' Script -> (see below)

set variable life_potion.quantity = [expression] 0

in scripting code, an example:

life_potion.quantity = 0

in 'creation' tag block code, an example:

<object name="life_potion">
<attr name="quantity" type="int">0</attr>
</object>


--------------------

some examples of scripting (actions~events) in your game:

'life_potion' Object -> 'Verbs' Tab -> Add -> (see below)

Verb Name: drink

run as script -> add new script -> scripts -> 'if' Script -> if [expression] life_potion.quantity = 0
-> then -> add new script -> output -> 'print a message' Script -> print [expression] "You can't drink what you have no more of, silly."
else
-> add new script -> variables -> 'set a variable or attribute' Script -> set variable player.current_life = [expression] player.current_life + 50
-> add new script -> variables -> 'set a variable or attribute' Script -> set variable life_potion.quantity = [expression] life_potion.quantity - 1
-> add new script -> output -> 'print a message' Script -> print [expression] "You drank a life potion, having 1 less quantity of life potions, but gaining +50 life back for drinking it."

in code:

if (life_potion.quanity = 0) {
msg ("You can't drink what you have no more of, silly.")
} else {
player.current_life = player.current_life + 50
life_potion.quantity = life_potion_quantity - 1
msg ("You drank a life potion, having 1 less quantity of life potions, but gaining +50 life back for drinking it.")
}


------

you can apply the above for all of your other features too of item~equipment usage: adding~removing 'quantities', moving Objects, transactions (buying~selling), and etc

-------

in the left side's 'tree of stuff'...

I'm not sure if you can copy and paste Objects in the GUI~EDitor (as I hardly work with it anymore, lol), but maybe you can literally highlight the Object, and then copy and paste it into whatever other (now highlighted) Object. I know you can click, hold, and drag an Object into another Object in the GUI~EDitor, to move that Object.

-------

you can directly do so in the code, but you got to know what you're doing, of course.

The Pixie
You might want to look at the Stackables library:
viewtopic.php?f=18&t=3515

Evil_int
Huge thanks for the responses.

I got the issues corrected and things seem to be working now as intended. :)

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

Support

Forums