1
0
mirror of https://github.com/natnat-mc/moonbuild synced 2026-05-22 08:31:14 +02:00

added table syntax for var, closes #19

This commit is contained in:
Codinget
2020-12-01 22:05:04 +01:00
parent ec5fc1cf7d
commit 803d1093bb
4 changed files with 41 additions and 15 deletions
+11 -1
View File
@@ -4,7 +4,17 @@ class Variable
new: (@name, ...) =>
@public = false
if (select '#', ...) !=1 or (type ...) == 'table'
if (type @name) == 'table'
error "not a valid var table: #{next @name}" unless (type next @name) == 'string'
error "more than one var at once: #{next @name}, #{next @name, (next @name)}" if next @name, (next @name)
name = next @name
@name, param = name, @name
val = param[name]
if (select '#', ...) !=0 or (type val) == 'table'
@value = flatten val, ...
else
@value = val
elseif (select '#', ...) !=1 or (type ...) == 'table'
@value = flatten ...
else
@value = ...
+1 -1
View File
@@ -21,7 +21,7 @@ import flatten from _
rawset env, 'var', (name, ...) ->
var = Variable name, ...
ctx\addvar var
rawset varlayer, name, var.value
rawset varlayer, var.name, var.value
var
rawset env, 'target', (name, opts) ->