Donation system

Status
Not open for further replies.

Chiptek

Villager
Member
Joined
Aug 26, 2013
Messages
9
Reaction score
0
First Language
Flemish
Primarily Uses
I'm trying to make a system where you donate creatures (which are actually items). You will donate all creatures you hadn't donated before.

But there are about 2,500 different ones to collect. I currently got it to work the way I want, but in a way I have to write the same bit of code 2,500 times.

So I was hoping for some better way to do this. This is what I have now:



The green part checks for the first creature (Dekkarok- B) . If it's not donated yet and you have it in your inventory, it will be donated. 

Below the green part it checks for the next creature/item, (Dekkarok-G). This would go on 2,500 times.

So I'm looking for a way to do this with a loop or something similar, where it will automatically go to the next item and next control switch (which tells if the particular item is donated or not) every time. 

I'm pretty new at this, so I'm sorry if the solution is something really simple.

Thanks!
 

Berylstone

Veteran
Veteran
Joined
Jun 3, 2013
Messages
642
Reaction score
62
First Language
English
Primarily Uses
I'm trying to make a system where you donate creatures (which are actually items). You will donate all creatures you hadn't donated before.

But there are about 2,500 different ones to collect. I currently got it to work the way I want, but in a way I have to write the same bit of code 2,500 times.

So I was hoping for some better way to do this. This is what I have now:



The green part checks for the first creature (Dekkarok- B) . If it's not donated yet and you have it in your inventory, it will be donated. 

Below the green part it checks for the next creature/item, (Dekkarok-G). This would go on 2,500 times.

So I'm looking for a way to do this with a loop or something similar, where it will automatically go to the next item and next control switch (which tells if the particular item is donated or not) every time. 

I'm pretty new at this, so I'm sorry if the solution is something really simple.

Thanks!
In page1 of your Event Commands look under Flow Control.  You will see two options - Loop and Break Loop.  I think that is what you are looking for.

You could also use Labels to do this as well.  So you may want to experiment with Label and Jump to Label also.  Very nice feature, that one is.

A quick example of how you could use labels for this:

Label: Donate RockB:Begins

Conditional Branch: RockB in Inventory

Text:

        :Donate RockB?

Show Choices: Yes, No

When [Yes]

Change Items: [RockB], -1

Jump to Label: Donate RockB:Begins

When [No]

Jump To Label: Donate RockB:Ends

Branch End

Else

Jump To Label: Donate RockB:Ends

Branch End

Label: Donate RockB:Ends
 
Last edited by a moderator:

Chiptek

Villager
Member
Joined
Aug 26, 2013
Messages
9
Reaction score
0
First Language
Flemish
Primarily Uses
Thanks for the quick response!

I already knew about the loop feature, but the problem is I have no idea how to go to the next item and to the next switch every time it loops.

I think it should probably look something like this, but now it will just check the same creature 2,500 times. While it should check the next creature on each loop. (So Dekkarok-B on loop 1, creature 2 the second loop, etc...)



Using labels seems great as well. I didn't really know about them yet. But again I can't figure out how to make it go to creature 2, then creature 3 etc... I'm probably missing something, but wouldn't you have to write it out 2,500 times for each different creature in the example you gave? Sorry for being rather noobish at this.
 

Berylstone

Veteran
Veteran
Joined
Jun 3, 2013
Messages
642
Reaction score
62
First Language
English
Primarily Uses
Thanks for the quick response!

I already knew about the loop feature, but the problem is I have no idea how to go to the next item and to the next switch every time it loops.

I think it should probably look something like this, but now it will just check the same creature 2,500 times. While it should check the next creature on each loop. (So Dekkarok-B on loop 1, creature 2 the second loop, etc...)



Using labels seems great as well. I didn't really know about them yet. But again I can't figure out how to make it go to creature 2, then creature 3 etc... I'm probably missing something, but wouldn't you have to write it out 2,500 times for each different creature in the example you gave? Sorry for being rather noobish at this.
I included an example of how you could use labels in my previous post.  I'm not sure if you saw it, but just in case I'll point that out.  I added it after my initial post.

If you wanted to move on to another creature, I would think you could just make a label for it and jump to it when ever your event is ready.  If there are certain conditions that need to be met before you move on to the next creature, you could place the jump to label command within a conditional branch.
 
Last edited by a moderator:

Chiptek

Villager
Member
Joined
Aug 26, 2013
Messages
9
Reaction score
0
First Language
Flemish
Primarily Uses
Thanks for the help so far. I still don't completely get how to make it work by using loops or labels right now, but I'll try to mess around a bit with them and see if I can make some progress. 
 

Berylstone

