This commit is contained in:
David Vogel 2019-10-20 16:32:48 +02:00
parent 99ad91e67c
commit f4db31f7e1
9 changed files with 6 additions and 183 deletions

View File

@ -1,4 +1,9 @@
UsePNGImageEncoder()
; Copyright (c) 2019 David Vogel
;
; This software is released under the MIT License.
; https://opensource.org/licenses/MIT
UsePNGImageEncoder()
Declare Worker(*Dummy)

View File

@ -1,81 +0,0 @@
// Copyright (c) 2019 David Vogel
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
package main
import (
"bufio"
"log"
"net"
"strconv"
"strings"
)
func startServer() {
log.Printf("Launching server...\n")
// listen on all interfaces
ln, err := net.Listen("tcp", ":46789")
if err != nil {
log.Fatalf("Couldn't open TCP server at port 46789: %v", err)
}
// accept connections
for {
conn, err := ln.Accept()
if err != nil {
log.Fatalf("Couldn't accept TCP connection: %v", err)
}
// Handle incoming data
go func(conn net.Conn) {
defer conn.Close()
var x, y int
for {
message, err := bufio.NewReader(conn).ReadString('\n')
if err != nil {
log.Printf("Couldn't read from connection: %v", err)
return
}
// Check for end condition
if message == "\n" {
break
}
colonPos := strings.IndexByte(message, ':') // Expect UTF-8
if colonPos < 0 {
log.Printf("Missing colon in message: %v", message)
return
}
key, value := message[:colonPos], message[colonPos+1:]
log.Printf("Bla %v blub %v", key, value)
switch key { // Expect UTF-8
case "x":
if res, err := strconv.ParseInt(value, 10, 0); err == nil {
x = int(res)
} else {
log.Printf("Can't parse string %v to integer: %v", value, err)
return
}
case "y":
if res, err := strconv.ParseInt(value, 10, 0); err == nil {
y = int(res)
} else {
log.Printf("Can't parse string %v to integer: %v", value, err)
return
}
}
}
conn.Write([]byte("\n"))
log.Printf("capture bla at %v, %v", x, y)
}(conn)
}
}

View File

@ -1,7 +0,0 @@
<Entity>
<InheritTransformComponent>
</InheritTransformComponent>
<GameEffectComponent >
</GameEffectComponent >
</Entity>

View File

@ -1,7 +0,0 @@
<Entity>
<InheritTransformComponent>
</InheritTransformComponent>
<GameEffectComponent >
</GameEffectComponent >
</Entity>

View File

@ -1,7 +0,0 @@
<Entity>
<InheritTransformComponent>
</InheritTransformComponent>
<GameEffectComponent >
</GameEffectComponent >
</Entity>

View File

@ -1,7 +0,0 @@
<Entity>
<InheritTransformComponent>
</InheritTransformComponent>
<GameEffectComponent >
</GameEffectComponent >
</Entity>

View File

@ -1,7 +0,0 @@
<Entity>
<InheritTransformComponent>
</InheritTransformComponent>
<GameEffectComponent >
</GameEffectComponent >
</Entity>

View File

@ -1,17 +0,0 @@
<Entity >
<FogOfWarRadiusComponent _enabled="0"
radius="200">
</FogOfWarRadiusComponent>
<SpriteComponent _enabled="0"
alpha="0.8"
image_file="data/particles/torch_fog_of_war_hole.xml"
smooth_filtering="1"
fog_of_war_hole="1"
has_special_scale="1"
special_scale_x="4"
special_scale_y="4">
</SpriteComponent>
</Entity>

View File

@ -3,17 +3,8 @@
-- This software is released under the MIT License.
-- https://opensource.org/licenses/MIT
--local host, port = "127.0.0.1", "46789"
--local socket = require("socket")
--local tcp = assert(socket.tcp())
--package.path = package.path .. ";" .. "mods/noita-mapcap/libs/lua/" .. "?.lua"
--package.cpath = package.cpath .. ";" .. "mods/noita-mapcap/libs/" .. "?.dll" -- TODO: Make it OS aware
local ffi = ffi or _G.ffi or require("ffi")
-- Don't let lua garbage collect and unload the lib, it will cause crashes later on!
-- Blah, this causes random crashes anyways. Probably the go runtime that interferes with something else in noita.
local status, caplib = pcall(ffi.load, "mods/noita-mapcap/bin/capture-b/capture")
if not status then
print("Error loading capture lib: " .. cap)
@ -23,45 +14,5 @@ ffi.cdef [[
]]
function TriggerCapture(x, y)
--IngamePrint(os.execute(string.format("mods/noita-mapcap/bin/capture/capture.exe -x %i -y %i", x, y)))
--IngamePrint("a", os.execute("capture.exe"))
--os.execute("screenshots")
--IngamePrint("b", os.execute("../bin/capture/capture.exe"))
--local handle = io.popen("mods/noita-mapcap/bin/capture/capture.exe")
--local result = handle:read("*a")
--IngamePrint(result)
--handle:close()
--IngamePrint(os.execute("echo test"))
--print("trace", "A")
caplib.Capture(x, y)
--print("trace", "B")
end
--[[function TriggerCapture(x, y)
local status, lib = pcall(require, "socket")
if not status then
IngamePrint("Error loading socket lib: " .. lib)
end
IngamePrint("DEBUG - Capture")
tcp:connect(host, port)
IngamePrint("DEBUG - Connected")
tcp:send(string.format("x: %i\n", x))
tcp:send(string.format("y: %i\n", y))
tcp:send(string.format("\n", y))
IngamePrint("DEBUG - Sent")
local result, error = tcp:receive("*l")
-- Ignore error or result for now, the function blocks until a newline character is received.
IngamePrint("DEBUG - Received")
tcp:close()
IngamePrint("DEBUG - Closed")
end]]