Change most of the Lua files into Venus files.

master
Nicole Collings 2020-02-09 22:58:10 -08:00
parent 2338d5b96c
commit 17380d83fa
27 changed files with 171 additions and 195 deletions

View File

@ -7,6 +7,7 @@
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wconversion"
#pragma ide diagnostic ignored "OCUnusedMacroInspection"
#define STB_IMAGE_IMPLEMENTATION
#define CUTE_FILES_IMPLEMENTATION
#define STB_IMAGE_WRITE_IMPLEMENTATION
@ -16,29 +17,4 @@
int main(int argc, char* argv[]) {
return StartGame(argc, argv);
// Voronoi3D v(256);
// v.setColorValues({{0, 0, 1}, {1, 0, 0.5}, {1, 0, 0}, {0.5, 0.5, 0}, {0, 0.5, 0.5}, {0.5, 0, 0.5}, {1, 0.5, 0}, {0.7, 0.3, 1}});
// v.setPoints({{30, 20, 1}, {100, 40, 30}, {50, 200, 10}, {73, 48, 60}, {212, 128, 128}, {192, 5, 255}, {50, 230, 160}, {230, 200, 192}});
//
// int i = 0;
// v.generateImage(0 + i);
// v.generateImage(15 + i);
// v.generateImage(31 + i);
// v.generateImage(47 + i);
// v.generateImage(63 + i);
// v.generateImage(79 + i);
// v.generateImage(95 + i);
// v.generateImage(111 + i);
// v.generateImage(127 + i);
// i = 128;
// v.generateImage(15 + i);
// v.generateImage(31 + i);
// v.generateImage(47 + i);
// v.generateImage(63 + i);
// v.generateImage(79 + i);
// v.generateImage(95 + i);
// v.generateImage(111 + i);
// v.generateImage(127 + i);
}
}

View File

