Compare commits
5 Commits
3b6daff211
...
6662298d76
Author | SHA1 | Date |
---|---|---|
ademant | 6662298d76 | |
ademant | d8186e150d | |
ademant | b0507dd1fa | |
A. Demant | bd0ed40a31 | |
A. Demant | c6779d050d |
21
README.md
21
README.md
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue