Need Help With .lua Please Help! Player_ID

I’m not very knowledgeable with .lua but just came across a small bug with my mod when playing multiplayer. In my necromancer mod when the necromancer summons, they assign the summon to a player_id. Right now, it seems that since my mod was originally made for single player the id set is “player_1” This makes it where if playing multiplayer every is owned by Player 1. I’m curious as to how I might be able to set the player_id to whoever performed the action

Ohh yeah i remember that. My friend stole all of my loot. cant hel you tho, sorry

@AndrealVox, in your execute_summon_action.lua, find the _create_summon function and the line inside it that sets the id to ‘player_1’.

Since you already have a reference to the summoner in that function, you can easily change this:

radiant.entities.set_player_id(summon, 'player_1') 

to this:

radiant.entities.set_player_id(summon, summoner:get_player_id()) 

That way they’ll be assigned to whoever’s town summoned them.

Hope it helps.

3 Likes

Thanks so much! I had removed ‘player_1’ last night and replaced it with summoner only. I thought it worked, but that :get_player_id() totally did the trick :wink: I had the magical @Banto help me test it on stream today. No more are the days where Player 1 controlled all!

3 Likes

i like that new summon ability with trees :wink:

2 Likes