I'm using a single variable set up as an array to keep track of farming fields. The farm field variable tracks 4 pieces of data per field, and will eventually wind up holding up to 400 entries.
This array length changes based on how many fields are planted, and using a simple step tracker for crop maturity, I am able to notify the player when a field or fields are ready to harvest. The problem I'm having now is I need to remove the relevant field entries from the array. I can't just set the data to 0's because I'm using the length of the array to determine how many fields are planted.
Here's a psuedo code sample of my harvest event:
Set Farm Loops var to the length of the fields array.
divide farm loops by 4 (stride length) which controls when I leave the loop.
Set Crop Value to 3, Set Field Ready to 2, Set Crop Yield to 1, Set Crop Name to 0.
Loop
Temp var = $gameVariables.value(FARMARRAY)[$gameVariables.value(Field Ready)];
if var == 0
{
This crop is ready to harvest. Here's where I need to remove each array element related to the variables I stored for the field.
}
Increase Crop Value, Field Ready, Crop Yield, and Crop Name by 4;
Decrease Farm Loops by 1.
if Farm Loops == 0 Break Loop.
I can't use pop because that takes off the end, and the other function I know takes off the front, but since the crops each have various maturity times, I can't say for sure where in the array the field that has matured will be. Although when I plant crops I'll just be adding the new data to the end of the array.
Can someone point me in the direction of the array function I'm looking for?
This array length changes based on how many fields are planted, and using a simple step tracker for crop maturity, I am able to notify the player when a field or fields are ready to harvest. The problem I'm having now is I need to remove the relevant field entries from the array. I can't just set the data to 0's because I'm using the length of the array to determine how many fields are planted.
Here's a psuedo code sample of my harvest event:
Set Farm Loops var to the length of the fields array.
divide farm loops by 4 (stride length) which controls when I leave the loop.
Set Crop Value to 3, Set Field Ready to 2, Set Crop Yield to 1, Set Crop Name to 0.
Loop
Temp var = $gameVariables.value(FARMARRAY)[$gameVariables.value(Field Ready)];
if var == 0
{
This crop is ready to harvest. Here's where I need to remove each array element related to the variables I stored for the field.
}
Increase Crop Value, Field Ready, Crop Yield, and Crop Name by 4;
Decrease Farm Loops by 1.
if Farm Loops == 0 Break Loop.
I can't use pop because that takes off the end, and the other function I know takes off the front, but since the crops each have various maturity times, I can't say for sure where in the array the field that has matured will be. Although when I plant crops I'll just be adding the new data to the end of the array.
Can someone point me in the direction of the array function I'm looking for?