Of course not.
research object describes a single research item.
research.name is a single
string object. It cannot be equal to two things at once. It sounds as if you misunderstand the whole idea of programming language (?)
Is this what you're trying to say?:
Code: Select all
function eventResearched(research, structure, player) {
// we don't care about function arguments at all
if (getResearch("R-Defense-TowerConst02").done
&& getResearch("R-Sys-Sensor-TurretHvy").done)
{
enableResearch("R-Sys-Sensor-Tower02", me);
}
}
And now i'm starting to understand what the problem is: being designed for AI scripts, this mechanism won't work unless surrounded by
hackChangeMe() or something like that.
A possible workaround would be to store such info in some static variable:
Code: Select all
function eventResearched(research, structure, player) {
if (typeof(eventResearched.meta) == undefined)
eventResearched.meta = {};
eventResearched.meta[research.id] = true;
if (eventResearched.meta["R-Defense-TowerConst02"]
&& eventResearched.meta["R-Sys-Sensor-TurretHvy"])
{
enableResearch("R-Sys-Sensor-Tower02", selectedPlayer);
}
}
But what we really need is, i think, an optional second
player parameter for
getResearch().
Another idea that you may like is to organise research tree in a more readable way:
Code: Select all
researchTree = [
...
// this is much shorter than five lines of nested if.
{ item: "R-Sys-Sensor-Tower02", prereqs: [ "R-Defense-TowerConst02", "R-Sys-Sensor-TurretHvy" ] },
...
];
function isDone(research) {
return getResearch(research).done; // or whatever will be there
}
function eventResearched(research, structure, player) {
researchTree.forEach(function(res) {
if (isDone(res.item))
return;
if (res.prereqs.every(isDone))
enableResearch(res.item);
});
}