Coin system

This forum is the place to learn about and discuss ADRIFT 5. Feel free to mention any bugs you find here, but please also add these to the Bugs & Enhancements list.

Please also refer to the ADRIFT 5 Wiki for more information.
User avatar
Denk
Posts: 786
Joined: Mon Feb 22, 2016 6:21 pm
Points: 291
Location: Hjørring, Denmark

Re: Coin system

Post by Denk »

strajepi wrote: Tue Apr 20, 2021 6:15 pm I would like to add bandaids in my game. I would like them to be buyable and foundable in many locations. Do I have to create one item per location ? When I choose dynamic and then the initial location, it seems that I can only choose one location...
Things can be done in many ways in ADRIFT, the easiest depends on the details of what you want to do. I guess, if you want to be able to carry a lot of band-aids, it will probably be better to only carry one dynamic object and the description of this object is something like "%ba% band-aids", which will be written as e.g. "5 band-aids" when you type inventory.

You are right that dynamic objects can only be in one location at a time and the Money System requires buyable objects to be dynamic, otherwise they can't be purchased. But you can work around this in many ways.

Some quick examples of what you can do:
1. In the money system, there is a property called "Buyable Item". If you open that property, you will see that it only appears for dynamic objects. However, you can quickly change it to "No dependent value" so it also appears for static objects. If you do this, you can purchase static objects. However, they will not be moved to your inventory when you purchase them as static objects cannot be held by characters. Instead you can override the task "purchase object" while you set %object% to the static object you want to buy. Thus, when you purchase a static object, you can move a dynamic band-aid object to the player and perhaps increase a variable which holds the number of held band-aids. The static band-aid objects can be in all locations or a location group you define yourself.

2. Though dynamic objects can only be in one location, they can be on or in static objects that are supporters or containers and such a static object can be in several rooms. Thus, if the dynamic object is in a static container that is in many rooms, the dynamic object is available in many rooms too, even though there is only one dynamic object.

These are just examples. If you are trying to achieve something but can't make it work, I recommend that you attach a small demo where you try to reproduce the problem. Sometimes when you do that, you find the solution and if not, we can look at the demo and let you know what to do.
----------------------------------------------------------------------
The Bash Saga:
1. The Dragon Diamond 2. The Way Home 3. Stone of Wisdom
----------------------------------------------------------------------
User avatar
Lumin
Posts: 2318
Joined: Fri Aug 06, 2004 6:48 pm
Points: 54

Re: Coin system

Post by Lumin »

strajepi wrote: Tue Apr 20, 2021 6:15 pm Sorry I have another question...
I would like to add bandaids in my game. I would like them to be buyable and foundable in many locations. Do I have to create one item per location ? When I choose dynamic and then the initial location, it seems that I can only choose one location...
Thanks a lot !!
It seems like this would be the perfect situation for the variable based inventory items just discussed.
strajepi
Posts: 15
Joined: Sat Apr 17, 2021 11:47 am
Points: 10

Re: Coin system

Post by strajepi »

Thanks a lot guys !
strajepi
Posts: 15
Joined: Sat Apr 17, 2021 11:47 am
Points: 10

Re: Coin system

Post by strajepi »

Denk wrote: Tue Apr 20, 2021 11:20 pm
strajepi wrote: Tue Apr 20, 2021 6:15 pm I would like to add bandaids in my game. I would like them to be buyable and foundable in many locations. Do I have to create one item per location ? When I choose dynamic and then the initial location, it seems that I can only choose one location...
Things can be done in many ways in ADRIFT, the easiest depends on the details of what you want to do. I guess, if you want to be able to carry a lot of band-aids, it will probably be better to only carry one dynamic object and the description of this object is something like "%ba% band-aids", which will be written as e.g. "5 band-aids" when you type inventory.

You are right that dynamic objects can only be in one location at a time and the Money System requires buyable objects to be dynamic, otherwise they can't be purchased. But you can work around this in many ways.

