What happened to OC? - CLOSED Carnage?!
Enclusion

External UI (Proof of Concept)

12 posts in this topic

I asked Kavawuvi a while back about adding an external UI feature to chimera that would render the UI on a separate layer so when recording the game you could have a less cluttered screen (would be good for clips). Would make recordings look a lot crisper. I decided instead of trying to get this feature added natively to chimera I'd just make it myself/do a proof of concept. THIS IS NOT A FINAL SCRIPT WHICH IS WHY I PUT IT IN THIS FORUM SECTION. I plan on improving this over time and hopefully eventually making the external elements indistinguishable from the standard game elements. If you have suggestions, questions, etc throw it below.

 

clua_version = 2.042


-- local maxHealth = read_float(player + 0xD8)
-- local health = read_float(player + 0xE0) -- (0 to 1)
-- local maxShields = read_float(player + 0xDC)
-- local shields = read_float(player + 0xE4) -- (0 to 3) (Normal = 1) (Full Overshield = 3)

-- local primary_ammo = read_word(player + 0x2B6) -- Confirmed. Unloaded ammo for magazine 1.
-- local primary_clip = read_word(player + 0x2B8) -- Confirmed. Loaded clip for magazine 1.
-- local secondary_ammo = read_word(player + 0x2C6) -- Confirmed. Unloaded ammo for magazine 1.
-- local secondary_clip = read_word(player + 0x2C8) -- Confirmed. Loaded clip for magazine 1.



set_callback("tick", "OnTick")

function OnTick()
	local player = get_dynamic_player()
	local health = read_float(player + 0xE0) -- (0 to 1)
	local shields = read_float(player + 0xE4) -- (0 to 3) (Normal = 1) (Full Overshield = 3)
	if player ~= nil then
		local file = io.open( "/home/user/Games/HaloCE/Profiles/chimera/lua/scripts/global/health.txt", "w" )
		file:write( health )
		file:close()

		local file = io.open( "/home/user/Games/HaloCE/Profiles/chimera/lua/scripts/global/shield.txt", "w" )
		file:write( shields )
		file:close()
	end
end