@ -23,7 +23,7 @@ Server::Server(const std::string& path, unsigned short port, const std::string&
}
void Server::update() {
const static long interval_ns = (long)((1000 / 20.f) * 1000000L);
const static long interval_ns = static_cast<long>((1000 / 20.f) * 1000000L);
Timer loop("");
world.update(0);
@ -76,7 +76,6 @@ void Server::update() {
}
void Server::handlePlayerPacket(ServerClient &client, Packet& p) {
//Client *does* have a player, this is ensured in processConnecting().
ServerPlayer& player = client.getPlayer();
switch (p.type) {

View File

@ -2,59 +2,59 @@ _G["crafting"] = {}
crafting.registered_recipes = {}
crafting.register_recipe = function(tbl)
crafting.register_recipe = fn(tbl) {
table.insert(crafting.registered_recipes, tbl)
end
}
crafting.bind = function(craft_input, craft_output)
crafting.bind = fn(craft_input, craft_output) {
local width = craft_input.width
local length = craft_input.length
local crafting_changed = function()
local crafting_changed = fn() {
local items = {}
local matched_any = false
for _,r in pairs(crafting.registered_recipes) do
foreach r in crafting.registered_recipes {
local matches = true
for i = 1, length do
for i = 1, length {
local x = (i - 1) % width + 1
local y = math.floor((i - 1) / width) + 1
local recipe_item_name = ""
if y <= #(r.recipe) and x <= #(r.recipe[y]) then
if (y <= #(r.recipe) and x <= #(r.recipe[y])) {
recipe_item_name = r.recipe[y][x]
end
}
if recipe_item_name ~= craft_input:get_stack(i).name then
if (recipe_item_name ~= craft_input:get_stack(i).name) {
matches = false
break
end
end
}
}
if matches then
if (matches) {
craft_output:set_stack(1, {r.output, 1})
matched_any = true
break
end
end
}
}
if not matched_any then
if (not matched_any) {
craft_output:set_stack(1, {"invalid", 0})
end
end
}
}
craft_input.on_put = crafting_changed
craft_input.on_take = crafting_changed
craft_output.allow_put = function()
craft_output.allow_put = fn() {
return 0
end
}
craft_output.on_take = function()
for i = 1, length do
craft_output.on_take = fn() {
for i = 1, length {
craft_input:remove_stack(i, 1)
end
}
crafting_changed()
end
end
}
}

View File

@ -12,17 +12,17 @@ zepha.register_block("@aurailus:tnt:tnt", {
pick = 2
},
drop = "@aurailus:tnt:tnt",
on_break = function(pos)
on_break = fn(pos) {
local amp = 20
for i = -amp, amp do
for j = -amp, amp do
for k = -amp, amp do
local offset = v{i, j, k}
if vector.distance(v{}, offset) < amp then
for i = -amp, amp {
for j = -amp, amp {
for k = -amp, amp {
local offset = v(i, j, k)
if (vector.distance(v(), offset) < amp) {
zepha.set_block(vector.add(pos, offset), "air")
end
end
end
end
end
}
}
}
}
}
})

View File

@ -1,3 +0,0 @@
runfile(_PATH .. "plains")
runfile(_PATH .. "rocklands")
runfile(_PATH .. "desert")

View File

@ -1,40 +0,0 @@
-- local noise = {
-- module = "add",
-- sources = {
-- { -- Elevation
-- module = "scale_bias",
-- source = {
-- module = "perlin",
-- frequency = 0.02,
-- octaves = 8
-- },
-- scale = 250,
-- bias = 32
-- },
-- { -- Features
-- module = "scale_bias",
-- source = {
-- module = "perlin",
-- frequency = 0.8,
-- octaves = 3,
-- },
-- scale = 30,
-- bias = 6
-- }
-- }
-- }
--
-- zepha.register_biome("zeus:default:desert", {
-- environment = {
-- temperature = 40/100,
-- humidity = 20/100,
-- roughness = 10/100
-- },
-- blocks = {
-- top = "zeus:default:sand",
-- soil = "zeus:default:sand",
-- rock = "zeus:default:sandstone"
-- },
-- biome_tint = "#e6fa61",
-- noise = noise
-- })

View File

@ -2,7 +2,6 @@ print("Hello from default")
runfile(_PATH .. "blocks/_index")
runfile(_PATH .. "entity/_index")
runfile(_PATH .. "biomes/_index")
local blockTypes = {
"@aurailus:tnt:tnt",
@ -19,17 +18,19 @@ local blockTypes = {
"zeus:default:tallgrass_5"
}
for i, v in ipairs(blockTypes) do
local i = 0;
foreach block in blockTypes {
zepha.register_keybind("zeus:default:block_" .. i, {
description = "Select Block " .. i,
default = zepha.keys[tostring(i)],
on_press = function() zepha.player:set_selected_block(v) end
on_press = () => { zepha.player:set_selected_block(block) }
});
end
i++;
}
local chat_down = false
zepha.register_keybind("zeus:default:open_chat", {
description = "Open Chat",
default = zepha.keys.t,
on_press = function() print "Opened chat!" end
on_press = () => { print "Opened chat!" }
})

View File

@ -9,11 +9,9 @@ local flowers = {
"yellow_dandelion"
}
local function tchelper(first, rest)
return first:upper()..rest:lower()
end
local tchelper = (first, rest) => { return first:upper()..rest:lower() }
for _,flower in ipairs(flowers) do
foreach flower in flowers {
local name = flower:gsub("_", " "):gsub("(%a)([%w_']*)", tchelper)
zepha.register_block("zeus:flowers:flower_" .. flower, {
@ -32,4 +30,4 @@ for _,flower in ipairs(flowers) do
hand = 0
}
})
end
}

View File

@ -1,6 +1,6 @@
print("Hello from inventory")
if zepha.server then return end -- Only run the following code on the client.
if (zepha.server) { return } ## Only run the following code on the client.
local inventory = zepha.player:get_inventory()
@ -10,46 +10,40 @@ local main = inventory:add_list("main", 44, 11)
zepha.register_keybind("zeus:inventory:add_shit_b", {
description = "Add testing items to inventory",
default = zepha.keys.b,
on_press = function()
shit_adding = 1
end,
on_release = function()
shit_adding = 0
end
on_press = () => { shit_adding = 1 },
on_release = () => { shit_adding = 0 }
})
zepha.register_keybind("zeus:inventory:add_shit_i", {
description = "Add testing items to inventory",
default = zepha.keys.n,
on_press = function()
shit_adding = 2
end,
on_release = function()
shit_adding = 0
end
on_press = () => { shit_adding = 2 },
on_release = () => { shit_adding = 0 }
})
zepha.delay(function()
if shit_adding == 1 then
zepha.delay(() => {
if (shit_adding == 1) {
main:add_stack({"zeus:default:cobblestone", 1})
main:add_stack({"zeus:default:tallgrass_5", 1})
main:add_stack({"zeus:default:leaves", 1})
main:add_stack({"zeus:kinetic:axle_0", 1})
main:add_stack({"zeus:default:wood", 1})
elseif shit_adding == 2 then
}
if (shit_adding == 2) {
main:add_stack({"zeus:materials:plant_fibre", 1})
main:add_stack({"zeus:materials:plant_twine", 1})
main:add_stack({"zeus:materials:stick", 1})
main:add_stack({"zeus:materials:flint", 1})
end
}
return true
end, 0)
}, 0)
zepha.register_keybind("zeus:inventory:open_inventory", {
description = "Open Inventory",
default = zepha.keys.e,
on_press = function()
if zepha.player.menu_state == "" then
on_press = () => {
if (zepha.player.menu_state == "") {
zepha.player:open_menu([[
body[body]
background: #0003
@ -140,26 +134,29 @@ zepha.register_keybind("zeus:inventory:open_inventory", {
end
]], {
body = {
left = function()
left = fn() {
zepha.player:close_menu()
end
}
},
inv_background = {
left = function() --[[ Prevent close menu from triggering. ]] end
left = fn() {} ## Prevent close menu from triggering.
}
})
else zepha.player:close_menu() end
end
}
else {
zepha.player:close_menu()
}
}
})
-- Bind crafting
## Bind crafting
local craft_input = inventory:add_list("craft", 4, 2)
local craft_output = inventory:add_list("craft_result", 2, 2)
crafting.bind(craft_input, craft_output)
-- Make hotwheel
## Make hotwheel
local invs = {
inventory:add_list("hot_wheel_1", 5, 5),
@ -170,13 +167,16 @@ local invs = {
inventory:add_list("hot_wheel_6", 5, 5)
}
for i, inv in pairs(invs) do
inv.allow_take = function() return 0 end
inv.allow_put = function(slot, item)
zepha.delay(function()
-- This delay is necessary to avoid the engine overwriting it with nothing
inv:set_stack(slot, item)
end, 0)
foreach inv in invs {
inv.allow_take = fn() {
return 0
end
end
}
inv.allow_put = fn(slot, item) {
zepha.delay(() => {
## This delay is necessary to avoid the engine overwriting it with nothing
inv:set_stack(slot, item)
}, 0)
return 0
}
}

View File

@ -10,27 +10,27 @@ zepha.register_block('zeus:kinetic:axle_0', {
{0, 6/16, 6/16, 1, 10/16, 10/16}
},
drop = "zeus:kinetic:axle_0",
on_place = function(pos)
for i = 0, 9 do
on_place = fn(pos) {
for i = 0, 9 {
pos.x = pos.x + 1
zepha.set_block(pos, "zeus:kinetic:axle_0")
end
end,
on_place_client = function(pos)
for i = 0, 9 do
}
},
on_place_client = fn(pos) {
for i = 0, 9 {
pos.x = pos.x + 1
zepha.set_block(pos, "zeus:kinetic:axle_0")
end
end,
on_construct = function(pos)
zepha.delay(function()
}
},
on_construct = fn(pos) {
zepha.delay(() => {
zepha.set_block(pos, "zeus:kinetic:axle_1")
end, 4)
end,
on_break_client = function(pos)
}, 4)
},
on_break_client = fn(pos) {
zepha.add_entity("zeus:default:dropped_item", {x = pos.x + 0.5, y = pos.y + 0.5, z = pos.z + 0.5},
{item = zepha.registered_blocks["zeus:kinetic:axle_0"].drop});
end
}
})
zepha.register_block('zeus:kinetic:axle_1', {
@ -44,11 +44,11 @@ zepha.register_block('zeus:kinetic:axle_1', {
collision_box = {
{0, 6/16, 6/16, 1, 10/16, 10/16}
},
on_construct = function(pos)
zepha.delay(function()
on_construct = fn(pos) {
zepha.delay(() => {
zepha.set_block(pos, "zeus:kinetic:axle_2")
end, 4)
end
}, 4)
}
})
zepha.register_block('zeus:kinetic:axle_2', {
@ -62,11 +62,11 @@ zepha.register_block('zeus:kinetic:axle_2', {
collision_box = {
{0, 6/16, 6/16, 1, 10/16, 10/16}
},
on_construct = function(pos)
zepha.delay(function()
on_construct = fn(pos) {
zepha.delay(() => {
zepha.set_block(pos, "zeus:kinetic:axle_3")
end, 4)
end
}, 4)
}
})
zepha.register_block('zeus:kinetic:axle_3', {
@ -80,9 +80,9 @@ zepha.register_block('zeus:kinetic:axle_3', {
collision_box = {
{0, 6/16, 6/16, 1, 10/16, 10/16}
},
on_construct = function(pos)
zepha.delay(function()
on_construct = fn(pos) {
zepha.delay(() => {
zepha.set_block(pos, "zeus:kinetic:axle_0")
end, 4)
end
}, 4)
}
})

View File

@ -1,11 +1,11 @@
local function create_model_def(speed)
fn create_model_def(speed) {
local mod = ""
if speed > 0 then mod = "rotate_x" end
if (speed > 0) { mod = "rotate_x" }
return {
parts = {
{
face = "left", -- Small part 1
face = "left", ## Small part 1
tex = 3,
points = {
0, 7/16, 7/16, 0, 2/10,
@ -18,7 +18,7 @@ local function create_model_def(speed)
speed = speed
}
}, {
face = "right", -- Small part 2
face = "right", ## Small part 2
tex = 4,
points = {
1, 9/16, 9/16, 2/16, 2/10,
@ -31,7 +31,7 @@ local function create_model_def(speed)
speed = speed
}
}, {
face = "nocull", -- Top
face = "nocull", ## Top
tex = 1,
points = {
0, 9/16, 7/16, 0, 2/10,
@ -44,7 +44,7 @@ local function create_model_def(speed)
speed = speed
}
}, {
face = "nocull", -- Bottom
face = "nocull", ## Bottom
tex = 2,
points = {
0, 7/16, 7/16, 0, 6/10,
@ -57,7 +57,7 @@ local function create_model_def(speed)
speed = speed
}
}, {
face = "nocull", -- Front
face = "nocull", ## Front
tex = 5,
points = {
0, 7/16, 9/16, 0, 8/10,
@ -70,7 +70,7 @@ local function create_model_def(speed)
speed = speed
}
}, {
face = "nocull", -- Back
face = "nocull", ## Back
tex = 6,
points = {
0, 7/16, 7/16, 0, 4/10,
@ -85,7 +85,7 @@ local function create_model_def(speed)
}
}
}
end
}
zepha.register_blockmodel("zeus:kinetic:axle_0", create_model_def(0));
zepha.register_blockmodel("zeus:kinetic:axle_1", create_model_def(0.5));

View File

@ -0,0 +1,3 @@
runfile(_PATH .. "plains")
runfile(_PATH .. "highlands")
runfile(_PATH .. "desert")

View File

@ -0,0 +1,40 @@
local noise = {
module = "add",
sources = {
{ ## Elevation
module = "scale_bias",
source = {
module = "perlin",
frequency = 0.02,
octaves = 8
},
scale = 250,
bias = 32
},
{ ## Features
module = "scale_bias",
source = {
module = "perlin",
frequency = 0.8,
octaves = 3,
},
scale = 30,
bias = 6
}
}
}
zepha.register_biome("zeus:mapgen:desert", {
environment = {
temperature = 40/100,
humidity = 20/100,
roughness = 10/100
},
blocks = {
top = "zeus:default:sand",
soil = "zeus:default:sand",
rock = "zeus:default:sandstone"
},
biome_tint = "#e6fa61",
noise = noise
})

View File

@ -4,7 +4,7 @@ local noise = {
{
module = "add",
sources = {
{ -- Voronoi
{ ## Voronoi
module = "scale_bias",
source = {
module = "voronoi",
@ -14,7 +14,7 @@ local noise = {
scale = 8,
bias = -32
},
{ -- Features
{ ## Features
module = "scale_bias",
source = {
module = "perlin",
@ -25,7 +25,7 @@ local noise = {
}
}
},
{ -- Variation
{ ## Variation
module = "scale_bias",
source = {
module = "perlin",
@ -37,7 +37,7 @@ local noise = {
}
}
zepha.register_biome("zeus:default:rocklands", {
zepha.register_biome("zeus:mapgen:highlands", {
environment = {
temperature = 0/100,
humidity = 0/100,

View File

@ -1,7 +1,7 @@
local noise = {
module = "add",
sources = {
{ -- Elevation
{ ## Elevation
module = "scale_bias",
source = {
module = "perlin",
@ -11,7 +11,7 @@ local noise = {
scale = 250,
bias = -32
},
{ -- Features
{ ## Features
module = "scale_bias",
source = {
module = "perlin",
@ -24,7 +24,7 @@ local noise = {
}
}
zepha.register_biome("zeus:default:plains", {
zepha.register_biome("zeus:mapgen:plains", {
environment = {
temperature = 15/100,
humidity = 80/100,

View File

@ -1 +0,0 @@
print("Hello from mapgen")

View File

@ -0,0 +1,3 @@
print("Hello from mapgen")
runfile(_PATH .. "biomes/_index")