Rinart73 Posted August 13, 2018 Share Posted August 13, 2018 0.18.2 - r12552, Windows 10 x64 I'm in the singleplayer game. I add some code to the "data/scripts/server/server.lua" file, at the end of "update" function: local players = {Server():getPlayers()} print("#players = ", #players) local playersOnline = {Server():getOnlinePlayers()} print("#playersOnline = ", #playersOnline) In the first case I get 0, in the second - 1. So I guess something is wrong with the "Server():getPlayers()" function? Link to comment Share on other sites More sharing options...
Sandworm Posted August 19, 2018 Share Posted August 19, 2018 I'm *just* starting to fiddle around with scripting, and this is one of the first functions I was messing with in the console. I'm also Single Player Win 10 x64 on r12552. In the console if I do /run Server():getPlayers() it returns a Player object. /run Server():getPlayers().name returns the correct name. /run x = {Server():getPlayers()}, print(x) prints nil. I'm also just learning LUA - do the "{}" in variable declaration denote an array? Because it seems weird that that my first example returns a Player object, but surrounding it with curly braces to make it an array variable screws things up. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now