2018-10-19         Jay

Lua - util_server.lua:440 attempt to index local 'self' (a nil value)

Good eveningWill you help me solve this problem?ERROR: race/util_server.lua:440: attempt to index local 'self' (a nil value) function string:split(separator) if separator == '.' then separator = '%.' end local result = {} for part in self:gmatch('(.-)' .. separator) do result[#result+1] = part end result[#result+1] = self:match('.*' .. separator .. '(.*)$') or self return resultend You're probably calling it wrong.function string:split(separator)Is short hand for:function string.split(self, separator)Given a string and separator: s = 'T...

 lua                     1 answers                     58 view
 2018-10-19         Curitis

lua error: attempt to index field 'frames'(a nil value)(but self and lacal errors)

I'm trouble to understand self and local value.Here is my asteroid.lua. I created local asteroid inside :create and was trying to use it other function but it is not working correctly.-- Class DeclarationAsteroid = {}Asteroid.__index = Asteroidfunction Asteroid:create()local asteroid = {}setmetatable(asteroid, Asteroid)-- Animation Dataasteroid.frames = {}asteroid.currentFrame = 1asteroid.frameDuration = 0.04 -- 0.016asteroid.frameTimeRemaining = asteroid.frameDurationasteroid.x = 0asteroid.y = 0return asteroidendfunction Asteroid:init()-- Use a loop to load a bunch of fil...

 lua                     1 answers                     58 view
 2018-10-21         Dunn

How can i animate sprites in lua when i press the right arrow?

i'm new to Defold and coding, i have been following a video tutorial from Gamefromscratch to animate sprites which is this one https://www.youtube.com/watch?v=ha1Wq2FB7L0&t=5s buto could not make it move when i press the right arrow, it is just stands in idle position.local currentAnimation = 0function init(self) msg.post(".", "acquire_input_focus")endfunction final(self) -- Add finalization code here -- Remove this function if not neededendfunction update(self, dt)endfunction on_message(self, message_id, message, sender) -- Add message-handling code here ...

 lua                     1 answers                     104 view
 2018-10-21         Yvette

Alternative to Modulus in Lua

In Lua, as you may know, arrays start with index 1.In other languages I will often use modulus to make a value oscillate through the members of an array, for example:i = (i + 1) % array.lengthreturn array[1]How can I do this in Lua, where array[0] is nil by default. Like Egor said in the comments, First do the modulo and then increment the value.If i is equal to the length it will end up 0. Incrementing that will result in 1. Every other value just gets incremented.This only works when incrementing by 1 though. For bigger steps you can do i = (i+n-1)% #array + 1 [XXX]

 lua                     1 answers                     27 view
 2018-10-21         Annabelle

Looping and adding chars to string in LUA

It's about Lua/Roblox. (Disclaimer: must be roblox compatible.) I have an array called "array1", and a number value "num" which is 0.local array1 = {"1","2","3","etc."}local num = 0I do:while 1 do wait(1) -- just a little delay between loops num = num + 1 -- every loop I'm increasing that "num" value with 1. script.Parent.TextLabel.Text = array1[num] -- I'm setting Text to [num]th (in this case 1) of array1. (I get 1st, 2nd, 3rd, 4th etc. word every second)endAnd it works. Kinda. My problem is, it's setting it to:"1" and then only "2", not "1" and then "12".Here's some v...

 lua                     1 answers                     28 view
 2018-10-21         Stacey

What is the recommended way to manage dev dependencies in Lua projects?

I'm building a Lua library (an internal kong plugin actually), and this is the first time I'm using Lua - let alone writing production code with it.I've made it a luarock. From what I can see, the rockspec lets me specify other libraries as dependencies. But there doesn't seem to be a notion of dev-dependencies as such. Like for example, libraries that I need for my tests, mocks etc... And I would rather not make them part of the actual dependencies list.I've resorted to keeping my dev-dependencies in the dependencies list, but commenting them out before a git push. How is ...

 lua                     1 answers                     49 view
 2018-10-21         Gary

Adding Softmax to ResNet model in Torch

Context: I'm trying to modify this Facebook's ResNet feature extractor script to classify an image and print the ImageNet class label.Let's say I have the model in torch:local model = torch.load('resnet-101.t7')local output = model:forward(img:cuda()):squeeze(1)That gives me the scores for each class. I want to obtain the top 5 classes and their probabilities. I think that to transform scores to probabilities I should use a SoftMax layer first.So I do: local model = torch.load('resnet-101.t7')local softMaxLayer = cudnn.LogSoftMax()model:add(softMaxLayer)local output = model...

 lua                     1 answers                     13 view
 2018-10-21         Laura

Lua string.format and use of newline or control characters

I'm trying to string.format for raw output to the uart using NodeMCU.I'm trying the functionuart.write(0,string.format("loop %03d local: %02d | gmt %02d:%02d:%02d local %02d/%02d/%04d\n",loops,timezonetime,gmthours,gmtmins,gmtsecs,Nmonth,Nday,Nyear))but the \n is ignored, and text is concatenated. print(string.format("loop %03d local: %02d | gmt %02d:%02d:%02d local %02d/%02d/%04d",loops,timezonetime,gmthours,gmtmins,gmtsecs,Nmonth,Nday,Nyear))works as expected, but I can't control the newline always added by print()How can I use uart.write and string.format to control the ...

 lua                     1 answers                     50 view
 2018-10-21         Anna

Is it possible to change the output of Lua error messages?

I managed to change the output of error messages by modifying the dbg_printf method. However, that method doesn't handle the following error messages:lua: ?:0: attempt to call global 'log' (a nil value)Which method(s) handle these types of errors? The error message is from the file ldebug.c in the function luaG_typeerror. But i guess you are using an older Lua Version because my message is a bit different:attempt to call a nil value (global 'log')You sould try to prevent the error if you can:if type(log) == "function" then log() endor as @lhf said use pcall:if pcall(lo...

 lua                     2 answers                     52 view
 2018-10-21         Yetta

Add a dissector on USB protocol

I am currently working on a homemade USB protocol to get to know dissectors in wireshark.I have written my dissector with Lua and added it to wireshark but I don't really understand the dissector table and especially how to apply my homemade protocol.Here is my code:rssi_protocol = Proto("RSSI", "RSSI protocol")header = ProtoField.ubytes("rssi.header", "Header", base.NONE)Rx = ProtoField.uint8("rssi.rx", "Reception time", base.HEX)Tx = ProtoField.uint8("rssi.tx", "Transmission time", base.HEX)Power = ProtoField.uint8("rssi.power", "Power Attenuation", base.HEX)RSSI1 = Proto...

 lua                     1 answers                     44 view
 2018-10-22         Maria

how to delete all redis keys using lua

i am trying to delete all redis keys in my redis dataset Except some IDs which are also stored in redis.if matches[1] == 'del keys' then list = redis:smembers("grid") <-- id list for k,v in pairs(list) do keys = redis:keys('*') for k1,v1 in pairs(keys) do if v ~= v1 then run_bash("redis-cli KEYS *"..v1.."* | xargs redis-cli DEL") end end end return "done .."endBut it doesn't work and I can't figure out what I am doing wrong If the number of keys you want to delete are much more than keys you want to...

 lua                     1 answers                     22 view
 2018-10-22         Eric

ROBLOX Lua - Wrong Rank colour being given to player despite having different color id in script

Hey guys so I've made a Rank GUI system that can be seen above players in-game.local billboardgui = game:GetService("ServerStorage"):WaitForChild("BillboardGui")game.Players.PlayerAdded:Connect(function(player)player.CharacterAdded:Connect(function(character) if player:IsInGroup(4348965) then -- Set the number to your group ID ! local clonedgui = billboardgui:Clone() clonedgui.TextLabel.Text = "Group member" clonedgui.TextLabel.TextColor3 = Color3.fromRGB(36,154,136) clonedgui.Parent = game.Workspace:WaitForChild(player.Name).Head -- Yes, you ...

 lua                     1 answers                     98 view
 2018-10-22         Polly

Lua: Unpack with nil? Alternative?

I've run into the age old unpack bug, where I have an array in Lua that can contain nil values, and I want to unpack the array with the nil values; which seems is not possible. What is the alternative to this logic?Here is the code I am attempting to runfunction InputSystem:poll(name, ...) local system = self:findComponent(name) local values, arr = {...}, {} for i, v in pairs(values) do arr[#arr+1] = system[v] end --If the first guy is null this does not work!! WHY return unpack(arr, 1, table.maxn(values))endThe idea is I poll my input system dynamically so that I ...

 lua                     2 answers                     106 view
 2018-10-22         George

How to Disambiguate Command Line and Variable Arguments in Lua?

Specifically, Luajit.I am writing a script as a learning exercise and am attempting to use variable arguments. However, doing so just prints the command line arguments. I double-checked the documentation and, indeed, both applications use the arg variable.How do I specify when I want to use one instead of the other?function init(...) for k,v in pairs(arg) do print(k,v) end -- Function body.endOutput,0 /.../lua_script.lua-1 luajit LuaJIT, stemming from Lua 5.1, uses the newer vararg syntax, wherein you manually capture the varargs into a table:function init (...)...

 lua                     1 answers                     91 view
 2018-10-22         Warner

uwsgi nginx lua, I've only seen 500 Server Errors. uwsgi log only re spawns

Ok here is what I have already tried, on the nginx#location ~ \.lua$ {# include uwsgi_params;# uwsgi_modifier1 6;# uwsgi_pass unix:/var/run/uwsgi/luajit/socket;#}#location ~ / {# include uwsgi_params;# uwsgi_param UWSGI_FILE $request_filename;# uwsgi_param UWSGI_TOUCH_RELOAD $request_filename;# uwsgi_param SCRIPT_NAME $uri;# uwsgi_modifier1 9;# if (-f $request_filename) {# uwsgi_pass unix:/var/run/uwsgi/luajit/socket;## }# }#location ~ \.c...

 lua                     1 answers                     25 view
 2018-10-22         Gladys

Running secrulescript lua against a response message

How do I access a response in a lua scriptwhen calling it via SecruleScript ?I am able to do so with REQUESTS as so:SecRuleScript "/myscript.lua" \ "id:12345,phase:2,deny,log"But the script does not trigger upon for response messages it seems.I have tried the following but not gotten anything:local response_body = m.getvar("RESPONSE_BODY")local output_body = m.getvar("STREAM_OUTPUT_BODY") Did you check, the RESPONSE_BODY is available in ModSec itself? That's a bit tricky as it depends on the content-type and you might need to enable it for your content-type.Otherwise,...

 lua                     1 answers                     63 view

Page 1 of 49  |  Show More Pages:  Top Prev Next Last