componentAvailable()
componentAvailable()
I'm struggling to understand the docs for this function -- what is a component type? (I couldn't find any constants relating to component types)
Also, how would we check if a component is available for a specific player?
Also, how would we check if a component is available for a specific player?
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
-- https://warzone.atlassian.net/wiki/display/GO
Re: componentAvailable()
Component type constants are unavailable (forgotten, i think), that's why i re-define them manually all across NullBot (:
Code: Select all
_global.iHaveHover = function() {
const COMP_PROPULSION=3;
for (var i = 0; i < propulsionStats.hover.length; ++i)
if (componentAvailable(COMP_PROPULSION, propulsionStats.hover[i].stat))
return true;
return false;
}
Maps | Tower Defense | NullBot AI | More NullBot AI | Scavs | More Scavs | Tilesets | Walkthrough | JSCam
Re: componentAvailable()
Any idea where those constants are defined in C++ code? I looked in component.cpp and component.h but they don't appear to be defined there... :s
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
-- https://warzone.atlassian.net/wiki/display/GO
Re: componentAvailable()
Awesome, tvm.
I created a ticket regarding the missing constants: http://developer.wz2100.net/ticket/3898
I created a ticket regarding the missing constants: http://developer.wz2100.net/ticket/3898
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
-- https://warzone.atlassian.net/wiki/display/GO
Re: componentAvailable()
I've changed componentAvailable(), it can now take a single parameter containing the component name - specifying the component type is deprecated.
Re: componentAvailable()
Excellent!
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
-- https://warzone.atlassian.net/wiki/display/GO
Re: componentAvailable()
Aha, backwards compatibility is there. Thanks (:Per wrote:I've changed componentAvailable(), it can now take a single parameter containing the component name - specifying the component type is deprecated.
Maps | Tower Defense | NullBot AI | More NullBot AI | Scavs | More Scavs | Tilesets | Walkthrough | JSCam
Re: componentAvailable()
And then we run into a funny riddle.NoQ wrote:Aha, backwards compatibility is there. Thanks (:
Suppose we have something like var weapons = [ "MG1Mk1", "MG2Mk1" ].
What will happen if we try to evaluate weapons.filter(componentAvailable)? (:
Maps | Tower Defense | NullBot AI | More NullBot AI | Scavs | More Scavs | Tilesets | Walkthrough | JSCam
Re: componentAvailable()
Ah, good point. Same would happen for weapons.some(componentAvailable)
Maybe we should break backwards compatibility, I think it would be worth it in this instance.
Maybe we should break backwards compatibility, I think it would be worth it in this instance.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
-- https://warzone.atlassian.net/wiki/display/GO
Re: componentAvailable()
I'd have to re-make my challenge mapsaubergine wrote:Maybe we should break backwards compatibility
Maybe just add this to the "gotchas" section of the docs?
Maps | Tower Defense | NullBot AI | More NullBot AI | Scavs | More Scavs | Tilesets | Walkthrough | JSCam
Re: componentAvailable()
An alternative would be to do this:
But it would be so much nicer if the native function could be used...
Code: Select all
function toAvailableComponents = function(component) {
// still has all three params passed in from .filter(), but only passes first one on to the JS API fn
return componentAvailable(component);
}
var availableWeapons = weapons.filter(toAvailableComponents);
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
-- https://warzone.atlassian.net/wiki/display/GO