How to create an object repetitively?

Vega
19 Dec 2015, 03:15
Hi,

I am building a resource gathering game on Quest and I want to create one object many times.

Example.

I have a map which is 25 tiles, and I want one object to be created *once* in *each* tile.

I want to set it up with a template (like a class in python) and have Quest create the object for me in all the tiles. Then I want to go in individually and adapt them all (if needed).

Can you help me?

K-

ps. I attached a screenshot of my game to see the idea. I want to create 25 instances of Tuna, each in one tile of the map (which is the ocean in the game)
1234.png

HegemonKhan
19 Dec 2015, 03:52
if you just want to do this stuff physically~manually as the game creator, there's many easy means for you do do so within the GUI~Editor:

copy~cut and paste, click hold drag and release an Object where you want in the 'tree of stuff' on the left side, and etc etc etc

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

if you want to do this stuff via scripting and etc coding stuff:

------

Classes in quest (at least at the user level):

Object Types (often shortened to ' Types ', which is gets confusing...)

http://docs.textadventures.co.uk/quest/ ... /type.html (Object Types ~ Classes)
http://docs.textadventures.co.uk/quest/ ... herit.html (simply add the 'inherit' Attribute code tag line, to add the Object Type to the Object)

http://docs.textadventures.co.uk/quest/ ... types.html

http://docs.textadventures.co.uk/quest/ ... types.html
http://docs.textadventures.co.uk/quest/ ... nced_.html

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

Creating and Cloning (copying) Objects:

http://docs.textadventures.co.uk/quest/ ... reate.html

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

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

Setting, Re-Setting (altering~changing), and Doing Attributes on Objects:

http://docs.textadventures.co.uk/quest/scripts/set.html

http://docs.textadventures.co.uk/quest/scripts/do.html ( 'do' is more useful~powerful~versatile~better than 'invoke' )
http://docs.textadventures.co.uk/quest/ ... nvoke.html

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

Iteration:

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

-----------

Randomization:

http://docs.textadventures.co.uk/quest/ ... omint.html
http://docs.textadventures.co.uk/quest/ ... ouble.html

http://docs.textadventures.co.uk/quest/ ... eroll.html

http://docs.textadventures.co.uk/quest/ ... hance.html

---------

Lists and Dictionaries:

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

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

-------

Conditionals~Checking:

(if you know Python, aka some Object-Oriented programming, you should be familiar with this concept of 'checking' an Object's Attributes)

the 'if' Script for conditionals~checking, such as using the built-in 'alias' String Attribute as 'tuna', since they must have unique 'name' String Attributes (as this is the ID for the quest engine) which the built-in cloning will give them (something like maybe: tuna_1, tuna_2, etc), to check for of the Object (aka: 'if' the Object has the 'alias' of 'tuna', it is one of your 'tuna_X' Objects).

-----

the basic concept:

put~add your desired rooms into an objectlist attribute, iterate through all of them (foreach), create and clone+move your tuna cloned objects into those rooms via the 'foreach' Function's scripting.

The Pixie
19 Dec 2015, 08:38
I would build a single prototype, then use CloneObjectAndMove to place it. Do that inside a for loop in the game start script, and Quest does the repetitive bit for you.
for (i, 1, 25) {
if (i < 10) {
room = GetObject("Ocean0" + i)
}
else {
room = GetObject("Ocean" + i)
}
CloneObjectAndMove (Tuna, room)
}