[E2] Getting error
KemGus opened this issue · 3 comments
Error:
[ERROR] lua/entities/gmod_wire_expression2/base/preprocessor.lua:504: attempt to index local 'portstbl' (a nil value)
1. ConvertDescriptions - lua/entities/gmod_wire_expression2/base/preprocessor.lua:504
2. Process - lua/entities/gmod_wire_expression2/base/preprocessor.lua:392
3. Execute - lua/entities/gmod_wire_expression2/base/preprocessor.lua:28
4. Include - lua/entities/gmod_wire_expression2/cl_init.lua:22
5. Validate - lua/entities/gmod_wire_expression2/cl_init.lua:80
6. Validate - lua/wire/client/text_editor/wire_expression2_editor.lua:1702
7. OnMousePressed - lua/wire/client/text_editor/wire_expression2_editor.lua:902
8. unknown - lua/wire/client/text_editor/issue_viewer.lua:151
Relevant code:
@name Remote Network Data Transfer System (RNDT) v 0.0.1
@inputs Radio:wirelink Radio:entity Activate:number
@outputs Recieve:number [One, Two, Three, Four, Five, Six, Seven]:number #[Radio inputs]#
@persist
@strict
#[
Description of the each channel.
]#
if(first() | dupefinished()){
#include "lib/rndt"
ReadyToRecieve = 1 # will send signals that it is going to interpret the given data.
TranfserChannels = 7 #Amount of recieving channels that radio has
Self = entity()
}
interval(100)
function number isRecieving(){
local Recieved = 0
for(I = 1, TranfserChannels){
local Key = Radio[I:toString(), number]
if(Key > 0){
Recieved = 1
}
}
return Recieved
}
if(Activate){
Recieve = isRecieving()
}
@outputs Recieve:number [One, Two, Three, Four, Five, Six, Seven]:number #[Radio inputs]#
You are not supposed to write down the variables in this format when grouping them with brackets.
This would be the intended "correct" format:
@outputs Recieve:number [One Two Three Four Five Six Seven]:number #[Radio inputs]#
But this would probably also "work", because of how the internal pre-processor handles the variable names:
@outputs Recieve:number [One,Two,Three,Four,Five,Six,Seven]:number #[Radio inputs]#
So basically either use Spaces only or Commas only, but not both.
Besides that, this still should not throw a Lua error, so the issue in general is still relevant.
For some reason PreProcessor:ConvertDescriptions(portstbl) receives a nil value, even though it is only being called on Lines 392-393 by PreProccesor:Proccess and the nil-check block on Lines 367-379 should make sure this doesn't happen.
Needs further investigation.
The error comes from including a file with any directives in it.
The error occurs because E2Lib.PreProcessor.Execute
can return either PPDirectives
or Error[]
as its second argument and the validate action does not check if an error occurred before trying to include the file.