gaurding something that is guarding something

gaurding something that is guarding something

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

Moderator: Moderators

Post Reply
User avatar
smartie
NOTA Developer
Posts: 146
Joined: 23 Jun 2005, 19:29

gaurding something that is guarding something

Post by smartie »

I've been having some weird problems getting this to work for some reason. There's three units, a bulldog, a warrior, and a lightning tank. The bulldog guards the warrior and the warrior guards the lightning tank. It should be simple but it doesn't work. When the script runs only the warrior is guarding the lightning tank. If that order is commented out (its the second one down) then the bulldog will be guarding the warrior when the script runs. Somehow the order given to the warrior is interfering with the bulldog or something. It doesn't matter what order the commands come in, the end result is the same.

So what might I be doing wrong here?

Code: Select all

local CreateUnit = Spring.CreateUnit
local GiveOrderToUnit = Spring.GiveOrderToUnit
local AddBuildOrders = Spring.AddBuildOrders
local CreateFeature = Spring.CreateFeature

if (gadgetHandler:IsSyncedCode()) then

if (Game.mapName ~= "Grts_Cookedwell_001.smf") then
	gadgetHandler:RemoveGadget()
	return
end

local u = {}

local function SpawnShit()
	u[461]  = CreateUnit("armwar",9190,754.88049316406,1407,0, 0)
	u[8638]  = CreateUnit("armbull",9209.30078125,754.88049316406,1265.8809814453,0, 0)
	u[4968]  = CreateUnit("armlatnk",9190,754.88049316406,1546,0, 0)

	GiveOrderToUnit(u[8638],25,{u[461],},16)
	GiveOrderToUnit(u[461],25,{u[4968],},16)

	Spring.MarkerAddPoint( 8674, 756.88049316406, 1444, "HI" )
end

function gadget:GameFrame(n)
	if (n == 0) then
		SpawnShit()
	end
end

end
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: gaurding something that is guarding something

Post by zwzsg »

Maybe it's not the problem, but I would try to Spawn Shit at frame like 3, and give orders to shit at frame like 5.
User avatar
smartie
NOTA Developer
Posts: 146
Joined: 23 Jun 2005, 19:29

Re: gaurding something that is guarding something

Post by smartie »

woah that was it

it didnt' have a problem with the spawning and orders on the same gamecycle, but once i set the original delay for spawnshit to 10 everything worked. Thanks
User avatar
REVENGE
Posts: 2382
Joined: 24 Aug 2006, 06:13

Re: gaurding something that is guarding something

Post by REVENGE »

Pace your shit mang.
User avatar
Pendrokar
Posts: 658
Joined: 30 May 2007, 10:45

Re: gaurding something that is guarding something

Post by Pendrokar »

zwzsg wrote:Maybe it's not the problem, but I would try to Spawn Shit at frame like 3, and give orders to shit at frame like 5.
Goddamnit! I knew that was probably it for him...

I was just too shy to tell. :oops:
Post Reply

Return to “Lua Scripts”