RPG Maker XP
Dynamic Gardening
Introduction
This system will allow you to easily set up a Gardening System very much like the one in "Legend of Mana" for PSX. For those who have never played that game, it is basically a system that lets the player plant seeds that they have acquired, which will grow over time into full plants. Once the plants are ripe, they can be harvested for items.
Some graphics for the seeds can be found in the demo. I ripped them from Legend of Mana.
If you have any problems or find any bugs, be sure to let me know so I can fix them.
Be sure to give proper credit. Hope you enjoy!
Here are some gardening sprites, found by Heretic86 at http://yms.main.jp/
Features
- Easy and total configuration for growth rates, item results, etc.
- Each plant uses its own independent timer, which will be saved with the game.
- Timers run constantly in the background unless player is in the menu, etc.
- Different plant stages show the progression from sprout to full grown plant.
- Events can be easily set-up, and you can use as many as needed
Screenshots
The Code
Downloads
dynamic-gardening-v-3-0-1.zip
License Terms
Attribution 3.0 Unported - You must attribute the work in the manner specified by the author or licensor. Commerical use allowed.
Instructions
- Place script below default scripts, and above "Main".
- Fill out the configuration in the script (instructions within)
- Simple create a blank event with a comment on its first page that reads "Garden Event", and your done!
Credits & Thanks
ForeverZer0, for writing the script.
Comments (30)
Does it actually take the seeds, or is the display of the quantity just not updated?
It takes seeds (checked in menu inventory) when you select, which seeds you want to be planted…
When you cancel select (press "No" or back button on keyboard), it wont give them back to you…
Actually, Iam surprised, how fast have you answered… Wow
I love this gardning system! The only thing I have with it is that you have to use up two seeds, and from what I can tell with the script, the 'harvest' is generated based on the seeds you use. Is there a way to alter this script so it only asks for one seed and gives you a specific harvest item? Or is there another script you can suggest I look at? Thanks for any help you can provide
Actually yes, Twb6543 altered the script and made a single seed variation. It can be found [url=”http://forum.chaos-project.com/index.php/topic,6123.0.html”]here[/url].
Oh awesome! Thank you so much for that link
Sorry about this double post- I tried to edit my other one, and my browser just kept freezing. The link to download the demo is broken, and I think I'm going to need it to try and get this working. I can't seem to get the stage graphics correct, and I want to see how they are arranged on the image to compare how they are refereed to in the script. I'm really at a loss as how to setup this section of the script:
[CODE]
def self.stage_graphics(stage)
return case stage
when 0 then ['Plants1', 1, 1]
when 1 then ['Plants1', 2, 3]
when 2 then ['Plants1', 2, 1]
when 3 then ['Plants1', 4, 2]
when 4 then ['Plants1', 2, 4]
end
end
def self.final_graphic(item)
return case item
when 9 then ['Garden Plants', 1, 1]
when 10 then ['Garden Plants', 2, 4]
when 11 then ['Garden Plants', 3, 4]
when 12 then ['Garden Plants', 4, 4]
when 13 then ['Garden Plants', 1, 4]
when 14 then ['Garden Plants', 2, 2]
{snip}
end
end
[/CODE]
The way I understand the instructions… the first set of numbers in represents the plants growth stage it's currently at, and what graphic to use? If that's so, how can you define different graphics for different plants (ie- tomatos don't look like corn)? Then the second set of numbers represent the item ID of the SEED and what it looks like in it's final stage? I'm usually good at this stuff, but I've spent about 2 hrs on it now (without the demo to reference) and it's just confusing. I keep getting an error at line 391 and I read the comments to try and fix the stage images, but I think I'm understanding these instructions wrong.
Demo link is down due to a 3-day suspension from Dropbox for high traffic (I have an upload of "Pandora's Box" that is nearly 4 GB and is a popular download apparently).
Either way, to answer your question, that proper configuration for that section is to define the graphic only. Since character sprites consist of a 4 x 4 grid, and you will obviously only want to use one.
It goes like this: ['Name of character file', X-coord, Y-coord]
I did my best to draw a simple little ASCII grid in the script, but maybe this will help:
[IMG]http://i1086.photobucket.com/albums/j452/ForeverZer0/4x4grid.png[/IMG]
For example, if you wanted to use a Aluxes a plant graphic, specifically the graphic in the second row, and the third column, it would like this:
(Lets pretend the "result" item of Aluxes is item with ID of 4)
For the final graphic, when he is "ripe" and ready to pick…
[code]when 4 then ['001-Fighter01', 2, 3][/code]
[quote name='ForeverZer0' timestamp='1334291113' post='72604']
Demo link is down due to a 3-day suspension from Dropbox for high traffic (I have an upload of "Pandora's Box" that is nearly 4 GB and is a popular download apparently).[/quote]
Ahh ok! Thanks for the info [img]http://www.rmxpunlimited.net/forums//public/style_emoticons/default/biggrin.png[/img] I'll keep checking to see when/if it comes back up!
~~~
[quote name='ForeverZer0' timestamp='1334291113' post='72604']For example, if you wanted to use a Aluxes a plant graphic, specifically the graphic in the second row, and the third column, it would like this:
(Lets pretend the "result" item of Aluxes is item with ID of 4)
For the final graphic, when he is "ripe" and ready to pick…
[code]when 4 then ['001-Fighter01', 2, 3][/code]
[/quote]
Ahh! I think thats the part I misunderstood! I'll try it once I'm home for work! I really appreciate your help, as I really love this system a ton! [img]http://www.rmxpunlimited.net/forums//public/style_emoticons/default/smile.png[/img]
Edit: YES! Got it fixed!! Thank you SO MUCH! <3
Just a little bump. Looking for how to use different growth graphics for the growth stages of different plants. Also possibly how to increase the produce yield using the single seed portion of the script. Sorry, not sure if anyone who could help would see this unless there was a newish post. Thank you again to anyone who can help!
(I have this so far) The potato graphic for growth states is used for both plants right now. I'm not sure if I set this up right. The instructions say [b]when ITEM_ID/STAGE then ['FILENAME', X, Y][/b] but, I didn't think I could use a / in code because it represents division in an algorithm, so I tried a comma with no success : /
[CODE]
def self.stage_graphics(stage)
return case stage
when 2,0 then ['PotatoPlant', 1, 1]
when 2,1 then ['PotatoPlant', 1, 2]
when 2,2 then ['PotatoPlant', 1, 3]
when 3,0 then ['TomatoPlant', 1, 3]
when 3,1 then ['TomatoPlant', 1, 2]
when 3,2 then ['TomatoPlant', 1, 3]
end
end
def self.final_graphic(item)
return case item
when 9 then ['PotatoPlant', 1, 4]
when 10 then ['TomatoPlant', 1, 3]
end
end
[/CODE]
# Stage 1# Stage 1# Stage 1[CODE]
def self.stage_graphics(stage)
return case stage
when 2,0 then ['PotatoPlant', 1, 1]
when 2,1 then ['PotatoPlant', 1, 2]
when 2,2 then ['PotatoPlant', 1, 3]
when 3,0 then ['TomatoPlant', 1, 3]
when 3,1 then ['TomatoPlant', 1, 2]
when 3,2 then ['TomatoPlant', 1, 3]
end
end
[/CODE]
This syntax will not work properly. For the first case, it is the same as if 2 or 0, in the second its 2 or 1, etc., etc. If the ID is 2, it will always be the first case, since it fulfills the condition, the second or third cases are never even checked. The method need modified to check two separate cases: First the ID of the final graphic to determine the plant, then a second based off the stage of growth. The original version actually had this function, but I found it more of a pain in the ass than something that would actually be utilized fully, and it would be more of a burden to average users who did not want to come up with hundreds of different graphics so that every plant had unique growth stages.
To answer your question, modify the method to supply 2 arguments: item_id, and stage, and call it accordingly. It will look something like this:
[code]
def self.stage_graphics(item_id, stage)
return case item_id
when 1 # Item 1
case stage
when 0 then ['FILENAME', X, Y] # Stage 1
when 1 then ['FILENAME', X, Y] # Stage 2
# etc, etc
end
when 2 # Item 2
case stage
when 0 then ['FILENAME', X, Y] # Stage 1
when 1 then ['FILENAME', X, Y] # Stage 2
# etc, etc
end
end
end
[/code]
Ahh! I see now! That's exactly what I was looking for! I'm [i]so[/i] grateful for your help, and I'm sorry to keep bugging you xD <3 You're awesome
Edit: Ok, I put this in and fiddled with it a bit, and I'm getting an error at line 382:NoMethodError occured. undefined method '[]' for nil:NilClass
I also altered line 380 to accept two arguments:
[CODE]
Garden.stage_graphics(@item_id,@stage)
[/CODE]
Line 382:
[code]
event.character_name = data[0] # If you get an error on this line it means
# that the final or stage graphics have not been set up properly or that
# there is missing data in the config for a certain (pair of) item(s).
[/code]
Here is my growth item/stage graphics area:
[CODE]
def self.stage_graphics(item_id, stage)
return case item_id
when 2 # Item 1
case stage
when 0 then ['PotatoPlant', 1, 1] # Stage 1
when 1 then ['PotatoPlant', 1, 2] # Stage 2
end
when 3 # Item 2
case stage
when 0 then ['TomatoPlant', 1, 1] # Stage 1
when 1 then ['TomatoPlant', 1, 2] # Stage 2
end
end
end
def self.final_graphic(item)
return case item
when 9 then ['PotatoPlant', 1, 3]
when 10 then ['TomatoPlant', 1, 3]
end
end
[/CODE]
All of my plants have a 3 stage growth, so I only need two stages defined in the growth item/stage graphics area, and then a final graphic correct? I've tried putting in a third stage there, and I still get the same error, so I suspect it has something to do with the way the syntax of the final stage graphic area is formatted.
The methods need changed like this:
First, the config section…
[code]
def self.stage_graphics(item_id, stage)
return case item_id
when 1 # Plant 9
case stage
when 0 then ['Plants1', 1, 1]
when 1 then ['Plants1', 2, 3]
when 2 then ['Plants1', 2, 1]
when 3 then ['Plants1', 4, 2]
when 4 then ['Plants1', 2, 4]
end
when 10
case stage
when 0 then ['Plants1', 1, 1]
when 1 then ['Plants1', 2, 3]
when 2 then ['Plants1', 2, 1]
when 3 then ['Plants1', 4, 2]
when 4 then ['Plants1', 2, 4]
end
when 11
case stage
when 0 then ['Plants1', 1, 1]
when 1 then ['Plants1', 2, 3]
when 2 then ['Plants1', 2, 1]
when 3 then ['Plants1', 4, 2]
when 4 then ['Plants1', 2, 4]
end
when 12
case stage
when 0 then ['Plants1', 1, 1]
when 1 then ['Plants1', 2, 3]
when 2 then ['Plants1', 2, 1]
when 3 then ['Plants1', 4, 2]
when 4 then ['Plants1', 2, 4]
end
end
end[/code]
And next the method that calls it…[code]
def change_graphic(final)
# Set local variable to this plant's event
event = $game_map.events[@id]
data = final ? Garden.final_graphic(@produce) :
Garden.stage_graphics(@produce, @stage)
# Apply graphical change by simply altering event's stance and source
event.character_name = data[0]
event.direction = (2 * data[2])
event.pattern = (data[1] – 1)
event.refresh
end[/code]
Ok. I think this isn’t working because there is something that maybe I’m mis-communicating in my database that is causing me to become confused. This is what my database looks like:
So, this is the code with all the alterations you’ve helped me make to it. I’m getting line 495: ‘NoMethodError Occured undefined method ‘[]’ for nil:NilClass Here is the script- I’m not sure what’s wrong with it, much less how to fix it : /
[spoiler]
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=: # Dynamic Gardening # Authors: ForeverZer0, Twb6543 # Date: 7.17.2011 # Version: v.3.2 #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=: # VERSION HISTORY #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=: # v.1.1 (4.15.2010) # - Improved coding # - No longer uses game variables, events use self-switches instead # - Added ability to create different graphics for every plant, without # having to use more event pages # - Much less tedious setting up multiple events and changing the every # condition variable. # v.2.0 (10.10.2010) # - Total re-write. Code has been vastly improved and is much more efficient. # - Event setup has been simplified. Now requires only a single comment, and # does not require multiple pages. # - Added configurability for the number of stages each item requires. # - The timers no longer use Game_System to constantly update, but simply # compare themselves with the Graphics.frame_count when the event exists # on the current map, which also allows the plants to grow during scenes # other than Scene_Map and Scene_Battle. # - Got rid of Scene_Harvest. Scene_Garden now handles both aspects, and has # been improved. # - Added item icons to the help window display. # v.3.0 (5.13.2011) # - Restructured code completely # - Increased compatibility and performance # - Fixed bug with final graphic not behaving correctly # v.3.1 (7.14.2011) by Twb6543 # - Changed Script to allow for Single Seeds # - Added the ability to set default values # v.3.2 (7.17.2011) by Twb6543 # - Changed Script to fix bugs in the last release # - Fixed Bugs from version 3.0 (May not be completely fixed but I(Twb6543) # believe that it is mostly fixed) # - #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=: # # Explanation: # # This system allows the player to plant seeds, which will eventually grow # into plants that can be harvested for items. The system is very similar in # nature to that found in Legend of Mana. Seed's can be combined in different # ways, which will effect the total growth duration, the number of stages the # plant passes through, the graphics used, and of course the final result. # # Features: # # - Totally configurable growth rates, results, and graphics for every plant. # - Can use arrays of items for each result, so the final item is not # neccessarily the same every time. # - Each plant timer is independent, and its progress is saved with the game. # - Easy setup. Need only a single comment in one of the event's pages. # # Instructions: # # - Place script below Debug and above Main # - Configure the options below (instructions are with each setting) # - Create an event, setting the graphic to whatever you want. This will be the # graphics used when nothing is growing on the plant. # - At the very top event's page, place a comment that reads "Garden Event", # omitting the quotation marks. # - As long as the page's conditions are met, this event can be clicked on to # initiate the Garden scene, and can grow plants. # - Note that plants can be harvested early, but they will yield nothing until # they are ripe. # # Note: # # - Any method modified or added in 3.1 or 3.2 has an headed attached to it. # - The header will be "Double and Single Seed" or # "Double and Single Seed Method" for modified Methods. # - The header will be "Double and Single Seed New Method" for new Methods. # - Headers may also have extra information. # - The Code for Scene_Garden and Window_Seed can definitely be optimised # but as I(Twb6543) finally squashed the bug preventing release of v 3.2 # I do not want to change anything with out a bit of forethought. # #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=: # Dynamic Gardening # Authors: ForeverZer0, Twb6543 # Date: 7.17.2011 # Version: v.3.2 #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=: # VERSION HISTORY #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=: # v.1.1 (4.15.2010) # - Improved coding # - No longer uses game variables, events use self-switches instead # - Added ability to create different graphics for every plant, without # having to use more event pages # - Much less tedious setting up multiple events and changing the every # condition variable. # v.2.0 (10.10.2010) # - Total re-write. Code has been vastly improved and is much more efficient. # - Event setup has been simplified. Now requires only a single comment, and # does not require multiple pages. # - Added configurability for the number of stages each item requires. # - The timers no longer use Game_System to constantly update, but simply # compare themselves with the Graphics.frame_count when the event exists # on the current map, which also allows the plants to grow during scenes # other than Scene_Map and Scene_Battle. # - Got rid of Scene_Harvest. Scene_Garden now handles both aspects, and has # been improved. # - Added item icons to the help window display. # v.3.0 (5.13.2011) # - Restructured code completely # - Increased compatibility and performance # - Fixed bug with final graphic not behaving correctly # v.3.1 (7.14.2011) by Twb6543 # - Changed Script to allow for Single Seeds # - Added the ability to set default values # v.3.2 (7.17.2011) by Twb6543 # - Changed Script to fix bugs in the last release # - Fixed Bugs from version 3.0 (May not be completely fixed but I(Twb6543) # believe that it is mostly fixed) # - #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=: # # Explanation: # # This system allows the player to plant seeds, which will eventually grow # into plants that can be harvested for items. The system is very similar in # nature to that found in Legend of Mana. Seed's can be combined in different # ways, which will effect the total growth duration, the number of stages the # plant passes through, the graphics used, and of course the final result. # # Features: # # - Totally configurable growth rates, results, and graphics for every plant. # - Can use arrays of items for each result, so the final item is not # neccessarily the same every time. # - Each plant timer is independent, and its progress is saved with the game. # - Easy setup. Need only a single comment in one of the event's pages. # # Instructions: # # - Place script below Debug and above Main # - Configure the options below (instructions are with each setting) # - Create an event, setting the graphic to whatever you want. This will be the # graphics used when nothing is growing on the plant. # - At the very top event's page, place a comment that reads "Garden Event", # omitting the quotation marks. # - As long as the page's conditions are met, this event can be clicked on to # initiate the Garden scene, and can grow plants. # - Note that plants can be harvested early, but they will yield nothing until # they are ripe. # # Note: # # - Any method modified or added in 3.1 or 3.2 has an headed attached to it. # - The header will be "Double and Single Seed" or # "Double and Single Seed Method" for modified Methods. # - The header will be "Double and Single Seed New Method" for new Methods. # - Headers may also have extra information. # - The Code for Scene_Garden and Window_Seed can definitely be optimised # but as I(Twb6543) finally squashed the bug preventing release of v 3.2 # I do not want to change anything with out a bit of forethought. # #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: # BEGIN CONFIGURATION #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: #=============================================================================== # ** Garden #=============================================================================== module Garden SEED_IDS = [2, 3, 4, 5, 6, 7] # IDs of the items in the database that are seeds. Add them into the array in # the order of value/rarity in your game this currently includes any single # seeds SINGLE_IDS = [2, 3, 4, 5, 6, 7] # IDS of the items in the database that are seeds that are grown singularly. # These can be any Id's (They used to have to be different to the SEED_IDS) # Any reference to SEED_ID in the Configuration also refers to this HARVEST_SE = '056-Right02' # This is the SE that will be played when the player harvests the plant. SEED_DISPLAY = false # If true, all seeds will be displayed in the seed window, including those # that the player does not have, though they will be disabled. If false, only # seeds that that the player currently has will be displayed. # Define the growth rates here. (the average of both seeds will be used) def self.growth_rate(seed) return case seed # when SEED_ID then SECONDS when 2 then 10 when 3 then 10 when 4 then 10 when 5 then 10 when 6 then 10 when 7 then 10 else 10 # Default Value to return if no speed is specified end end #------------------------------------------------------------------------------- # Define the number of stages that each item uses. The stages will still cycle # in the same order, but only use up to the defined number of them before going # to the final graphic. This will not effect the duration that the seed takes to # grow, only how many times the graphic changes. # # You do not have to define anything that uses a three stage configuration. #------------------------------------------------------------------------------- def self.number_stages(result) case result when 2..7 return 4 # when 17..24 # return 5 else return 4 end end #------------------------------------------------------------------------------- # Define the final result of the seeds. A random item from the array will be # given as the final result. # # Each seed is given a value from 0 to the total number of seeds in the SEED_IDS # array, and both values are added together to determine which 'produce' array # will be used for the final result. This is why it is important that you have # the SEED_IDS array in order of value/rarity. You can find the total number of # cases you will need by subtracting 1 from the total number of different seeds # in SEED_IDS, and multiplying that number by 2. # # EX. Player uses one each of the first and last seed in the SEED_IDS array, # and there are 8 total seeds in the array... # # FIRST_SEED = 2 # LAST_SEED = 5 2 + 5 = RESULT # # By placing multiple copies of the same value in an array, you can increase # the odds of receiving that item over another in the same array. #------------------------------------------------------------------------------- #-------------------------------# # - Double and Single Seed - # #-------------------------------# # Now with Else/Defualt Clause # #-------------------------------# # def self.produce(seed) # return case seed # when 0 then [9, 10] # Only if both seed are the lowest seeds # when 1 then [10, 11] # when 2 then [12, 13] # when 3 then [13, 14] # when 4 then [14, 15] # when 5 then [15, 16] # when 6 then [16, 17] # Every combination in between # when 7 then [17, 18] # when 8 then [18, 19] # when 9 then [19, 20] # when 10 then [20, 21] # when 11 then [21, 22] # when 12 then [22, 23] # when 13 then [23, 24] # when 14 then [24] # Only if both seeds are the highest seeds # else # [9] # Default Value to return, Brackets are important, # May contain more than one value e.g [9,10] or [9,10,11,12,13] # end # end #------------------------------------------# # - Double and Single Seed New Method - # #------------------------------------------# # Table set up much in the same way as # # .produce, however items come from seed # # _ID_ not position in array # #------------------------------------------# # Also the ids are taken from SINGLE_IDS # # Array # #------------------------------------------# def self.produce_single(seed) return case seed when 2 then [9,9] when 3 then [10,10] when 4 then [11,11,11] when 5 then [12,12] when 6 then [13,13,13] when 7 then [14,14] else [9] # Default Value to return, Brackets are important, # May contain more than one value e.g [9,10] or [9,10,11,12,13] end end #------------------------------------------------------------------------------- # Define graphics for the final results, and each stage. Follow the below # template to set it up. # # when ITEM_ID/STAGE then ['FILENAME', X, Y] # # ITEM_ID = The ID number of the item in your database # STAGE = The stage during which to display the graphic # # FILENAME = The name of the character file the needed graphic is on # X = The x-coordinate of the correct picture on the charset (1 - 4) # Y = The y-coordinate of the correct picture on the charset (1 - 4) # # ← X → Ex. If the needed graphic was in the bottom # 1 2 3 4 left corner: X = 1 Y = 4 # ┌──┬──┬──┬──┐ # 1 │ │ │ │ │ # ├──┼──┼──┼──┤ # ↑ 2 │ │ │ │ │ # Y ├──┼──┼──┼──┤ # ↓ 3 │ │ │ │ │ # ├──┼──┼──┼──┤ # 4 │ │ │ │ │ # └──┴──┴──┴──┘ #------------------------------------------------------------------------------- def self.stage_graphics(item_id, stage) return case item_id when 1 # Plant 9 case stage when 0 then ['Plants1', 1, 1] when 1 then ['Plants1', 2, 3] when 2 then ['Plants1', 2, 1] when 3 then ['Plants1', 4, 2] when 4 then ['Plants1', 2, 4] end when 10 case stage when 0 then ['Plants1', 1, 1] when 1 then ['Plants1', 2, 3] when 2 then ['Plants1', 2, 1] when 3 then ['Plants1', 4, 2] when 4 then ['Plants1', 2, 4] end when 11 case stage when 0 then ['Plants1', 1, 1] when 1 then ['Plants1', 2, 3] when 2 then ['Plants1', 2, 1] when 3 then ['Plants1', 4, 2] when 4 then ['Plants1', 2, 4] end when 12 case stage when 0 then ['Plants1', 1, 1] when 1 then ['Plants1', 2, 3] when 2 then ['Plants1', 2, 1] when 3 then ['Plants1', 4, 2] when 4 then ['Plants1', 2, 4] end end end def self.final_graphic(item) return case item when 9 then ['Plants1', 2, 1] when 10 then ['Plants1', 2, 1] when 11 then ['Plants1', 2, 1] when 12 then ['Plants1', 2, 1] when 13 then ['Plants1', 2, 1] when 14 then ['Plants1', 2, 1] end end #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: # END CONFIGURATION #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: #--------------------------------------# # - Double and Single Seed Method - # #--------------------------------------# # ! Warning ! # # # # This rearranges the order of the def # # variables to allow for Single Seed # #--------------------------------------# def self.plant_seeds(event_id, seed1, seed2=nil) # Create a new instance of a Garden::Plant if seed2 != nil # Double Seed Method plant = self::Plant.new(event_id, seed1, seed2) if $game_system.garden[$game_map.map_id] == nil $game_system.garden[$game_map.map_id] = [plant] else $game_system.garden[$game_map.map_id].push(plant) end else #Single Seed Method plant = self::Plant.new(event_id, seed1) if $game_system.garden[$game_map.map_id] == nil $game_system.garden[$game_map.map_id] = [plant] else $game_system.garden[$game_map.map_id].push(plant) end end end def self.harvest(id) # Find the appropriate plant. plant = $game_system.garden[$game_map.map_id].find {|plant| plant.id == id } return nil if plant == nil # Return the result, and delete plant data from array. result = plant.produce plant.restore_event $game_system.garden[$game_map.map_id] -= [plant] return result end #=============================================================================== # ** Garden::Plant #=============================================================================== class Plant attr_reader :id, :ripe #--------------------------------------# # - Double and Single Seed Method - # #--------------------------------------# def initialize(id, seed1, seed2=nil) if seed2 != nil # Initialize needed instance variables. @id, @seed1, @seed2, @single = id, seed1, seed2, false else # Initialize needed instance variables. @id, @seed1, @single = id, seed1, true end @ripe, @stage = false, -1 # Run setup method, using data in Garden config for this plant's seeds setup end #--------------------------------------# # - Double and Single Seed Method - # #--------------------------------------# # Similar to old method but adds a # # check for the single flag # #--------------------------------------# def setup # Store original graphic, direction, and pattern in variable. event = $game_map.events[@id] @original_event = [event.character_name, event.direction, event.pattern] # Calculate the total duration of the seed combination. if @single == true # If single then only the duration of that seed @duration = Garden.growth_rate(@seed1) else # IF double then duration of both seeds @duration = (Garden.growth_rate(@seed1) + Garden.growth_rate(@seed2)) end # Find the produce that this combination will grow into if @single == true @produce = Garden.produce_single(@seed1) # Get a random produce from case Seed1 id @produce = @produce[rand(@produce.size)] else comb = Garden::SEED_IDS.index(@seed1) + Garden::SEED_IDS.index(@seed2) @produce = Garden.produce(comb) @produce = @produce[rand(@produce.size)] end # Get the number of stages this plant will use, then setup counts for it number, count = Garden.number_stages(@produce), 0 dur = (@duration / number.to_f).to_i @stages = (0...number).to_a @stages.collect! {|i| $game_system.garden_counter + (i * dur) } # Refresh the plant to apply changes refresh end def refresh unless @ripe # Initialize local variable that will determine if graphic needs redrawn. previous = @stage count = @stages.find_all {|rate| $game_system.garden_counter <= rate } @stage = (@stages.size - count.size) @ripe = (@stage >= @stages.size - 1) # Redraw bitmap if needed. change_graphic(@ripe) if previous != @stage end end def change_graphic(final) # Set local variable to this plant's event event = $game_map.events[@id] data = final ? Garden.final_graphic(@produce) : Garden.stage_graphics(@produce, @stage) # Apply graphical change by simply altering event's stance and source event.character_name = data[0] event.direction = (2 * data[2]) event.pattern = (data[1] - 1) event.refresh end def restore_event # Restore event to original state before planting. event = $game_map.events[@id] event.character_name = @original_event[0] event.direction = @original_event[1] event.pattern = @original_event[2] end def produce # Return nil if not yet ripe, else return an item ID. return (@ripe ? @produce : nil) end end end #=============================================================================== # ** Game_System #=============================================================================== class Game_System attr_accessor :garden, :garden_counter alias zer0_garden_init initialize def initialize # Initialize variables used for the garden system. @garden_counter = 0 @garden = {} zer0_garden_init end alias zer0_garden_upd update def update # Increase garden counter and check if update is needed every second. if (Graphics.frame_count % 40) == 0 @garden_counter += 1 # Check if current map has any plants on it. If so, refresh them. if @garden[$game_map.map_id] != nil && !@garden[$game_map.map_id].empty? @garden[$game_map.map_id].each {|plant| plant.refresh } end end zer0_garden_upd end end #=============================================================================== # ** Game_Event #=============================================================================== class Game_Event attr_accessor :character_name, :direction, :pattern alias zer0_garden_event_refresh refresh def refresh # Normal refresh method. zer0_garden_event_refresh # Set flag for this event being a garden event. @garden_event = (@page != nil && @page.list[0].code == 108 && @page.list[0].parameters[0] == 'Garden Event') end alias zer0_garden_upd update def update # Skip update method foe this event if it is a plant. @garden_event ? return : zer0_garden_upd end alias zer0_garden_event_start start def start # Redefine the 'start' method if Garden Event flag is present. if @garden_event plants, harvest = $game_system.garden[$game_map.map_id], false # Check if plant exists, and if so check if it is ripe. pick = plants != nil ? (plants.find {|obj| obj.id == @id }) != nil : false $scene = Scene_Garden.new(@id, pick) else zer0_garden_event_start end end end #=============================================================================== # ** Game_Map #=============================================================================== class Game_Map alias zer0_garden_setup setup def setup(map_id) zer0_garden_setup(map_id) # Refresh each plant when map is set up if $game_system.garden[@map_id] != nil $game_system.garden[@map_id].each {|obj| obj.change_graphic(obj.ripe) } end end end #=============================================================================== # * Window_Seed #=============================================================================== class Window_Seed < Window_Selectable #--------------------------------------# # - Double and Single Seed Method - # #--------------------------------------# def initialize super(160, 304, 320, 160) @seednum1 = false self.index = 0 refresh end #--------------------------------------# # - Double and Single Seed Method - # #--------------------------------------# def refresh # Clear the bitmap. self.contents = self.contents.dispose if self.contents != nil # Determine what seeds to display. # makes an array of all Ids if @ids_add == nil @dup = Garden::SEED_IDS.dup @ids_add = Garden::SINGLE_IDS.dup @ids_add.each {|val| if @dup.include?(val) @ids_add.delete(val) end } # This is the one line that caused the last bug # I was using .concat() instead of + so dup # also contained the single ids... @idss = @dup + @ids_add end # If compacting does something # (.compact! return nil when nothing happens) if @idss.compact! != nil @ids = @idss.compact! else @ids = @idss end if @dup.compact! != nil @idse = @dup.compact! else @idse = @dup end @seeds = nil @seeds = @ids.collect {|id| $data_items[id]} unless @seednum1 == false @seeds = nil @seeds = @idse.collect {|id| $data_items[id]} end unless Garden::SEED_DISPLAY @seeds.reject! {|seed| $game_party.item_number(seed.id) < 1 } end @item_max = @seeds.size # Draw the items on the bitmap. if @item_max > 0 self.contents = Bitmap.new(width - 32, @item_max * 32) @seeds.each_index {|i| item = @seeds[i] number = $game_party.item_number(item.id) self.contents.font.color = number > 0 ? normal_color : disabled_color opacity = number > 0 ? 255 : 128 # Find icon bitmap and set it to window, and draw the text. bitmap = RPG::Cache.icon(item.icon_name) self.contents.blt(4, i*32+4, bitmap, Rect.new(0, 0, 24, 24), opacity) self.contents.draw_text(32, i*32, 288, 32, item.name) self.contents.draw_text(-32, i*32, 288, 32, ':', 2) self.contents.draw_text(-4, i*32, 288, 32, number.to_s, 2) } end if @seednum1 != true @seednum1 = true end end def seed # Returns currently highlighted seed item. return @seeds[self.index] end #------------------------------------------# # - Double and Single Seed New Method - # #------------------------------------------# def resetseed @seednum1 = false end #------------------------------------------# # - Double and Single Seed New Method - # #------------------------------------------# # Just use seed.id instead it's much # # easier # #------------------------------------------# # Here for the sake of History # #------------------------------------------# def seedid return @seeds[self.index].id end #------------------------------------------# # - Double and Single Seed New Method - # #------------------------------------------# def single(id=nil) # This could be optimised into # result = Garden::SINGLE_IDS.includes?(seed.id)=true&&id=nil ? True : False # or # result = Garden::SINGLE_IDS.includes?(seed.id)&&id==nil ? True : False result = false if Garden::SINGLE_IDS.include?(seedid) && id == nil # Can use seed.id result = true end # This part could be optimised into # result = id !=nil ? Garden::SINGLE_IDS.include?(id) : result if id != nil result = Garden::SINGLE_IDS.include?(id) end return result end end #=============================================================================== # * Scene_Garden #=============================================================================== class Scene_Garden def initialize(id, harvest) @event_id, @harvest = id, harvest # Play SE to give impression that scene never changed. $game_system.se_play($data_system.decision_se) $game_player.straighten garden = $game_system.garden[$game_map.map_id] if garden != nil @plant = garden.find {|plant| plant.id == id } end end #--------------------------------------# # - Double and Single Seed Method - # #--------------------------------------# def main # Create map sprite and required windows. @map, @help_window = Spriteset_Map.new, Window_Help.new # Create Confirmation window. @confirm_window = Window_Command.new(128, ['Yes', 'No']) @confirm_window.x, @confirm_window.y = 496, 336 # Used in Set_Help @r = 0 # Initialize sprites array. Used to handle all the sprites together. @sprites = [@map, @help_window, @confirm_window] # Create seed window if plant is not being harvested. unless @harvest @seed_window = Window_Seed.new @sprites.push(@seed_window) @seed_window.active = @seed_window.visible = false @help_window.set_text('Plant seeds here?') else @data = $game_system.garden[$game_map.map_id][@event_id] if @plant != nil && @plant.ripe text = 'This plant is ripe. Would you like to harvest it?' else text = 'Nothing is growing yet on this plant. Harvest it anyway?' end @help_window.set_text(text) end # Transition instantly then start main loop. Graphics.transition(0) loop { Graphics.update; Input.update; update; break if $scene != self } # Dispose of all the sprites. @sprites.each {|sprite| sprite.dispose } # Have map refresh to update any changes made. $game_map.need_refresh = true end def update @sprites.each {|sprite| sprite.update } # Branch update method depending on what window is active. if @confirm_window.active update_confirm elsif @seed_window != nil && @seed_window.active update_seed_select end end #--------------------------------------# # - Double and Single Seed Method - # #--------------------------------------# def update_confirm if Input.trigger?(Input::B) # Branch by what action is being canceled. if @harvest back_to_map else @seed1 == nil ? back_to_map : cancel_seed_selection end elsif Input.trigger?(Input::C) # Branch by what action is being confirmed. if @harvest if @confirm_window.index == 0 item_id = Garden.harvest(@event_id) if item_id != nil @confirm_window.active = @confirm_window.visible = false # Gain item, play the harvest SE, then return to the map. $game_party.gain_item(item_id, 1) $game_system.se_play(RPG::AudioFile.new(Garden::HARVEST_SE, 80, 100)) show_results($data_items[item_id]) $scene = Scene_Map.new else back_to_map end else back_to_map end else # If asking if player would like to plant seeds at this location. if @seed1 == nil if @confirm_window.index == 0 @seed_window.active = @seed_window.visible = true @confirm_window.active = @confirm_window.visible = false @help_window.set_text('Which seeds would you like to plant?') else back_to_map return end else # If confirming seed selection. if @confirm_window.index == 0 # Plant seeds and return to map. @single = @seed_window.single(@idsingle) # This is how Twb6543 reloaded the single command (in case of index # movement) if @single = true && @seed2 == nil # If Single only Garden.plant_seeds(@event_id, @seed1.id) else # If Double or Includes Double Seed Garden.plant_seeds(@event_id, @seed1.id, @seed2.id) end $scene = Scene_Map.new else # If canceling seed selection if Garden::SEED_IDS.include?(@seed1.id) && @seed2 == nil cancel_single else cancel_seed_selection end return end end $game_system.se_play($data_system.decision_se) end end end def show_results(result) @help_window.contents.clear # Display the message in the help window. @help_window.draw_item_name(result, 0, 0) cw = @help_window.contents.text_size(result.name).width + 32 @help_window.contents.draw_text(cw, 0, 608, 32, ' received!') # Call Input.update to the clear key press. Input.update # Loop until it is pressed again. until Input.trigger?(Input::C) Graphics.update; Input.update; update end end #------------------------------------------# # - Double and Single Seed New Method - # #------------------------------------------# def cancel_single @seed_window.active = @seed_window.visible = true @confirm_window.active = @confirm_window.visible = false @r = 1 set_help @seed_window.refresh end def cancel_seed_selection # Play cancel SE, reset seeds, and activate/deactivate windows. $game_system.se_play($data_system.cancel_se) $game_party.gain_item(@seed1.id, 1) # Added to re add the seeds $game_party.gain_item(@seed2.id, 1) # Added to re add the seeds @seed_window.active = @seed_window.visible = true @confirm_window.active = @confirm_window.visible = false @r = 0 @help_window.set_text('Which seeds would you like to plant?') @seed1 = @seed2 = nil @seed_window.resetseed @seed_window.refresh end def back_to_map # Play cancel SE and return to map. $game_system.se_play($data_system.cancel_se) $scene = Scene_Map.new end #--------------------------------------# # - Double and Single Seed Method - # #--------------------------------------# def update_seed_select if Input.trigger?(Input::B) # If first seed is selected, go back to re-select, else return to map. if @seed1 != nil $game_party.gain_item(@seed1.id, 1) # Regain seed @seed_window.resetseed @seed1 = nil @seed_window.refresh $game_system.se_play($data_system.cancel_se) else back_to_map end elsif Input.trigger?(Input::C) # Play Cancle SE if displayed and party has none. if $game_party.item_number(@seed_window.seed.id) < 1 $game_system.se_play($data_system.buzzer_se) return end $game_system.se_play($data_system.decision_se) @single = @seed_window.single @idsingle = @seed_window.seedid # How Twb6543 set the Id # Can use @idsingle = @seed_window.seed.id if @single == true && @seed1 == nil # Set first seed then continue @seed1 = @seed_window.seed $game_party.lose_item(@seed1.id, 1) @seed_window.active = false @confirm_window.active = @confirm_window.visible = true elsif @single == true && @seed1 != nil # Set second seed then continue @seed2, @seed_window.active = @seed_window.seed, false $game_party.lose_item(@seed2.id, 1) @confirm_window.active = @confirm_window.visible = true elsif @single != true # Set first seed if not defined, else set the second seed and continue. if @seed1 == nil @seed1 = @seed_window.seed $game_party.lose_item(@seed1.id, 1) else @seed2, @seed_window.active = @seed_window.seed, false $game_party.lose_item(@seed2.id, 1) @confirm_window.active = @confirm_window.visible = true end end # Refresh seed window to show changes in inventory. set_help @seed_window.refresh end end #--------------------------------------# # - Double and Single Seed Method - # #--------------------------------------# def set_help # Clear help window. @help_window.contents.clear # Draw items @single = @seed_window.single(@idsingle) if @single == true && @seed2 == nil && @r == 0 text = 'Plant this seed?' else text = @seed2 != nil ? 'Plant these two seeds?' : 'Select second seed...' end @help_window.set_text(text) @help_window.draw_item_name(@seed1, 224, 0) if @seed2 != nil cw = @help_window.contents.text_size(@seed1.name).width + 320 @help_window.draw_item_name(@seed2, cw, 0) end end end
[/spoiler]
Did you try looking at the demo and seeing the basic setup there?
I can try a bit more in-depth explanation in a bit, but I can't until I get home later on.
[quote name='ForeverZer0' timestamp='1335215749' post='72871']
Did you try looking at the demo and seeing the basic setup there?
I can try a bit more in-depth explanation in a bit, but I can't until I get home later on.
[/quote]
I'll download it right now. I've redone it a couple times since you probably last checked the post. I started over from scratch so to speak, copying the single seed version by TWB6543 from here: [url=”http://forum.chaos-project.com/index.php?topic=6123.0″]http://forum.chaos-p…hp?topic=6123.0[/url] and then making the alterations to that (recheck the post I made above). It's ok! I really, really appreciate all the help you've provided me so far. I wish there was something I could do in return xD
Edit: Dropbox link is still suspended [img]http://www.rmxpunlimited.net/forums//public/style_emoticons/default/sad.png[/img] It's alright- I'm just not sure WHY it's not working. I've since started over completely a couple times now, [i]only[/i] adding what I needed for it to interact with my database and images, and of course the alterations for growth patterns and the method to call the final product.
Bump
Bump. I just came across this, and thought of this script…
[img]http://yms.main.jp/sozai/chips/vege.png[/img]
Dynamic Gardening is so much more dynamic with pictures of Actual Vegetables!
More sets here: http://yms.main.jp/
I normally dont say this but…
Thank you for necroposting. I been looking for something like this and it gave me some ideas on how to make my script better.
Dont know how many times i dug through the scripts section and missed this.
You're welcome!
I felt it contributed to the thread as a necropost as opposed to making another thread.
is it the version of the rpg maker that make the letters look better, i mean they have a shadow, and looks like more focused. What should i change to maker the letters looks like that?
Hi, Can i use this script for a commercial proyect? thanks.
By the way, did you know how i can change the animation of the dead of the player in the XAS system? and how i can disable the keys F1…F12? thanks and sorry for the inconvinients.
If i can help you with some script this is my mail victoriaevolution@gmail.com
Leave a Reply
You must be logged in to post a comment.
Eltod
Help!!!, i got this error when I try to plant the seeds (in my project)
????? ' Dynamic Garden System 3.0' ? 263 ??? NoMethodError ?????????
undefined method `+' for nil:NillClass
Need help. I want this system in my game
ForeverZer0
[quote name='Eltod' timestamp='1305566795' post='60704']
Help!!!, i got this error when I try to plant the seeds (in my project)
????? ' Dynamic Garden System 3.0' ? 263 ??? NoMethodError ?????????
undefined method `+' for nil:NillClass
Need help I want this system in my game
[/quote]
It sounds like a problem with your setup. Make sure you have everything configured correctly.
Eltod
mmmm, Another script was messing out with this one, I've correct it.
This is a wonderful Script, congratulations. You'll be in the special thanks section ^^
CrimsonInferno
This is a great script! Especially for people wanting games like Harvest Moon
Great work, ForeverZer0
ForeverZer0
[quote name='CrimsonInferno' timestamp='1305860460' post='60951']
This is a great script! Especially for people wanting games like Harvest Moon
Great work, ForeverZer0
[/quote]
Thank you both, and I'm glad you like it.
As for the error that you were getting, did you find a way to resolve it. I may be able to help you make them compatible if you haven't already.
Eltod
[quote name='ForeverZer0' timestamp='1305861389' post='60954']
Thank you both, and I'm glad you like it.
As for the error that you were getting, did you find a way to resolve it. I may be able to help you make them compatible if you haven't already.
[/quote]
That wil be so great, but I think that will be imposible, because I use scripts that causes incompatibility like SDK, Icon commands, command manager, MACL…
Don't know if you want to try…
ForeverZer0
[quote name='Eltod' timestamp='1306185878' post='61213']
That wil be so great, but I think that will be imposible, because I use scripts that causes incompatibility like SDK, Icon commands, command manager, MACL…
Don't know if you want to try…
[/quote]
I can give it a go. If you know the exact script that is causing the issues, either give me link to it, PM it, or post it so I can see what the problem is. If you have no idea which one, a copy of your Scripts.rxdata will do just fine.
iwitrag
Found small bug, when you select seeds to plant and when you must confirm, you select "No", it wont give you back your seeds
ForeverZer0