HiveCraft - Hub Map

in #pimpyesterday

The server is running. If you're having any bugs or things aren't working correctly, comment here.

I am working on trying to code in a centralized hub that has all the things that we're working on as well.

I may add in other games and such that are Hive-associated. I might add Splinterlands... we'll see.

main.lua


-- HubWorld main.lua

local g_Config =
{
WorldName = "world",
Radius = 256,
WarningCooldownSeconds = 3,
CenterX = nil,
CenterY = nil,
CenterZ = nil,
}

local g_LastWarn = {}

local function LoadConfig()
local ini = cIniFile()
local cfgPath = "Plugins/HubWorld/HubWorld.ini"
if (ini:ReadFile(cfgPath)) then
g_Config.WorldName = ini:GetValue("HubWorld", "WorldName", g_Config.WorldName)
g_Config.Radius = ini:GetValueI("HubWorld", "Radius", g_Config.Radius)
g_Config.WarningCooldownSeconds = ini:GetValueI("HubWorld", "WarningCooldownSeconds", g_Config.WarningCooldownSeconds)
local cx = ini:GetValueI("HubWorld", "CenterX", 0)
local cy = ini:GetValueI("HubWorld", "CenterY", 0)
local cz = ini:GetValueI("HubWorld", "CenterZ", 0)
if (cx ~= 0 or cy ~= 0 or cz ~= 0) then
g_Config.CenterX = cx
g_Config.CenterY = cy
g_Config.CenterZ = cz
end
return
end

ini:SetValue("HubWorld", "WorldName", g_Config.WorldName)
ini:SetValueI("HubWorld", "Radius", g_Config.Radius)
ini:SetValueI("HubWorld", "WarningCooldownSeconds", g_Config.WarningCooldownSeconds)
ini:WriteFile(cfgPath)
end

local function GetCenter(a_World)
if (g_Config.CenterX ~= nil) then
return g_Config.CenterX, g_Config.CenterY, g_Config.CenterZ
end
return a_World:GetSpawnX(), a_World:GetSpawnY(), a_World:GetSpawnZ()
end

local function SaveCenter(a_World, a_X, a_Y, a_Z)
g_Config.CenterX = math.floor(a_X + 0.5)
g_Config.CenterY = math.floor(a_Y + 0.5)
g_Config.CenterZ = math.floor(a_Z + 0.5)

local ini = cIniFile()
local cfgPath = "Plugins/HubWorld/HubWorld.ini"
if (ini:ReadFile(cfgPath)) then
ini:SetValueI("HubWorld", "CenterX", g_Config.CenterX)
ini:SetValueI("HubWorld", "CenterY", g_Config.CenterY)
ini:SetValueI("HubWorld", "CenterZ", g_Config.CenterZ)
ini:WriteFile(cfgPath)
end
end

local function IsOutside(a_World, a_Pos)
local cx, cy, cz = GetCenter(a_World)
local dx = a_Pos.x - cx
local dz = a_Pos.z - cz
return ((dx * dx + dz * dz) > (g_Config.Radius * g_Config.Radius))
end

local function BouncePlayer(a_Player)
local world = a_Player:GetWorld()
local cx, cy, cz = GetCenter(world)
a_Player:TeleportToCoords(cx, cy, cz)
end

function HandleHubSetCenter(a_Split, a_Player)
local pos = a_Player:GetPosition()
SaveCenter(a_Player:GetWorld(), pos.x, pos.y, pos.z)
a_Player:SendMessageSuccess("Hub center updated.")
return true
end

function HandleHubStatus(a_Split, a_Player)
local world = a_Player:GetWorld()
local cx, cy, cz = GetCenter(world)
a_Player:SendMessageInfo("HubWorld: center=" .. cx .. "," .. cy .. "," .. cz .. " radius=" .. g_Config.Radius)
return true
end

function OnPlayerMoving(a_Player)
local world = a_Player:GetWorld()
if (world:GetName() ~= g_Config.WorldName) then
return false
end

local pos = a_Player:GetPosition()
if (not IsOutside(world, pos)) then
return false
end

local uid = a_Player:GetUniqueID()
local now = os.time()
local last = g_LastWarn[uid] or 0
if ((now - last) >= g_Config.WarningCooldownSeconds) then
a_Player:SendMessageFailure("You reached the hub boundary.")
g_LastWarn[uid] = now
end

BouncePlayer(a_Player)
return true
end

function Initialize(Plugin)
Plugin:SetName("HubWorld")
Plugin:SetVersion(1)
LoadConfig()

cPluginManager:Get():AddHook(cPluginManager.HOOK_PLAYER_MOVING, OnPlayerMoving)

LOG("HubWorld loaded")
return true
end


🪙 PeakeCoin Ecosystem

💱 PeakeCoin USDT Bridge (Hive ↔ Polygon/MATIC)
Bridge SWAP.USDT from Hive Engine to USDT on Polygon (MATIC).
Whitelist access, documentation, and bridge status updates:
👉 https://geocities.ws/peakecoin


⚙️ HiveP.I.M.P. — PeakeCoin Intelligent Market Protector
Operated by @hivepimp, P.I.M.P. focuses on stabilizing PEK markets and strengthening liquidity on Hive Engine.
Community participation supports long-term ecosystem health.


🤖 PeakeBot — Autonomous Trading System
Independent multi-token trading bot with RC-awareness, adaptive delay logic, and smart cycle control.
📊 Trading bot documentation:
👉 https://geocities.ws/p/e/peakecoin/trading-bot/peakebot_v0_01.html
💻 Open-source repositories:
👉 https://github.com/paulmoon410


🎰 PeakeSino — The PeakeCoin Casino (Beta)
Blockchain-powered games using PEK as the native in-game currency.
Built on Hive with a focus on provable fairness and community-driven growth.
🃏 Play the beta games here:
👉 https://geocities.ws/peakecoin/pek_casino/beta_games/index.html


🙏 Acknowledgements

Thanks to and please follow:
@enginewitty @ecoinstant @neoxian @txracer @thecrazygm @holdonia @aggroed

For their continued support, guidance, and help expanding the PeakeCoin ecosystem.


Sort:  

Congratulations @strangedad! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)

You received more than 4750 upvotes.
Your next target is to reach 5000 upvotes.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Check out our last posts:

Our Hive Power Delegations to the February PUM Winners