lua

GetPlayers not working on server side script

◇◆丶佛笑我妖孽 提交于 2021-01-29 09:01:14
问题 I am learning lua making games in Roblox. I have this sample of code that I got from their developer website. Players = game:GetService("Players") for i, player in pairs(Players:GetPlayers()) do print(player.Name) end This code works when I paste it in a local script but it doesn't when I paste it in a server side script. I don't get an error, but nothing gets printed. I am wondering why this is, and also what code do I need to use to get all players from a server side script. Thanks Edit ---

Having problems with Sleep() func on MouseMoveRelative on LUA

主宰稳场 提交于 2021-01-29 07:13:04
问题 got a new drive and installed a fresh windows. Before on old OS, i could use "Sleep" to make "MoveMouseRelative" work like it was natural movement. i have created a function were i can move the mouse calling it with how many times i want it to "move" and with the milliseconds between each "move" Example:(works well) function _move(x, range, time, range2) for i = 1, x do MoveMouseRelative(range,range2) Sleep(time) end end n If i set "Sleep(1)" beteween each "MoveMouseRelative" it moves like it

Find substring between specific characters

安稳与你 提交于 2021-01-28 21:59:11
问题 I am unfamiliar with Lua language and a I would like your help. I am trying to receive some values through POST and the values is something like that: pwd = password ssid = ssid_name swstat={string.find(payload,"pwd=")} swstat1={string.find(payload,"ssid=")} if swstat[2]~=nil then pass=string.sub(payload,swstat[2]+1,#payload) ssid=string.sub(payload,swstat1[2]+1,#payload) print("Password: "..pass) print("SSID: "..ssid) end The actual result of the above code is ( am sending through a web

Find substring between specific characters

被刻印的时光 ゝ 提交于 2021-01-28 21:39:29
问题 I am unfamiliar with Lua language and a I would like your help. I am trying to receive some values through POST and the values is something like that: pwd = password ssid = ssid_name swstat={string.find(payload,"pwd=")} swstat1={string.find(payload,"ssid=")} if swstat[2]~=nil then pass=string.sub(payload,swstat[2]+1,#payload) ssid=string.sub(payload,swstat1[2]+1,#payload) print("Password: "..pass) print("SSID: "..ssid) end The actual result of the above code is ( am sending through a web

Local variables in global scope Lua

妖精的绣舞 提交于 2021-01-28 20:24:06
问题 So let's say I have a lua file, and at the top, I define a variable outside of any function, but I call it local local x = 1 Is there any difference between that local x, and a global x? 回答1: Yes, as it is local to the chunk that it is created in. Lua handles a chunk as the body of an anonymous function with a variable number of arguments (see §3.4.11). As such, chunks can define local variables, receive arguments, and return values. Moreover, such anonymous function is compiled as in the

How to dump all _G table content

荒凉一梦 提交于 2021-01-28 12:24:58
问题 i want to dump _G table. in _G table has other table also dump (inline table). and i want have a good format. i have a example but use it dump _G table have some problem function print_table(node) -- to make output beautiful local function tab(amt) local str = "" for i=1,amt do str = str .. "\t" end return str end local cache, stack, output = {},{},{} local depth = 1 local output_str = "{\n" while true do local size = 0 for k,v in pairs(node) do size = size + 1 end local cur_index = 1 for k,v

Difference between two tables as a table

馋奶兔 提交于 2021-01-28 10:50:12
问题 IN SHORT t1 = {1,3,5,7,9} t2 = {1,2,3,4,5,6,7,8,9} result wanted: t3 = {2,4,6,8} LONG EXPLANATION I have a list of objects in a scene, and I have a list of all objects not in the scene. I am trying to write a simple bit of code that will allow me to add objects to the scene but make sure that it does not load an object that has already been loaded. So I can say something like.... SafeAdd (2, currentOBJlist, notLoadedOBJList) and have the app load in 2 random objects from "notLoadedOBJList"

Difference between two tables as a table

半世苍凉 提交于 2021-01-28 10:48:59
问题 IN SHORT t1 = {1,3,5,7,9} t2 = {1,2,3,4,5,6,7,8,9} result wanted: t3 = {2,4,6,8} LONG EXPLANATION I have a list of objects in a scene, and I have a list of all objects not in the scene. I am trying to write a simple bit of code that will allow me to add objects to the scene but make sure that it does not load an object that has already been loaded. So I can say something like.... SafeAdd (2, currentOBJlist, notLoadedOBJList) and have the app load in 2 random objects from "notLoadedOBJList"

Replace a substring in Lua with a pattern

我是研究僧i 提交于 2021-01-28 03:03:10
问题 I have a string like this str = '["username"] = "user"; ["deepscan"] = "true"; ["token"] = true; ["password"] = "krghfkghkfghf"; ["uploadMethod"] = "JSON"; ["serviceIsRunning"] = {}; ["host"] = "sample.com"; ["instance_ID"] = 405454058;' I would like the pattern match ["password"] = and have it replace only the string in between the ";' that would be '"krghfkghkfghf" in this instance. 回答1: local function replacePass(configstr, newpass) return configstr:gsub("(%[\"password\"%]%s*=%s*)%b\"\"",

Replace a substring in Lua with a pattern

喜夏-厌秋 提交于 2021-01-28 00:34:05
问题 I have a string like this str = '["username"] = "user"; ["deepscan"] = "true"; ["token"] = true; ["password"] = "krghfkghkfghf"; ["uploadMethod"] = "JSON"; ["serviceIsRunning"] = {}; ["host"] = "sample.com"; ["instance_ID"] = 405454058;' I would like the pattern match ["password"] = and have it replace only the string in between the ";' that would be '"krghfkghkfghf" in this instance. 回答1: local function replacePass(configstr, newpass) return configstr:gsub("(%[\"password\"%]%s*=%s*)%b\"\"",