Can Somone make a simple gadget?

Can Somone make a simple gadget?

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
Noruas
XTA Developer
Posts: 1269
Joined: 24 Feb 2005, 02:58

Can Somone make a simple gadget?

Post by Noruas »

If the unit takes negative storage, and causes the main storage to go into negative values, can its construction be completely stopped and refused?
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Can Somone make a simple gadget?

Post by Argh »

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.
User avatar
Noruas
XTA Developer
Posts: 1269
Joined: 24 Feb 2005, 02:58

Re: Can Somone make a simple gadget?

Post by Noruas »

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.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: Can Somone make a simple gadget?

Post by KDR_11k »

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
User avatar
Noruas
XTA Developer
Posts: 1269
Joined: 24 Feb 2005, 02:58

Re: Can Somone make a simple gadget?

Post by Noruas »

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
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: Can Somone make a simple gadget?

Post by KDR_11k »

Yeah, yeah, should be Xstor + blastorage
Post Reply

Return to “Lua Scripts”