mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
karl
This commit is contained in:
parent
fefaf0ed79
commit
cd3997b83b
2 changed files with 56 additions and 0 deletions
55
quant.ew/files/system/karl/karl.lua
Normal file
55
quant.ew/files/system/karl/karl.lua
Normal file
|
@ -0,0 +1,55 @@
|
|||
local rpc = net.new_rpc_namespace()
|
||||
|
||||
local karl = {}
|
||||
|
||||
local my_karl
|
||||
|
||||
function rpc.send_karl(x, y, vx, vy, t, jet)
|
||||
local players_karl
|
||||
for _, entity in ipairs(EntityGetWithTag("racing_cart")) do
|
||||
local com = EntityGetFirstComponentIncludingDisabled(entity, "VariableStorageComponent", "ew_karl")
|
||||
if ComponentGetValue2(com, "value_string") == ctx.rpc_peer_id then
|
||||
players_karl = entity
|
||||
break
|
||||
end
|
||||
end
|
||||
if players_karl == nil then
|
||||
players_karl = EntityLoad("data/entities/buildings/racing_cart.xml", x, y)
|
||||
EntitySetTransform(players_karl, x, y, t)
|
||||
EntityAddComponent2(players_karl, "VariableStorageComponent", {_tags = "ew_karl", value_string = ctx.rpc_peer_id})
|
||||
for _, com in ipairs(EntityGetComponent(players_karl, "LuaComponent")) do
|
||||
if ComponentGetValue2(com, "script_source_file") == "data/scripts/buildings/racing_cart_move.lua" then
|
||||
EntityRemoveComponent(players_karl, com)
|
||||
break
|
||||
end
|
||||
end
|
||||
else
|
||||
EntitySetTransform(players_karl, x, y, t)
|
||||
end
|
||||
EntitySetComponentsWithTagEnabled(players_karl, "jetpack", jet)
|
||||
local vel = EntityGetFirstComponentIncludingDisabled(players_karl, "VelocityComponent")
|
||||
ComponentSetValue2(vel, "mVelocity", vx, vy)
|
||||
end
|
||||
|
||||
function karl.on_world_update()
|
||||
if my_karl == nil or not EntityGetIsAlive(my_karl) then
|
||||
my_karl = nil
|
||||
if GameGetFrameNum() % 30 == 0 then
|
||||
for _, entity in ipairs(EntityGetWithTag("racing_cart")) do
|
||||
local com = EntityGetFirstComponentIncludingDisabled(entity, "VariableStorageComponent", "ew_karl")
|
||||
if com == nil then
|
||||
my_karl = entity
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
local x, y, t = EntityGetTransform(my_karl)
|
||||
local vel = EntityGetFirstComponentIncludingDisabled(my_karl, "VelocityComponent")
|
||||
local vx, vy = ComponentGetValue2(vel, "mVelocity")
|
||||
local jet = ComponentGetIsEnabled(EntityGetFirstComponentIncludingDisabled(my_karl, "SpriteParticleEmitterComponent"))
|
||||
rpc.send_karl(x, y, vx, vy, t, jet)
|
||||
end
|
||||
end
|
||||
|
||||
return karl
|
|
@ -99,6 +99,7 @@ local function load_modules()
|
|||
ctx.load_system("spectate")
|
||||
ctx.load_system("effect_data_sync")
|
||||
ctx.load_system("gen_sync")
|
||||
ctx.load_system("karl")
|
||||
if ctx.proxy_opt.randomize_perks then
|
||||
ctx.load_system("randomize_perks")
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue