#2629 closed enhancement (fixed)
[PATCH] Allow the ResourceDropsite to be modified through tech research
Reported by: | Niek | Owned by: | leper |
---|---|---|---|
Priority: | Should Have | Milestone: | Alpha 18 |
Component: | UI & Simulation | Keywords: | technology dropsite patch |
Cc: | Patch: |
Description
It would be nice to be able to modify which resources a Dropsite accepts through technology research.
This patch also includes a small fix the AI API to fix an undefined error which occured due to the ResourceDropsite fix.
The technology could look like this:
{ "genericName": "Advanced Dropsite", "description": "Citizens are now able to drop food at the house", "cost": {"food": 0, "wood": 0, "stone": 0, "metal": 100}, "requirements": {"tech": "phase_village"}, "requirementsTooltip": "Unlocked in Village Phase.", "icon": "upgrade_advanced.png", "researchTime": 10, "tooltip": "Citizens are now able to drop food at the house", "modifications": [ {"value": "ResourceDropsite/Types", "replace": "food"} ], "affects": ["House"], "soundComplete": "interface/alarm/alarm_upgradearmory.xml" }
The value ("food" in this case) should be a string to be accepted. Also the building that is being modified should have a ResourceDropsite/Types tag. But this tag is allowed to be empty e.g. this:
<ResourceDropsite> <Types> </Types> </ResourceDropsite>
Attachments (4)
Change History (20)
by , 10 years ago
Attachment: | ResourceModify.patch added |
---|
comment:1 by , 10 years ago
Keywords: | patch review added |
---|
comment:2 by , 10 years ago
Milestone: | Alpha 17 → Alpha 18 |
---|
comment:3 by , 9 years ago
Keywords: | review removed |
---|
Splitting "" results in [""] which is not what is wanted here. Checking if it is empty before splitting and returning [] is what should be done.
The AI change would be nicer with an early return.
comment:4 by , 9 years ago
Keywords: | review added |
---|
comment:5 by , 9 years ago
Tested and it works perfectly fine. No errors and workers dropped food in the house.
comment:6 by , 9 years ago
Summary: | [Patch] Allow the ResourceDropsite to be modified through tech research → [PATCH] Allow the ResourceDropsite to be modified through tech research |
---|
comment:7 by , 9 years ago
Braces around line 24-26 can be removed.
Also, it'd be nicer to use another variable instead of copy and pasting the same long expression.
by , 9 years ago
Attachment: | ResourceModify.3.patch added |
---|
Removes curly bracket and uses a variable instead of copying over the whole expression
comment:8 by , 9 years ago
Just a tip: If branching is not needed, don't use if.
if (this.types) == "") return []; return this.types.split(/\s+/);
better:
return this.types === "" ? [] : this.types.split(/\s+/);
Avoids also the not matching brackets pitfall.
follow-ups: 10 11 comment:9 by , 9 years ago
Extra tab whitespace on line 379 of binaries/data/mods/public/simulation/ai/common-api/entity.js
comment:10 by , 9 years ago
Replying to scythetwirler:
Extra tab whitespace on line 379 of binaries/data/mods/public/simulation/ai/common-api/entity.js
I should add one?
follow-up: 12 comment:11 by , 9 years ago
Replying to scythetwirler:
Extra tab whitespace on line 379 of binaries/data/mods/public/simulation/ai/common-api/entity.js
I mean, the empty line has the same indentation as line 380 (which is correct I believe).
follow-up: 13 comment:12 by , 9 years ago
Replying to niektb:
Replying to scythetwirler:
Extra tab whitespace on line 379 of binaries/data/mods/public/simulation/ai/common-api/entity.js
I mean, the empty line has the same indentation as line 380 (which is correct I believe).
Not according to leper. :P
comment:13 by , 9 years ago
Replying to scythetwirler:
Replying to niektb:
Replying to scythetwirler:
Extra tab whitespace on line 379 of binaries/data/mods/public/simulation/ai/common-api/entity.js
I mean, the empty line has the same indentation as line 380 (which is correct I believe).
Not according to leper. :P
I just checked and it isn't the case here :D
patch that modifies both the API and the ResourceDropsite component