Well I'm making good progress. I think all the bugs are worked out of the code but right now I'm trying to set up an easy for mods to get code in and out of live game from the panel. It looks like next Sunday is the most likely release date but we'll see what happens.
Well it looks like I'm going to need a little more help. I tried to setup a system where a mod in LiveGame_FloatZone could send a function to run in live_game like this: Code: var toLiveGame = { funct: function () { console.log("test"); } }; RunLiveGame(toLiveGame); In my LiveGame_FloatZone panel I have this function: Code: function RunLiveGame(Code) { api.Panel.message(api.Panel.parentId, Code); } and as part of the setup it runs this in live_game: Code: handlers.LiveGame = function(Code) { Code.funct(); console.log("Message received from LiveGame_FloatZone"); }; I have a similar system for live_game to run code in LiveGame_FloatZone. The idea is that a mod could use this to send data back and forth which could be used to create sort of cross-panel KO variables or do any number of other tasks. My problem is that whenever I try adding RunLiveGame(toLiveGame); to a mod it causes the LiveGame_FloatZone panel to disappear from the game and causes all sorts of UI glitches. Worst of all "test" never appears in live_game's log. Any suggestions? I don't know if the other half of the system (the live_game to LiveGame_FloatZone part) works because I need this working to test it.
BTW, the current WIP code for this is now on GitHub here: https://github.com/pamods/LavaSnake-s-Mods I'm using the WIP version of Commander HUD as the testing mod for this and you can see the glitch by uncommenting line 46 of rCommanderHP/ui/mods/rCommanderHP/rCommanderHP.js. Everything else works fine when the line is commented.
Haven't looked into why it's causing such a severe error, but I believe messages are sent via JSON, and functions aren't part of JSON; at best you're sending a string of the function's code, and then trying to call that string. If you really want to do this, you may be able to eval() the function string but keep in mind you won't be able to get any closured variables in the function. First things to try: try printing what you get to see if it's even coming through in a usable form. Perhaps before that, just do .toString() on a function in the sending panel to see if functions even stringify usefully, and then JSON.stringify(Code) to see what it's going to send. Yes, this all complicated and difficult. Here be dragons.
ok, thanks. That helps a lot in the me-understanding-what-this-is department which should help in the good-old-debugging department. I'll run some tests and possibly redesign the system to make it work better with JSON. Anyway, that really helps!
Well that helped. Now it doesn't glitch but no payloads seem to get through. Here's my updated code: in LiveGame_FloatZone: Code: function toLiveGame(payload) { api.Panel.message(api.Panel.parentId, "floatmessage", payload); console.log("Sent payload"); } var handlers = {}; handlers.floatmessage = function(payload) { console.log("Payload received from live_game:"); console.log(payload); }; in live_game: Code: handlers.floatmessage = function(payload) { console.log("Payload received from LiveGame_FloatZone:"); console.log(payload); SendBack(payload); }; function SendBack(payload) { api.panels.LiveGame_FloatZone.message("floatmessage", payload); console.log("and sent back."); } But when Code: toLiveGame("testing payload"); is run in LiveGame_FloatZone nothing gets logged in live_game. Any ideas? I've compared my code to MC and as far as I can tell it matches. I've also checked that my handlers aren't getting overwritten. (and thanks for all your help @wondible!)
I'd expect this to be more of a problem going the other way, but I notice in github that you aren't calling registerWithCoherent. The stock panels are running code in $(document).ready, whereas you are in a script tag. I'd stick pretty close to the patterns you see in the uber panels until you get things working. Then you can try experiments and git-reset back to the last working version if it doesn't turn out.
That's a good point, thanks! I'll play around with some of that and see what's missing. @raevn If you don't mind I'd like to "assume ownership" of this mod like I did with Commander HP. That should make it easier for both of us since this update has a lot of API changes and that way I'll be able to easily manage code changes and future updates. My GitHub repo will still be open in case anyone wants to contribute. If that ok with you I'll make a new thread once I've finished this update and you can link to it from the OP of this thread.
I am 100% ok with this. It's a useful mod, but I just don't have the time to maintain or update it. Thanks heaps!
Sweet, thanks! I guess I'm officially a mod hijacker now. (The thanks really goes to @wondible though. I never would've gotten this far without his help.)
Well it turns out it was a combination of that and some issues with how I added the handler in live_game. So now I have a functional way of sending messages across panels. Thanks for helping me with that! Now I just need to turn this into a usable method of getting data....
ok, everything's done and I've finished updating the API guide. The new thread's here: https://forums.uberent.com/threads/rel-floating-framework-v2-0-73737.65658/
Trying to install floating framework on pamm by itself isn't working for me. It just keeps trying to download it forever. All mods with floating framework as a dependancy are refusing to install/update as a result *should add that it's only floating framework as far as i can tell. All other mods are installing successfully
Cola Colin managed to updated by completely uninstalling frameworks mod and reinstalling it. I didn't have it installed prior to trying to update hotbuild so I can't try that but you possibly could?
@LavaSnake There's something wrong with the mod's download URL (https://github.com/pamods/LavaSnake-s-Mods/blob/master/Releases and Icons/FloatingFramework_v2-0.zip?raw=true) The URL has a redirect loop.