Page 1 of 1

Unlimited Objects to take?

PostPosted: Sun Mar 10, 2019 4:08 pm
by ohhaykfrankk
I'm trying to make a flower field. I will need flowers later for quests though so if I pick flowers from this field and give them to someone or drop them, you'd think I'd still be able to pick more flowers from the field. Whether or not I want them to wilt is undetermined as of yet. However, in case of stupidity, I want the flowers to be unlimited at the field.
Is there anyway to do this?

Re: Unlimited Objects to take?

PostPosted: Sun Mar 10, 2019 11:59 pm
by saabie
If you only want the player to be able to have one flowers object at a time, then when you enter the field location run a task that checks if the player is carrying the flowers and if not then move the flowers from wherever they are back to the field.
If you want a limited number of flower objects then move a new one into the location from hidden instead of moving the original one.
If you need to be able to have many copies of the same object at multiple locations at the same time then you need to make an integer property of items to count how many of them are located at each item.
You will need to add several tasks to manage taking and dropping these virtual objects.

Re: Unlimited Objects to take?

PostPosted: Mon Mar 11, 2019 2:39 pm
by The0didactus
Another thing that you can do is have "Flower" be a variable instead of an item. Whenever you "pick" a flower from the field, it increases the variable FLOWERS by 1. Whenever you give one away. You can make certain tasks like "Give flower to X" decrease the number of flowers you have by one, and "look at flowers" only work if you are in the flower field OR if you have more than 0 flowers.

This solution is good if you don't really care what happens to the flowers once you give them away, and ESPECIALLY if you want the player to have lots of flowers at once.

If neither of those are true it's better to use the solutions listed above.

Re: Unlimited Objects to take?

PostPosted: Mon Mar 11, 2019 4:08 pm
by P/o Prune
The0didactus wrote:Another thing that you can do is have "Flower" be a variable instead of an item. Whenever you "pick" a flower from the field, it increases the variable FLOWERS by 1. Whenever you give one away. You can make certain tasks like "Give flower to X" decrease the number of flowers you have by one, and "look at flowers" only work if you are in the flower field OR if you have more than 0 flowers.

This solution is good if you don't really care what happens to the flowers once you give them away, and ESPECIALLY if you want the player to have lots of flowers at once.

If neither of those are true it's better to use the solutions listed above.

I'm using this one in my next game. It works :-)

Re: Unlimited Objects to take?

PostPosted: Mon Mar 11, 2019 5:28 pm
by Lumin
I like variables, they're simple and they create the illusion of the feeling that I know what I'm doing and have finally moved past all the hilariously hacky solutions I used to go with.

Re: Unlimited Objects to take?

PostPosted: Mon Mar 11, 2019 5:36 pm
by The0didactus
The entire "inventory" system in Tingalan is variable-based. Items are either a number variable (You have "x" jars of water) or a text variable (You have "No shears"/"A pair of shears") Skybreak is going to be very similar.

Games where you might have to rely on multiple "copies" of the same item might get confusing. The way I'd probably do it is to make a roster of items, perhaps 20, that are all copies, and call them all something... "A Grenade" or whatever. Then I'd designate them all to be part of a group ("grenades") and have all actions concerning them be like "Player must have an object from group "gernade"...but of course, even now, I'm seeing problems with this system. Variables would be easier.

In fact I used exactly this system in Six Silver Bullets: There is an item called "The silver bullets" and when you "Take" that item, the game destroys the item, and sets the bullet counter to 6. Setting up a system that tracked each bullet would be maddening.

Re: Unlimited Objects to take?

PostPosted: Mon Mar 11, 2019 5:44 pm
by Lumin
Ask me about how I used to track water levels in a bucket.

(If you guessed 'create as many buckets as there are units of water and swap them out constantly', you're right!)

Re: Unlimited Objects to take?

PostPosted: Mon Mar 11, 2019 6:34 pm
by The0didactus
I think my dumbest kludge is for Tingalan: I artisinally hand-crafted variables for the numbers "1" through "10" because I didn't realize you could program your own equations on tasks...so about 25% of my tasks in Tingalan have conditions like "and [witsroll] is greater than or equal to [thenumber10]"

Re: Unlimited Objects to take?

PostPosted: Wed Mar 13, 2019 10:25 pm
by DazaKiwi
I created a basic system for one of the games i'm making, i had make a little demo to refine it first. This would be tedious to implement for a lot of objects you can stack, however i think there could be way to do this using groups which can force parameters on objects that you want to have multiple instances of and run it through a similar system as my demo. I might tackle that one in the future.

Also in another game where i have a combat system i have 2 characters; 'enemies' and 'enemy' and just have an integer property for number of enemies for character 'enemies', and using these two characters for each enemy encounter.

Re: Unlimited Objects to take?

PostPosted: Wed Mar 13, 2019 11:28 pm
by ohhaykfrankk
Oh my, DazaKiwi. I appreciate the effort/time it seems like you put into that demo. It looks amazing. Question about it, so if I drop an apple, is there no way to pick up that one apple I just dropped? And if I don't want the field to run out at all, do I still need the variable for the ground?

My only concern, not a concern really, is that I have like 15 different types of flowers so I need all of those things per flower? Lol, not looking forward to that part but it'll do lol.

Thank you, a lot!

Re: Unlimited Objects to take?

PostPosted: Wed Mar 13, 2019 11:41 pm
by DazaKiwi
ohhaykfrankk wrote:Oh my, DazaKiwi. I appreciate the effort/time it seems like you put into that demo. It looks amazing. Question about it, so if I drop an apple, is there no way to pick up that one apple I just dropped? And if I don't want the field to run out at all, do I still need the variable for the ground?

My only concern, not a concern really, is that I have like 15 different types of flowers so I need all of those things per flower? Lol, not looking forward to that part but it'll do lol.

Thank you, a lot!


I made the demo previously for my game where i was trying to get this working properly and just tweaked it a little for demonstration purposes.
Its often a good idea to demo out some game mechanic you have to implement in a game and can be a good demonstration to view again in future when you cant remember how it was set up etc. I had tried a similar system in the past and it got messy and more complicated than it needed to be. This time it was more simple.

Anyway as for your questions, if you drop a red apple in the game you can pick it up again and the held version of the apple just increases in number and variable tracking what is on the ground decreases by 1. Once the apples on the ground count down to zero it is removed (until you drop another red apple on the ground again). So yes you can pick up what you drop.

As for having the field not run out, then for the flower object called say 'Red Flowers' you could have have a very big number for the variable that tracks this, in my demo its for the red apple the variable "RedAG" tracks number on ground. So you could have a variable called 'RedFlowersOnGround' and set the amount to 100 or 500. And everytime the player picks one this decreases by 1 and increases the variable for the 'Red Flowers' held. All the other tasks do is check if those variables reach 0 and removes object if depleted.

Hope that makes sense?

Re: Unlimited Objects to take?

PostPosted: Thu Mar 14, 2019 8:47 pm
by ohhaykfrankk
Makes total sense. Thank you so much!