Okay now it's starting to work

This commit is contained in:
jordan4ibanez 2023-11-13 04:22:07 -05:00
parent 0a698f7194
commit 573ca90422
5 changed files with 47 additions and 2677 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,11 @@
local ____lualib = require("lualib_bundle") -- Lua Library inline imports
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach local function __TS__ArrayForEach(self, callbackFn, thisArg)
local Map = ____lualib.Map for i = 1, #self do
utility = utility or ({}) callbackFn(thisArg, self[i], i - 1, self)
do end
local function concat(self, ...) end
-- End of Lua Library inline imports
function concat(...)
local input = {...} local input = {...}
local accumulator = "" local accumulator = ""
__TS__ArrayForEach( __TS__ArrayForEach(
@ -14,7 +16,7 @@ do
) )
return accumulator return accumulator
end end
local function generateSchematic(self, size, keys, forcePlace, data, ySliceProb) function generateSchematic(size, keys, forcePlace, data, ySliceProb)
local newSchematic = {size = size, data = {}, yslice_prob = {}} local newSchematic = {size = size, data = {}, yslice_prob = {}}
local length = #data local length = #data
local countDown = length local countDown = length
@ -22,21 +24,14 @@ do
local i = 1 local i = 1
while i <= length do while i <= length do
local databit = string.sub(data, countDown, countDown) local databit = string.sub(data, countDown, countDown)
table.insert( table.insert(newSchematic.data, {name = keys[databit], force_place = forcePlace[databit] == true})
newSchematic.data, print(forcePlace[databit] == true)
{
name = keys:get(databit),
forcePlace = forcePlace:get(databit)
}
)
countDown = countDown - 1 countDown = countDown - 1
i = i + 1 i = i + 1
end end
end end
for databit in pairs(ipairs(ySliceProb)) do for ____, databit in ipairs(ySliceProb) do
table.insert(newSchematic.yslice_prob, {prob = databit}) table.insert(newSchematic.yslice_prob, {prob = databit})
end end
local ____ = ItemStack
return newSchematic return newSchematic
end end
end

View File

@ -1,4 +1,4 @@
module utility { // module utility {
function concat(...input: string[]): string { function concat(...input: string[]): string {
let accumulator = "" let accumulator = ""
input.forEach((val: string) => { input.forEach((val: string) => {
@ -7,7 +7,7 @@ module utility {
return accumulator 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 = { let newSchematic = {
size: size, size: size,
@ -20,18 +20,17 @@ module utility {
for (let i = 1; i <= length; i++ ) { for (let i = 1; i <= length; i++ ) {
const databit = string.sub(data, countDown, countDown) const databit = string.sub(data, countDown, countDown)
table.insert(newSchematic.data, { table.insert(newSchematic.data, {
name: keys.get(databit), name: keys[databit],
forcePlace: forcePlace.get(databit) force_place: forcePlace[databit] == true
}) })
print(forcePlace[databit] == true)
countDown -= 1 countDown -= 1
} }
for (const databit in ipairs(ySliceProb)) { for (const databit of ySliceProb) {
table.insert(newSchematic.yslice_prob, {prob: databit}) table.insert(newSchematic.yslice_prob, {prob: databit})
} }
ItemStack
return newSchematic return newSchematic
} }
} // }

View File

@ -39,7 +39,7 @@ do
}) })
end end
local small_oak = generate_schematic( local small_oak = generateSchematic(
vector.new(5, 5, 5), vector.new(5, 5, 5),
{ {
[" "] = "air", [" "] = "air",
@ -89,7 +89,7 @@ concat(
}) })
local medium_oak = generate_schematic( local medium_oak = generateSchematic(
vector.new(7, 7, 7), vector.new(7, 7, 7),
{ {
[" "] = "air", [" "] = "air",
@ -167,7 +167,7 @@ concat(
local large_oak = generate_schematic( local large_oak = generateSchematic(
vector.new(9, 9, 9), vector.new(9, 9, 9),
{ {
[" "] = "air", [" "] = "air",

View File

@ -23,8 +23,9 @@
"luaTarget": "JIT", "luaTarget": "JIT",
"noHeader": true, "noHeader": true,
"noImplicitSelf": true,
// "noImplicitGlobalVariables": false, // "noImplicitGlobalVariables": false,
// "sourceMapTraceback": true // "sourceMapTraceback": true
// "luaLibImport": "inline" "luaLibImport": "inline"
} }
} }