Can Somone make a simple gadget?
Moderator: Moderators
Can Somone make a simple gadget?
If the unit takes negative storage, and causes the main storage to go into negative values, can its construction be completely stopped and refused?
Re: Can Somone make a simple gadget?
Can you explain what you want a little more clearly? "Construction completely stopped and refused" is really, really vague.
It sounds like what you're looking for is a generic third-resource system, that creates X amount of resource ("storage") for a given Team, upon certain things being built, and takes it away when they're destroyed.
The easiest way to prevent items that need this from being built is to make them run a COB-->LUA check against the amount of this storage that's available when they start being built, and delete themselves if they would reduce the value of "storage" to < 0. You could also send a message to the player, and/or play a sound, special FX, or whatever.
It sounds like what you're looking for is a generic third-resource system, that creates X amount of resource ("storage") for a given Team, upon certain things being built, and takes it away when they're destroyed.
The easiest way to prevent items that need this from being built is to make them run a COB-->LUA check against the amount of this storage that's available when they start being built, and delete themselves if they would reduce the value of "storage" to < 0. You could also send a message to the player, and/or play a sound, special FX, or whatever.
Re: Can Somone make a simple gadget?
I am trying to upload a mod as it had a very very old concept before lua came in. a third and even fourth resource is what it originally need, but until then, i used storage to cap units in a certain sense. At negative storage it maxed population until you could get out of negatives, but it halted everything, so i dropped the idea,. If units require storage and it detects storage before being built it would be prevented.
http://www.darkstars.co.uk/downloads/vi ... mymod5.sdz
I decided I might work on it again. I just cannot model.
http://www.darkstars.co.uk/downloads/vi ... mymod5.sdz
I decided I might work on it again. I just cannot model.
Re: Can Somone make a simple gadget?
Untested but should be what you need:
Code: Select all
function gadget:AllowUnitCreation(u, ud, team)
local _,mstor = Spring.GetTeamResources(team, "metal")
local _,estor = Spring.GetTeamResources(team, "energy")
if estor - UnitDefs[ud].energyStorage < 0 or mstor - UnitDefs[ud].metalStorage < 0 then
return false
end
return true
end
Re: Can Somone make a simple gadget?
It prevents units being built or ordered after negative supplies are true, but it does not prevent it the negative supplies which locks everything up.
http://www.darkstars.co.uk/downloads/vi ... mymod6.sdz
http://www.darkstars.co.uk/downloads/vi ... mymod6.sdz
Re: Can Somone make a simple gadget?
Yeah, yeah, should be Xstor + blastorage