Some quick examples of what you can do:
1. In the money system, there is a property called "Buyable Item". If you open that property, you will see that it only appears for dynamic objects. However, you can quickly change it to "No dependent value" so it also appears for static objects. If you do this, you can purchase static objects. However, they will not be moved to your inventory when you purchase them as static objects cannot be held by characters. Instead you can override the task "purchase object" while you set %object% to the static object you want to buy. Thus, when you purchase a static object, you can move a dynamic band-aid object to the player and perhaps increase a variable which holds the number of held band-aids. The static band-aid objects can be in all locations or a location group you define yourself.

2. Though dynamic objects can only be in one location, they can be on or in static objects that are supporters or containers and such a static object can be in several rooms. Thus, if the dynamic object is in a static container that is in many rooms, the dynamic object is available in many rooms too, even though there is only one dynamic object.

These are just examples. If you are trying to achieve something but can't make it work, I recommend that you attach a small demo where you try to reproduce the problem. Sometimes when you do that, you find the solution and if not, we can look at the demo and let you know what to do.
Here is how I tried to make buyable band-aids with the coin system :

- I created a dynamic and hidden object called "band-aids" which has for only property : "buyable item".

- I created a task called "buy band-aids". There is no restriction but two actions :
1) Move object "band-aids" to help by the Player character.
2) Increase variable Band-aids by "3".
3) Decrease variable money by "3".

- I created a variable called "Band-aids with : initial value = 0, number as type, and I did not cross the array option.

What do you think of it ?

Thank you very much
strajepi
Posts: 15
Joined: Sat Apr 17, 2021 11:47 am
Points: 10

Re: Coin system

Post by strajepi »

I tried to run it and a problem came to me :
I can buy as many band-aids as I want but my wallet shows me -10 coins... How can I make sure that the character can not spend more than he owns ?
User avatar
Lumin
Posts: 2318
Joined: Fri Aug 06, 2004 6:48 pm
Points: 54

Re: Coin system

Post by Lumin »

I'm at work so can't really give a detailed answer right now, but you have to use your task actions and restrictions for this, just like anything else.
User avatar
P/o Prune
Site Admin
Posts: 4862
Joined: Mon Jun 24, 2002 9:18 am
Points: 133
Location: Denmark

Re: Coin system

Post by P/o Prune »

Off the top of my head you have to make a restriction in the buy task where the number of coins mus be more than or equal to (the lowest amount of the price.) If the restrictions isn't met you can write the reply: You haven't got enough money to buy that (whatever it is)
Does this make sense?
D-Day in progress 86Kb (Slowly drifting)
October 31st: 93Kb (possible entry for IFComp 2021 :wink: )
User avatar
Denk
Posts: 786
Joined: Mon Feb 22, 2016 6:21 pm
Points: 291
Location: Hjørring, Denmark

Re: Coin system

Post by Denk »

As P/o Prune said, you just need the right restrictions.

However, I would like to comment on best practice, as I can see that you understandably approach ADRIFT as most newbies:
strajepi wrote: Wed Apr 21, 2021 4:23 pm- I created a dynamic and hidden object called "band-aids" which has for only property : "buyable item".

- I created a task called "buy band-aids". There is no restriction but two actions :
1) Move object "band-aids" to help by the Player character.
2) Increase variable Band-aids by "3".
3) Decrease variable money by "3".

- I created a variable called "Band-aids with : initial value = 0, number as type, and I did not cross the array option.
If you want a strong parser and not a misleading parser that frustrates the player, you should follow best practice whenever you can.

This means, that you should use specific tasks instead of general tasks whenever possible. As you apply the Money System, you should either utilize it or make your own instead.

You should utilize the task "purchase object" in the "Money System" folder. Open it and click on "restrictions", which looks like this:
restrictions.png
restrictions.png (22.17 KiB) Viewed 156 times
The third restriction says that the object must be visible to the player. As you put your "band-aids" in "hidden", the restrictions of the "purchase object"-task are never fulfilled and therefore you cannot override the "purchase object"-task when the object is the "band-aids"-object.

So I propose:
1. Make a static object and put it in a location group you have created yourself, with all the locations where the band-aids can be bought.
2. Make the static object a supporter.
3. Put the dynamic "band-aids"-object on the supporter. It is now available in all the same locations as the supporter-object.
4. Override the "purchase object"-task with a specific task and set the object to the "band-aids"-object. The specific task can then change the variables as you want.