Veteran
Veteran
Joined
Jun 3, 2013
Messages
642
Reaction score
62
First Language
English
Primarily Uses
Thanks for the help so far. I still don't completely get how to make it work by using loops or labels right now, but I'll try to mess around a bit with them and see if I can make some progress. 
I'm having a hard time understanding specifically what is giving you problems, so I'm sorry if I'm not being more precise.

As long as you break the loop or the label cycle, you should be able to move on to the next loop for donating towards your second creature.  The event should read from the top down.  For example:

#Comment

====Creature1 donation loop if [Creature Number] <= 2500====

Conditional Branch: [0005:Creature Number] <= 2500

Label: Donate Creature1:Begins

Conditional Branch: Creature1 in Inventory

Text:

        :Donate Creature1?

Show Choices: Yes, No

When [Yes]

Change Items: [Creature1], -1

Control Variables: [0005: Creature Number] +=1

Jump to Label: Donate Creature1:Begins

When [No]

Jump To Label: Donate Creature1:Ends

Branch End

Else

Jump To Label: Donate Creature1:Ends

Branch End

Label: Donate Creature1:Ends

Branch End

#Comment:

====New Creature donation Loop IF Creature Number is greater than 2,500====

Conditional Branch: [0005:Creature Number] > 2500

Label: Donate Creature2:Begins

Conditional Branch: Creature2 in Inventory

Text:

        :Donate Creature2?

Show Choices: Yes, No

When [Yes]

Control Variables: [0005: Creature Number] +=1

Jump to Label: Donate Creature2:Begins

When [No]

Jump To Label: Donate Creature2:Ends

Branch End

Else

Jump To Label: Donate Creature2:Ends

Branch End

Label: Donate Creature2:Ends

Branch End

Does this help at all?
 
Last edited by a moderator:

Chiptek

Villager
Member
Joined
Aug 26, 2013
Messages
9
Reaction score
0
First Language
Flemish
Primarily Uses
I understand that part, but what I'm trying to do is find some way to make it shorter. If I have about 10 lines of code per creatures, I will have 25,000 lines of code in total when I do this for all 2,500 creatures. I was hoping for some way to get the same effect by using just a single loop instead of having 2,500 different labels. Sorry if I wasn't very clear about that.

On the other hand, I did find something that leads me towards what I want:

On page 1 of Event commands, under "Actor" most of them let you choose between either a Fixed actor, or a variable that corresponds to an actor ID. Like seen in the picture below:



But for items and switches, it only lets you pick a "fixed" item or switch. Not a variable, which is what I'd need.



Am I missing some other way this could be done or did they just not implement this?
 

seita

Donn_M
Veteran
Joined
Feb 6, 2013
Messages
2,254
Reaction score
611
First Language
English
Primarily Uses
I'm going to write you a little event loop, but first I need to know. Are all of the items ID's in sequence? That is, if the first one is at 100 does it end at 2600 ?
 

Berylstone

Veteran
Veteran
Joined
Jun 3, 2013
Messages
642
Reaction score
62
First Language
English
Primarily Uses
I understand that part, but what I'm trying to do is find some way to make it shorter. If I have about 10 lines of code per creatures, I will have 25,000 lines of code in total when I do this for all 2,500 creatures. I was hoping for some way to get the same effect by using just a single loop instead of having 2,500 different labels. Sorry if I wasn't very clear about that.

On the other hand, I did find something that leads me towards what I want:

On page 1 of Event commands, under "Actor" most of them let you choose between either a Fixed actor, or a variable that corresponds to an actor ID. Like seen in the picture below:



But for items and switches, it only lets you pick a "fixed" item or switch. Not a variable, which is what I'd need.



Am I missing some other way this could be done or did they just not implement this?
Oh ok, I understand you now.  You are trying to contain 2,500 separate items into a single loop and avoid having to write a separate line of code for each of them.  I finally understand you now.  I thought you were wanting to donate the same item 2,500 times before enabling the second item to donate. 
 
Last edited by a moderator:

Chiptek

Villager
Member
Joined
Aug 26, 2013
Messages
9
Reaction score
0
First Language
Flemish
Primarily Uses
@Seita That would be great! Yes, both the items and corresponding switches are in sequence. 100 - 2600 seems perfect as well.

EDIT: Just to be clear, these are the things that would have to be different each time it loops.



Brown is the item, which would start at ID 0100 and end at 2600.

Yellow is the corresponding switch, which I'd also let start at ID 0100 and end at 2600. (not 0015 like in the pic)

Variables 0004 and 0002 and Switch 0014 should always be the same.

@Berylstone That's right! Sorry about the confusion.
 
Last edited by a moderator:

seita

Donn_M
Veteran
Joined
Feb 6, 2013
Messages
2,254
Reaction score
611
First Language
English
Primarily Uses
for my loop you'll only need 3 variables and no switches when I finish it. Do you have a custom message system you're using for the game?
 

