Page 1 of 1

controlling team spawn

Posted: Sun Aug 16, 2015 11:39 pm
by ZoomV
So I have this conquest map with two local teams, one friendly to ATT the other to DEF. I'm trying to set it up to where the team friendly to ATT only spawns if ATT's reinforcement's are below DEF's and if DEF's reinforcements are above 30. Vise Versa applies to the local's friend to DEF.

LUA seems like witchcraft to me, so I am hoping one of you guys might have advice.

Re: controlling team spawn

Posted: Mon Aug 17, 2015 12:44 am
by AQT
Here's a very similar code that you can use as a base: http://www.gametoast.com/viewtopic.php?p=328409#p328409

Re: controlling team spawn

Posted: Mon Aug 17, 2015 4:40 pm
by ZoomV
AQT wrote:Here's a very similar code that you can use as a base: http://www.gametoast.com/viewtopic.php?p=328409#p328409
<_<
>_>
huh, I completely blanked on there being a GetReinforcementCount call. I was trying to do something crazy with OnTicketCountChange.


Anyways, is there a way to print a message in the log so I can have it tell me when it does its thing, and what syntax would be necessary to get said log message also print the reinforcements at that point?

Re: controlling team spawn

Posted: Tue Aug 18, 2015 9:08 am
by Marth8880
ZoomV wrote:Anyways, is there a way to print a message in the log so I can have it tell me when it does its thing, and what syntax would be necessary to get said log message also print the reinforcements at that point?
Sure. The function you're looking for is print(). Here's its usage:

Code: Select all

i = "Hello World!";
print(i); -- prints "Hello World!" (without quotes)
Or you could use Lua's concatenate, which is .. (two periods) to bind parts together:

Code: Select all

i = "Hello World!";
print("Message: "..i); -- prints "Message: Hello World!" (without quotes)
And here's an example from MEU of printing multiple variables in the same function call:

Code: Select all

	local screenWidth, screenHeight = ScriptCB_GetScreenInfo()
	local aspectRatio = screenWidth / screenHeight
		print("ME5_MiscFunctions:    Width: "..screenWidth.."    Height: "..screenHeight.."    Aspect Ratio: "..aspectRatio)
The idea is you're printing a string directly with quotations in the print() function, or you're printing a variable, or both.

In your case, you'd want to assign the result of GetReinforcementCount to a variable, and then print that variable (possibly with a message for organization/clarity reasons).

Re: controlling team spawn

Posted: Tue Aug 18, 2015 11:16 pm
by [RDH]Zerted
Don't use concatenate, use commas instead. If you try to concatenate a nil value it'll crash. It doesn't crash if you use commas.

Examples:

Code: Select all

print('Team: ', DEF, 'count:', GetReinforcementCount(DEF))

local impCount = GetReinforcementCount(IMP)
print('Team:', IMP, 'count:', impCount)
In Lua you can use ' or " for string (but not both at the same time: 'this is wrong").