Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Handle age-up cs's
- for _, entry in pairs(ageBoundaries) do
- if currentStage == entry[1] and age >= entry[2] then
- table.insert(event[2], entry[3])
- end
- end
- table.insert(events, event)
- -- Remove used days from care plan and write back to chocoState + db
- for i = 1, #carePlan do
- if carePlan[i][2] <= daysElapsed then
- daysElapsed = daysElapsed - carePlan[i][2]
- table.remove(carePlan, i)
- i = i - 1
- else
- carePlan[i][2] = carePlan[i][2] - daysElapsed
- break
- end
- end
- chocoState.care_plan = carePlan
- -- Write back to db here
- This code will remove any completed days from the care plan and update the chocoState accordingly. It assumes that carePlan is a table containing sub-tables of the form {careItem, daysLeft} where careItem is a string describing the care to be given and daysLeft is the number of days remaining for that care item. The updated carePlan table is then written back to both chocoState and the database.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement