Search the Community
Showing results for tags 'tables'.
Hi, i stumbled on a new issue while learning. Or i would say that i am not understanding the mechanic i just did because its not how i readed it from docs. instructionSet = gg.getValues(values) -- create new table with address, flags, value -- instructionSet function instructions(instructionSet) -- function parameters (instructionSets) if (instructionSet < 0x40) then print(type(instructionSet)) print("this is 32 bits") else print("this is 64 bits") end return instructionSet end print("instructionset", instructions(instructionSet.value)) -- function call (instructions(...) function dataTypes(dword, instructions) if (dword*10 == instructions.value) then result = dword print("dataType is size four") else result = qword print("dataType is size eight") end return result end print("dataType", dataTypes(4, instructionSet)) currently in the first function, instructionSet is of type number. and compared to the hex 0x40 but if i change the name of the parameter of the function "instructions" function instructions(instructionSet) -- function parameters (instructionSets) instructionSet is then not recognized anymore as type number but changes to a type table. I am then forced to let it know that i want to compare int values specifying field value, (the fact that it changes from number to table i don't understand) if (instructionSet.value < 0x40) then In some sources i understand that parameters can basically have any name. So if i use the table name as a function parameter i should only be able to use them in the function it self. Or at least, the functionality of the body in the functions should not be directly effected by some parameter change. Then there is the other part of the script which i have questions about. In the function dataTypes function dataTypes(dword, instructions) i use "instructions" as a parameter which i don't think would be an issue. And as values i use "instructionSet" which is where i would as my other question. print("dataType", dataTypes(4, instructionSet)) why is instructionSet here of type table? during comparison with 0x40 its type was a number. Then in the other function it changed back to type table. then when i want to compare it in function dataTypes i am forced to compare it as a table. which is for my current understanding odd. Some insights would be great. Thank you.