Jump to content

getPlayers() or something?


MafiaPuppet

Recommended Posts

I see how to get a specific player or check if a specific player is visible or near to the current player, but is there a command to get ALL players or get ALL visible characters, or even just get ALL nearby characters? The only function that I could find that get groups of entities was ones that got people in the same room or the same building, and that isn't close enough for what I want to do.

 

Thanks for any help.

 

Edit: Found a count function for connections, which lets me make a list of players. Still if anyone knows of any other functions, that'd still be fun to know.

Link to comment
Share on other sites

Thanks so much.

 

Unrelated, but is there some kind of waiting function or public clock so I can delay commands? It seems like the OS library doesn't work with zomboid or something, so I'm not sure how to get functions to delay their execution X seconds or whatever...

 

The 10 minute event is not a solution to my problem, btw >.<

Link to comment
Share on other sites

Custom moodlets that tic happiness, panic, etc every few seconds, sort of like pills. 

 

I can't use something like thread.sleep cuz that freezes the game until the timer runs out, and os.execute doesn't seem to work.

 

Or am I just bad?

 

Anyway, it still sort of works with the 10 minute tic, but it's not as pretty as if it tic'd at the same rate as pills.

Link to comment
Share on other sites

as far as i know timers and such are disabled yea, at least havent seen it used so far...

alternatively you could use OnTick event and simply count an x amount of ticks then trigger a function that applies effect... not as reliable, also not sure if the game can run at different cycle rates youd have to take that in account as well. (server runs at lower rate for sure, 12t/sec i believe)

 

perhaps for moodles tenmins is the safest bet.

Link to comment
Share on other sites

For mp they've recently added this command:

local players 		= getOnlinePlayers();

works both on server and client, its available as of b27 if im not mistaken.

 

I started to try this method, but getOnlinePlayers() returns a java array instead of a lua table. How do you manipulate a java array with Kahlua? Is there a conversion function?

Link to comment
Share on other sites

No conversion needed, can be done like this for example (note the array in question is IsoPlayer array)

local players 		= getOnlinePlayers();local array_size 	= players:size();for i=0, array_size-1, 1 do	local player = players:get(i);	if player:getUsername() == "TurboTuTone" then		player:Say("Hi it is I, turbo");	endend	
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...