Compare commits

...

5 Commits

Author SHA1 Message Date
ademant 6662298d76 small changes needed by api update 2020-06-19 16:41:48 +02:00
ademant d8186e150d add reading single file into one string (used for importing json) 2019-07-15 12:16:05 +02:00
ademant b0507dd1fa documentation 2019-02-13 14:32:50 +01:00
A. Demant bd0ed40a31 Add link to repository 2019-02-13 04:53:55 +01:00
A. Demant c6779d050d update README 2019-02-13 04:33:17 +01:00
2 changed files with 31 additions and 3 deletions

View File

@ -1,12 +1,27 @@
Basic functions
short api:
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
# Minetest mod: Basic functions
Main repository:
https://notabug.org/ademant/basic_functions.git
Mirrors:
https://gitlab.com/ademant/basic_functions.git
https://github.com/ademant/basic_functions.git
## Short description
Mod provide some functions, I need for several mods. Basically for import spreadsheet configurations.
## short api:
function has_value(tab,val)
check if val is inside list tab
function import_csv(infile,def)
read configuration from infile
def.as_numeric: all values not stated in col_num, col_tab or with name "name" are interpreted as numeric
def.seperator: character to use as field delimiter
def.seperator: character to use as field delimiter in infile
def.col_num: turn this elements to numbers
def.groups_num: put this elements as numbers into matrix groups

View File

@ -12,6 +12,7 @@ end
local has_value=basic_functions.has_value
-- read table "infile" where in "def" is defined, which cols are numbers and which belongs to a group
-- First line has to be the header.
-- def.as_numeric: all values not stated in col_num, col_tab or with name "name" are interpreted as numeric
-- def.seperator: character to use as field delimiter
-- def.col_num: turn this elements to numbers
@ -126,3 +127,15 @@ basic_functions.import_settingtype = function(infile)
end
end
end
basic_functions.read_file=function(filename)
local file=io.open(filename,"r")
local out=""
if file then
for line in file:lines() do
out=out..line
end
file:close()
end
return(out)
end