im trying to make a small custom Os. i managed to get the BIOS working and now im trying to load libraries to the lua enviroment (OpenOS does the same from my understanding)
i have a function that iterates over all the files on /lib/core and loads them. however im getting an error that i did not manage to solve. Here is the first part of the function:
clarification: as im working almost at bios level, i dont have access to some functions like print(). so i use error() to print a message in screen
--loading libraries in /lib/coredofor _, object in pairs(component.invoke(addr,"list","/lib/core"))do--equivalent to component.filesystem.list("/lib/core") then object becomes a file or directory in /lib/core for each iteration--if i call error(object) at this point the message reads the correct content of objectifnot component.invoke(addr,"isDirectory","/lib/core/".. object)then--if object is not a directory (a file) local lib, err = loadfile("/lib/core/".. object)--calls loadlib. this function reads the file and returns a function lib. when lib is called it returns the table corresponding to the library loaded--at this point when i call error(type(object)) i get that object is a stringlocal name = string.sub(object,1,#object -4)--here i get the error "attempt to get length of a number value" sugesting that object has now became a number--[...]
i have been thinkering for some time now, however i didnt manage to solve the error. Thanks
error using string.sub(stringObject), "attempt to get length of a number value"
in Programming
Posted
im trying to make a small custom Os. i managed to get the BIOS working and now im trying to load libraries to the lua enviroment (OpenOS does the same from my understanding)
i have a function that iterates over all the files on /lib/core and loads them. however im getting an error that i did not manage to solve. Here is the first part of the function:
clarification: as im working almost at bios level, i dont have access to some functions like print(). so i use error() to print a message in screen
i have been thinkering for some time now, however i didnt manage to solve the error. Thanks