Page 1 of 1
Spawn Ship
Posted: 14 Feb 2011, 01:28
by Von66341
Hey! does any one know how do I get a ship to spawn in a map at the begining of the game?
My land units are able to spawn at the game, but not my ships.
Thanks.
Re: Spawn Ship
Posted: 14 Feb 2011, 01:29
by oksnoop2
Re: Spawn Ship
Posted: 14 Feb 2011, 01:41
by Von66341
Do we need to change anything in spawn.lua?
Re: Spawn Ship
Posted: 14 Feb 2011, 01:49
by knorke
the file oksnoop2 posted is just a config file for a gadget that reads the config and then spawns those units.
spawner gadget would be this:
http://code.google.com/p/conflictterra/ ... _spawn.lua
gadget comes from this thread:
http://springrts.com/phpbb/viewtopic.php?f=67&t=21883
I dont see why ships should be any different than land units. Does your ship work when you do
/cheat
/give unitname
?
Maybe give infolog.txt or upload your game.
Re: Spawn Ship
Posted: 14 Feb 2011, 01:51
by zwzsg
Make sure your ship is a valid unit by typing in the console:
/cheat
/give yourshipname
Re: Spawn Ship
Posted: 14 Feb 2011, 02:11
by Von66341
Sorry am little new to spring and lua.
what do you all meant by console?
cause in gameplay i couldn't type anything.
I did following to add a ship unit:
Under hq_spawn.lua, I added the ship I want to spawn.
For e.g part of the code:
ushq={
spread= 200,
units={
"ship1",
"ship2",
},
},
will this work?
In the gadget spawn.lua,
Part of the code is like this:
local function IsPositionValid(unitDefID, x, z)
-- Don't place units underwater. (this is also checked by TestBuildOrder
-- but that needs proper maxWaterDepth/floater/etc. in the UnitDef.)
local y = GetGroundHeight(x, z)
if (y <= 0) then
return false
end
-- Don't place units where it isn't be possible to build them normally.
local test = TestBuildOrder(unitDefID, x, y, z, 0)
if (test ~= 2) then
return false
end
-- Don't place units too close together.
local ud = UnitDefs[unitDefID]
local units = GetUnitsInCylinder(x, z, CLEARANCE)
if (units[1] ~= nil) then
return false
end
return true
end
Do i need to change anything?
Thanks lots for the help! =)
Re: Spawn Ship
Posted: 14 Feb 2011, 02:40
by knorke
console = the chat
http://answers.springlobby.info/questio ... est-my-mod
reading the comments, there seems to be some code that only spawns the unit if the position is a) on land and b) the position is not blocked.
Probally be best to start making your game from the example game:
http://springrts.com/wiki/The_Complete_ ... pring_Game
I think that is the "cleanest" example game there is.
if you start with modifying other games, you will always have left over things like this.
Re: Spawn Ship
Posted: 14 Feb 2011, 02:47
by Von66341
hey! i manage to test my units and they work when I key into the console.
When I key /give yourship name, the ship spawn on land, how can i let it spawn on water?
Any idea how I can edit the gadget: spawn.lua to allow my ship to spawn on water?
Re: Spawn Ship
Posted: 14 Feb 2011, 02:55
by knorke
When I key /give yourship name, the ship spawn on land, how can i let it spawn on water?
/give spawns the unit at your mouse pointer. so point it at water.
Any idea how I can edit the gadget: spawn.lua to allow my ship to spawn on water?
remove the part that checks for valid position or modify it. or use the gadget from the "complete guide to.." game that does not do such checks at all.
where did you find this spawn.lua?
Re: Spawn Ship
Posted: 14 Feb 2011, 04:27
by Von66341
Thanks all for the help! my ships are working! =)
knorke the spawn.lua found from spring1944.
Thanks alot for your help!