As the "band-aids"-object is now available, the specific task will run (unless you made a mistake). If you have problems, i strongly recommend to attach a demo to your post.
----------------------------------------------------------------------
The Bash Saga:
1. The Dragon Diamond 2. The Way Home 3. Stone of Wisdom
----------------------------------------------------------------------
strajepi
Posts: 15
Joined: Sat Apr 17, 2021 11:47 am
Points: 10

Re: Coin system

Post by strajepi »

Thanks a lot for your help ! I will try to run it !
strajepi
Posts: 15
Joined: Sat Apr 17, 2021 11:47 am
Points: 10

Re: Coin system

Post by strajepi »

P/o Prune wrote: Wed Apr 21, 2021 6:14 pm Off the top of my head you have to make a restriction in the buy task where the number of coins mus be more than or equal to (the lowest amount of the price.) If the restrictions isn't met you can write the reply: You haven't got enough money to buy that (whatever it is)
Does this make sense?
So I have to write a number instead of the other variables the software suggests me when I fulfill the last case on the left ?
User avatar
Denk
Posts: 786
Joined: Mon Feb 22, 2016 6:21 pm
Points: 291
Location: Hjørring, Denmark

Re: Coin system

Post by Denk »

strajepi wrote: Thu Apr 22, 2021 11:59 am
P/o Prune wrote: Wed Apr 21, 2021 6:14 pm Off the top of my head you have to make a restriction in the buy task where the number of coins mus be more than or equal to (the lowest amount of the price.) If the restrictions isn't met you can write the reply: You haven't got enough money to buy that (whatever it is)
Does this make sense?
So I have to write a number instead of the other variables the software suggests me when I fulfill the last case on the left ?
I am not sure if I understand completely what you mean. In the picture below, I have shown how the restriction should be created. Hope that helps.
(I still would recommend a specific task instead of a general task)
r1.png
r1.png (17.39 KiB) Viewed 117 times
----------------------------------------------------------------------
The Bash Saga:
1. The Dragon Diamond 2. The Way Home 3. Stone of Wisdom
----------------------------------------------------------------------
User avatar
Lumin
Posts: 2318
Joined: Fri Aug 06, 2004 6:48 pm
Points: 54

Re: Coin system

Post by Lumin »

That money system add on is useful shortcut, but a coin system (or similar) by itself isn't difficult to set up and doing so forces the learning of the basics of variables and tasks in the process. Not getting the sense strajepi has quite grasped the fundamental concepts yet, hence the continued confusion even when he's trying to follow instructions.
User avatar
Denk
Posts: 786
Joined: Mon Feb 22, 2016 6:21 pm
Points: 291
Location: Hjørring, Denmark

Re: Coin system

Post by Denk »

Lumin wrote: Thu Apr 22, 2021 12:39 pm That money system add on is useful shortcut, but a coin system (or similar) by itself isn't difficult to set up and doing so forces the learning of the basics of variables and tasks in the process. Not getting the sense strajepi has quite grasped the fundamental concepts yet, hence the continued confusion even when he's trying to follow instructions.
I agree that it could be a good exercise. However, I think that it might be too early to do that, as it seems that the purpose of specific tasks hasn't been grasped yet. Thus, there is a risk that all tasks would be created with general tasks, which would work but would most likely result in a very weak parser.
----------------------------------------------------------------------
The Bash Saga:
1. The Dragon Diamond 2. The Way Home 3. Stone of Wisdom
----------------------------------------------------------------------
strajepi
Posts: 15
Joined: Sat Apr 17, 2021 11:47 am
Points: 10

Re: Coin system

Post by strajepi »

Thanks a lot ! I will try to apply all your pieces of advice and to stop bothering you ;)
User avatar
Denk
Posts: 786
Joined: Mon Feb 22, 2016 6:21 pm
Points: 291
Location: Hjørring, Denmark

Re: Coin system

Post by Denk »

No problem, we are still here if you get stuck. :)
----------------------------------------------------------------------
The Bash Saga:
1. The Dragon Diamond 2. The Way Home 3. Stone of Wisdom
----------------------------------------------------------------------
Post Reply