Jump to content


Replying to Understanding SGroups


Post Options

    • Can't make it out? Click here to generate a new image

  or Cancel


Topic Summary

fuggles

Posted 01 August 2022 - 06:01 AM

Khornes driving school of the gifted does something similar if useful.

Gambit

Posted 03 July 2022 - 12:17 PM

The code does introduce some "irregularities",... Regardless, the reason it is not working is that you need to SPAWN the squad :grad:

Squad_Create, simply creates the squad in "despawned" state.

In order to select it, you need to spawn it to the world via Squad_Spawn(child) (immediately after the Squad_Create).


YOUSLESS

Posted 01 July 2022 - 03:14 AM

Update:

function Punisher_Init()
	ind = Tut_GetLocalPlayerIndex()
	client = World_GetPlayerAt(ind)
	build = Player_GetEntities(client)
	PID = Player_GetID(client)
	hq = EGroup_GetSpawnedEntityAt(string.format("__Player%dEntities", PID),1)
	spawn = Entity_GetPosition(hq)
	child = Squad_Create("guard_squad_civilian_child_a", client, spawn, 0)
	one = SGroup_Create("1")
	two = SGroup_Create("2")
	three = SGroup_Create("3")
	four = SGroup_Create("4")
	SGroup_Add(one, child)
	W40k_AssignHotkeySGroup( "1", 0 )
	W40k_AssignHotkeySGroup( "2", 9 )
	W40k_AssignHotkeySGroup( "3", 8 )
	W40k_AssignHotkeySGroup( "4", 7 )
	Rule_Add(Rule_Monitor1)
	print("successfully initialized")
end

function Rule_Monitor1()
	Misc_GetSelectedSquads(SGroup_CreateIfNotFound("sg_Player1selection"))
	t_builder1 = Util_MakeBlueprintTable(
		"guard_squad_civilian_child_a"
		)
	if SGroup_ContainsBlueprints("sg_Player1selection", t_builder1, false) ==  true then
		print("pressed 0")
	end
end

I switched to this, SGroup_IsSelected didn't seem to work, but this configuration isn't working either, I think its becuase the squad I spawn in doesn't actually show up but I'm trying to find out why


YOUSLESS

Posted 30 June 2022 - 10:07 PM

I am not 100% sure, but I think the SGroup must not be empty...

(Arbitrary conjecture) I think that the SGroup_IsSelected boolean function  is True, only if at least one squad of the SGroup is selected...

reading the documentation it says all squads have to be selected, I'll try to put something in the SGroup. Its done with Sgroup_Add right?


Gambit

Posted 30 June 2022 - 06:09 PM

I am not 100% sure, but I think the SGroup must not be empty...

(Arbitrary conjecture) I think that the SGroup_IsSelected boolean function  is True, only if at least one squad of the SGroup is selected...


YOUSLESS

Posted 30 June 2022 - 02:33 AM

Hello, I have started trying to use SGroups as a means to read input from the keyboard

function Punisher_Init()
	ind = Tut_GetLocalPlayerIndex()
	client = World_GetPlayerAt(ind)
	SGroup_Create("1")
	SGroup_Create("2")
	SGroup_Create("3")
	SGroup_Create("4")
	W40k_AssignHotkeySGroup( "1", 0 )
	W40k_AssignHotkeySGroup( "2", 9 )
	W40k_AssignHotkeySGroup( "3", 8 )
	W40k_AssignHotkeySGroup( "4", 7 )
	Rule_Add(Rule_Monitor1)
	print("successfully initialized")
end

function Rule_Monitor1()
	if SGroup_IsSelected("1") then
		print("pressed 0")
	end
end

When I press 0 the game selects an empty squad but when I check the logs nothing printed, what am I doing wrong?


Review the complete topic (launches new window)