Page 1 of 1
building remains at 0%
Posted: 24 Sep 2010, 20:01
by thedude
When I try to build a factory and give a build command to it the factory is created but it won't build the unit (well I can see the wireframe of the model and building-bar remains at 0%). When I cheat the factory and give it a build order then it will build the unit (so the yardmap should me ok right?).
Here are the functions I use:
Code: Select all
Create the factory:
(builder is global)
builder=Spring.CreateUnit("bsupportfactory",1000,0,200,0,gaia)
Give build command:
local defID = UnitDefNames.bot.id
Spring.GiveOrderToUnit(builder, CMD.INSERT, {-1,-defID,0,1060,0,300}, {"alt","ctrl"});
AFAIR the code worked in 0.82.3 but it is also possible that I changed something cause it has been a while since I made this gadget.
Have I to set the CanMove tag to true to make the factory beeing able to build units? Cause most factories have the CanMove tag set to true. My factory has the CanMove tag set to true and MaxVelocity to "0" atm.
Re: building remains at 0%
Posted: 25 Sep 2010, 12:22
by KDR_11k
Is Gaia able to afford building stuff?
Re: building remains at 0%
Posted: 25 Sep 2010, 13:56
by thedude
Yes gaia is allowed to produce stuff. It seems like the "unit-file" of the factory has something that makes spring not letting the factory build the unit (by using luascript).
Re: building remains at 0%
Posted: 25 Sep 2010, 14:28
by KDR_11k
Gaia can produce stuff but does it have resources in the bank? I'm not sure zero costs are handled properly.
Re: building remains at 0%
Posted: 25 Sep 2010, 17:44
by yuritch
From my experience with S44, engine requires resource amount to be greater than 0 to produce things, even if those things cost 0. So zero costs don't seem to be handled properly.
Re: building remains at 0%
Posted: 25 Sep 2010, 18:36
by thedude
I tried another factory I made and the code works using that one. So I think it has something to do with the unit-file or the script-file. I set buildCostEnergy and buildCostMetall to 1. Btw does GAIA also start with 1000 of metal and energy?
The factory which does not work has a build-in platform on one side this is where I try to build the units. So I don't need any animation for that one.
This is the unitscript (is it OK??)
Code: Select all
local cube = piece "Cube"
local build = piece "build"
--local nano = piece "nano"
--local bp = piece "bp"
--local rp = piece "rp"
function script.Create(unitID)
end
function script.QueryBuildInfo() return build end
function script.QueryNanoPiece() return build end
function script.Activate()
SetUnitValue(COB.YARD_OPEN, 1)
SetUnitValue(COB.INBUILDSTANCE, 1)
return 1
end
function script.Deactivate()
SetUnitValue(COB.YARD_OPEN, 0)
SetUnitValue(COB.INBUILDSTANCE, 0)
return 0
end
function script.Killed(recentDamage, maxHealth)
return 0
end
Do the hitsphere and the hight (set in upspring) has an influence on the build-process? (like: the sphere of the factory has to cover the one of the built unit or the hight of the factory has to be bigger than the one of the built unit or something like that?)
Re: building remains at 0%
Posted: 25 Sep 2010, 22:01
by KDR_11k
I don't believe Gaia gets any default storage.
Re: building remains at 0%
Posted: 25 Sep 2010, 22:54
by FLOZi
Resources / Storage should be setup in the start unit spawning gadget now anyway
Re: building remains at 0%
Posted: 26 Sep 2010, 21:35
by thedude
Thanks guys! Yes the problem was GAIA not having any resources. (the working factory produced resources so it worked)
FLOZi wrote:Resources / Storage should be setup in the start unit spawning gadget now anyway
Do you mean in the "modoptions.lua" file ?
cause "game_spawn.lua" says:
Code: Select all
-- set start resources, either from mod options or custom team keys
local teamOptions = select(7, Spring.GetTeamInfo(teamID))
local m = teamOptions.startmetal or modOptions.startmetal or 1000
local e = teamOptions.startenergy or modOptions.startenergy or 1000
So if I won't set the start resources all teams will start with 1000 but gaia will start with 0, right?
Re: building remains at 0%
Posted: 26 Sep 2010, 21:38
by FLOZi
I meant that you can just give gaia infinite resources right there in game_spawn.lua
Re: building remains at 0%
Posted: 26 Sep 2010, 21:49
by thedude
How can one set it to infinite or do you mean just very big amount.
or can I just do it like this:
Code: Select all
Spring.SetTeamResource(gaia, "ms", infinite)
Spring.SetTeamResource(gaia, "m", infinite)
Re: building remains at 0%
Posted: 26 Sep 2010, 23:26
by zwzsg
Infinite is spelt math.huge in Lua.
But yeah sounds safer to give very a big amount instead.