Since this is a proof of concept (and because i couldn't get luasocket working with chimera) the method of passing information to the external ui is inefficient. It writes health and shielf info to a file every tick. The external hud is just written in python since I knew I could cobble it together quickly.

import tkinter as tk
from tkinter import *
from functools import partial


app = tk.Tk()

bg = PhotoImage(file = "empty_bar.png")

main = tk.Label(app, image = bg)
main.place(x=0, y=0)

hp = tk.Label(app, text = "Test", font=("Arial", 10))
hp.place(x=90, y=10)

sv = tk.Label(app, text = "Test", font=("Arial", 10))
sv.place(x=120, y=10)

def task():
    health = open("health.txt", "r")
    shield = open("shield.txt", "r")
    hpn = health.read()
    svn = shield.read()
    if svn != "":
        svn = float(svn)*100

    sv.config(text=svn)

    #if float(svn) == 1:
    #    sv.config(text=svn)


    if hpn == "":
        hp.config(text="Error")
    elif float(hpn) == 1:
        hp.config(text="8/8")
    elif float(hpn) >= 0.875:
        hp.config(text="7/8")
    elif float(hpn) >= 0.750:
        hp.config(text="6/8")
    elif float(hpn) >= 0.625:
        hp.config(text="5/8")
    elif float(hpn) >= 0.500:
        hp.config(text="4/8")
    elif float(hpn) >= 0.375:
        hp.config(text="3/8")
    elif float(hpn) >= 0.250:
        hp.config(text="2/8")
    elif float(hpn) >= 0.125:
        hp.config(text="1/8")
    else:
        hp.config(text="Error")

    #if float(hpn) >= 0.125:
    #    hp.config(text="")

    app.after(100, task)

app.after(100, task)
app.mainloop()

#print(f.read())

My plan is to get each HUD element working well externally, make them look good, and then finally try to make the method of passing data more efficient. I think I can do the first two well but getting sockets to work so I can pass information to the external UI is going to be the trickiest part because I don't know how to do some of that in lua and I've been unsuccessful at loading the luasocket library. If you have any ideas drop them below.

Edited by Enclusion
changed "not final script" disclaimer
Kavawuvi and Takka like this

Share this post


Link to post
Share on other sites

Tiddy-bits:

4 minutes ago, Tucker933 said:

Posted in SAPP by mistake?

Yeah, but also I can't submit in Chimera: General. No submit topic button.

Edited by Enclusion

Share this post


Link to post
Share on other sites
3 minutes ago, Enclusion said:

Yeah, but also I can't submit in Chimera: General.

Yeah, @Kavawuvi wanted General to just be for news. This topic could be considered a release though because you've provided the script, even if it's early days, so I could move it there. The other alternative is I can move this to CE Development for ya.

Enclusion likes this

Oddly, this is familiar to you... as if from an old dream.  

Share this post


Link to post
Share on other sites
Just now, Tucker933 said:

Yeah, @Kavawuvi wanted General to just be for news. This topic could be considered a release though, even if it's early days, so I could move it there. The other alternative is I can move this to CE Development for ya.

Move it to CE Development, please. I wouldn't consider this a release, just showing people what I am working on and asking for any input they can provide.

Share this post


Link to post
Share on other sites
2 minutes ago, Enclusion said:

Move it to CE Development, please. I wouldn't consider this a release, just showing people what I am working on and asking for any input they can provide.

Gotcha, and done. Thanks! 

Enclusion likes this

Oddly, this is familiar to you... as if from an old dream.  

Share this post


Link to post
Share on other sites

You could use something like this:

local file = io.open( "%username%\\Documents\\My Games\\Halo CE\\chimera\\lua\\global\\health.txt", "w" )

That way it will target what ever user the current system is on all Windows systems. 
 

Not sure how to implement such a thing on Linux though, as there you are pointing to the `z:` drive?  This would want to point to wine's `c:` drive.

Enclusion likes this

Share this post


Link to post
Share on other sites
27 minutes ago, Devieth said:

You could use something like this:


local file = io.open( "%username%\\Documents\\My Games\\Halo CE\\chimera\\lua\\global\\health.txt", "w" )

That way it will target what ever user the current system is on all Windows systems. 
 

Not sure how to implement such a thing on Linux though, as there you are pointing to the `z:` drive?  This would want to point to wine's `c:` drive.

Writing files isn't the issue, I know how to write files for windows/linux, would just use relative directories in the end. The issue is that writing to files and reading files isn't the most efficient way of doing it and is sort of a strange, in the end I'd rather not do reading/writing for something simple as this. For now I am just focusing on re-creating the UI and getting it polished before going back and making the data transfer method better.

Share this post


Link to post
Share on other sites

Ahh.  Also think you mentioned luasocket, not sure if it would work for you, but try installing Lua modules in the executable (haloce.exe) directory using luarocks?  That part of Chimera's Lua was not really set up to point to something like `chimera/lua/global/modules` unfortunately.  Good chance it still wont work though.

Neat project though.

Enclusion likes this

Share this post


Link to post
Share on other sites
11 hours ago, Devieth said:

Ahh.  Also think you mentioned luasocket, not sure if it would work for you, but try installing Lua modules in the executable (haloce.exe) directory using luarocks?  That part of Chimera's Lua was not really set up to point to something like `chimera/lua/global/modules` unfortunately.  Good chance it still wont work though.

Neat project though.

I tried that. It just instantly crashes upon trying to load socket. I'm not knowledgeable enough about Lua or how Chimera scripting works to search for a solution right now. 

Share this post


Link to post
Share on other sites
  • Recently Browsing   0 members

    No registered users viewing this page.