Chiptek

Villager
Member
Joined
Aug 26, 2013
Messages
9
Reaction score
0
First Language
Flemish
Primarily Uses
for my loop you'll only need 3 variables and no switches when I finish it. Do you have a custom message system you're using for the game?
Nope, I'm currently using the standard one.
 

seita

Donn_M
Veteran
Joined
Feb 6, 2013
Messages
2,254
Reaction score
611
First Language
English
Primarily Uses
A few notes:

This assumes your items start at 100 and ends at 2600.

This uses Variables 21, 22, 23 and 24. If you want to use other variables, make sure to change ALL of them that use this number, including the ones in the script calls.

NEVER touch these variables (except Item Name and Current Donations) outside of this event, or it'll mess up the counts.

This uses something I taught in an intermediate/advanced variables tutorial.

Here's page one. This only happens ONCE which is why it turns on self switch A, to make sure it never accesses page 1 again.



Page two is all of the processes.

 

Berylstone

Veteran
Veteran
Joined
Jun 3, 2013
Messages
642
Reaction score
62
First Language
English
Primarily Uses
@Berylstone That's right! Sorry about the confusion.
It's not your fault.  I'm easy to confuse :)

What I would do is just make a single item and attach a variable to it and add +1 to variable [Creatures in Inventory] every time you want the player to find a creature. So I would make two variables [Creatures Donated] and [Creatures in inventory].  Then write something like this:

Conditional Branch: [Creatures Found] <= 2500

Conditional Branch:  [Creatures in inventory] >= 1

Text:

        :Donate Creatures?

Show Choices: Yes, No

When [Yes]

Control Variables: [Creatures Found] += [Creatures in Inventory]

Control Variables: [Creatures Found] = 0

When [No]

Branch End

Branch End

That way you can keep track of how many creatures the player has donated without having to make so many different items.  This may not be what you looking for, but if it's not maybe Seita's solution will be.  Can't hurt to have a variety of answers.
 
Last edited by a moderator:

Chiptek

Villager
Member
Joined
Aug 26, 2013
Messages
9
Reaction score
0
First Language
Flemish
Primarily Uses
@seita: Thank you so much, it works amazingly! 

There's just one thing. If a creature has been donated, I'd like its sprite to appear on one of the maps that show all of the donations you've made, so you can easily see the ones you have donated already. It's hard to see which creatures have been donated right now. Those switches corresponding to each item may come in handy here?Like if the switch is on, the sprite will appear and will show you the name of the creature, while if it's off, there will be nothing there.

Is it easy to implement this into the code or would it take too much to change?

@Berylstone: Every creature is different, so that's why I need the 2,500 different items for. I've got different sprites for each of them as well. The point of the game will be to collect all of the different ones through battles, quests and various other ways.
 

Berylstone

Veteran
Veteran
Joined
Jun 3, 2013
Messages
642
Reaction score
62
First Language
English
Primarily Uses
@Berylstone: Every creature is different, so that's why I need the 2,500 different items for. I've got different sprites for each of them as well. The point of the game will be to collect all of the different ones through battles, quests and various other ways.
Wow, that is a lot of creatures.
 

seita

Donn_M
Veteran
Joined
Feb 6, 2013
Messages
2,254
Reaction score
611
First Language
English
Primarily Uses
It would be easier with a utility script that adds more custom event triggers, but there's an easy roundabout way. Let me cook up another event for you~

First off~ are you actually going to have 2,500 events in that map or will you segregate them in groups?
 

Chiptek

Villager
Member
Joined
Aug 26, 2013
Messages
9
Reaction score
0
First Language
Flemish
Primarily Uses
Wow, that is a lot of creatures.
I know, I always hate when a game ends, so I want to make something you can keep playing for an extremely long time. I may start to regret this eventually though.

@seita I think it'd be best to have many different maps, with probably around 50-100 creatures displayed per map.
 

seita

Donn_M
Veteran
Joined
Feb 6, 2013
Messages
2,254
Reaction score
611
First Language
English
Primarily Uses
I'm calling each map a "room".

In this case, all of the creatures start at event ID 7, and it should end at 107, for a total of 200 creatures.

The creatures it will be showing are numbers 101 to 200.

Basically, each event will have two pages. The first page is blank and has no conditions. The second page has the sprite of that creature and has Self Switch A as a condition.

Read the comments~

 

Chiptek

Villager
Member
Joined
Aug 26, 2013
Messages
9
Reaction score
0
First Language
Flemish
Primarily Uses
@seita I can't thank you enough for this. It works perfectly now and it's exactly the way I wanted.

Thank you so very much!
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,868
Messages
1,017,066
Members
137,576
Latest member
SadaSoda
Top