Using python to interface with Civ 5 using the Firetuner port

Battary

Chieftain
Joined
Feb 3, 2025
Messages
2
Like the title says I'm trying to call a simple function using a python script over a websocket connection with the fire tuner port.

Lua code:
Code:
function GiveGold()
    Players[Game.GetActivePlayer()]:SetGold(500);
end

LuaEvents.GiveGold.Add(GiveGold)

Python code:
Python:
import socket

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(('127.0.0.1', 4318))
cont = True

command_string = "Events.GiveGold();"
b_command_string = command_string.encode('utf-8')

command_prefix = b"CMD:0:"
delimmiter = b"\x00"
full_command = b_command_string
message = command_prefix + full_command + delimmiter
message_length = len(message).to_bytes(1,byteorder='little')

message_header = message_length + b"\x00\x00\x00\x03\x00\x00\x00"
data = message_header + command_prefix + full_command + delimmiter

print(data)

sock.listen(1)

while (cont == True):
    client, addr = sock.accept()
    client.send(data)
    response = client.recv(2048)
    print(response)
    val = input("Next? Type y to continue")
    if val == 'y':
        continue
    else:
        break

FireTuner:
FireTuner.png

I can see the string I sent in the console but nothing is happening in game. To be clear I don't know how the fire tuner work on the inside I'm just going off of a civ 6 modders solution.
 
Back
Top Bottom