Okay now it's starting to work
This commit is contained in:
parent
0a698f7194
commit
573ca90422
File diff suppressed because it is too large
Load Diff
@ -1,42 +1,37 @@
|
||||
local ____lualib = require("lualib_bundle")
|
||||
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
|
||||
local Map = ____lualib.Map
|
||||
utility = utility or ({})
|
||||
do
|
||||
local function concat(self, ...)
|
||||
local input = {...}
|
||||
local accumulator = ""
|
||||
__TS__ArrayForEach(
|
||||
input,
|
||||
function(____, val)
|
||||
accumulator = accumulator .. val
|
||||
end
|
||||
)
|
||||
return accumulator
|
||||
end
|
||||
local function generateSchematic(self, size, keys, forcePlace, data, ySliceProb)
|
||||
local newSchematic = {size = size, data = {}, yslice_prob = {}}
|
||||
local length = #data
|
||||
local countDown = length
|
||||
do
|
||||
local i = 1
|
||||
while i <= length do
|
||||
local databit = string.sub(data, countDown, countDown)
|
||||
table.insert(
|
||||
newSchematic.data,
|
||||
{
|
||||
name = keys:get(databit),
|
||||
forcePlace = forcePlace:get(databit)
|
||||
}
|
||||
)
|
||||
countDown = countDown - 1
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
for databit in pairs(ipairs(ySliceProb)) do
|
||||
table.insert(newSchematic.yslice_prob, {prob = databit})
|
||||
end
|
||||
local ____ = ItemStack
|
||||
return newSchematic
|
||||
-- Lua Library inline imports
|
||||
local function __TS__ArrayForEach(self, callbackFn, thisArg)
|
||||
for i = 1, #self do
|
||||
callbackFn(thisArg, self[i], i - 1, self)
|
||||
end
|
||||
end
|
||||
-- End of Lua Library inline imports
|
||||
function concat(...)
|
||||
local input = {...}
|
||||
local accumulator = ""
|
||||
__TS__ArrayForEach(
|
||||
input,
|
||||
function(____, val)
|
||||
accumulator = accumulator .. val
|
||||
end
|
||||
)
|
||||
return accumulator
|
||||
end
|
||||
function generateSchematic(size, keys, forcePlace, data, ySliceProb)
|
||||
local newSchematic = {size = size, data = {}, yslice_prob = {}}
|
||||
local length = #data
|
||||
local countDown = length
|
||||
do
|
||||
local i = 1
|
||||
while i <= length do
|
||||
local databit = string.sub(data, countDown, countDown)
|
||||
table.insert(newSchematic.data, {name = keys[databit], force_place = forcePlace[databit] == true})
|
||||
print(forcePlace[databit] == true)
|
||||
countDown = countDown - 1
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
for ____, databit in ipairs(ySliceProb) do
|
||||
table.insert(newSchematic.yslice_prob, {prob = databit})
|
||||
end
|
||||
return newSchematic
|
||||
end
|
||||
|
@ -1,4 +1,4 @@
|
||||
module utility {
|
||||
// module utility {
|
||||
function concat(...input: string[]): string {
|
||||
let accumulator = ""
|
||||
input.forEach((val: string) => {
|
||||
@ -7,7 +7,7 @@ module utility {
|
||||
return accumulator
|
||||
}
|
||||
|
||||
function generateSchematic(size: Vec3, keys: Map<string, string>, forcePlace: Map<string, boolean>, data: string, ySliceProb: number[]): SchematicDefinition {
|
||||
function generateSchematic(size: Vec3, keys: {[id: string] : string}, forcePlace: {[id: string] : boolean}, data: string, ySliceProb: number[]): SchematicDefinition {
|
||||
|
||||
let newSchematic = {
|
||||
size: size,
|
||||
@ -20,18 +20,17 @@ module utility {
|
||||
for (let i = 1; i <= length; i++ ) {
|
||||
const databit = string.sub(data, countDown, countDown)
|
||||
table.insert(newSchematic.data, {
|
||||
name: keys.get(databit),
|
||||
forcePlace: forcePlace.get(databit)
|
||||
name: keys[databit],
|
||||
force_place: forcePlace[databit] == true
|
||||
})
|
||||
print(forcePlace[databit] == true)
|
||||
countDown -= 1
|
||||
}
|
||||
|
||||
for (const databit in ipairs(ySliceProb)) {
|
||||
for (const databit of ySliceProb) {
|
||||
table.insert(newSchematic.yslice_prob, {prob: databit})
|
||||
}
|
||||
|
||||
ItemStack
|
||||
|
||||
return newSchematic
|
||||
}
|
||||
}
|
||||
// }
|
@ -39,7 +39,7 @@ do
|
||||
})
|
||||
end
|
||||
|
||||
local small_oak = generate_schematic(
|
||||
local small_oak = generateSchematic(
|
||||
vector.new(5, 5, 5),
|
||||
{
|
||||
[" "] = "air",
|
||||
@ -89,7 +89,7 @@ concat(
|
||||
})
|
||||
|
||||
|
||||
local medium_oak = generate_schematic(
|
||||
local medium_oak = generateSchematic(
|
||||
vector.new(7, 7, 7),
|
||||
{
|
||||
[" "] = "air",
|
||||
@ -167,7 +167,7 @@ concat(
|
||||
|
||||
|
||||
|
||||
local large_oak = generate_schematic(
|
||||
local large_oak = generateSchematic(
|
||||
vector.new(9, 9, 9),
|
||||
{
|
||||
[" "] = "air",
|
||||
|
@ -23,8 +23,9 @@
|
||||
"luaTarget": "JIT",
|
||||
"noHeader": true,
|
||||
|
||||
"noImplicitSelf": true,
|
||||
// "noImplicitGlobalVariables": false,
|
||||
// "sourceMapTraceback": true
|
||||
// "luaLibImport": "inline"
|
||||
"luaLibImport": "inline"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user