Today I’m trying to figure out how to inject cosfiles into the lc2e engine.


I know next to nothing about bash, but some googling and looking at the official lc2e tools ended me up with this:




Which seems to work … kinda. But I don’t get any feedback if something fails to inject for whatever reason and I feel like that’s important. I also don’t get any OUTS messages and that’s really important.


The thing that’s frustrating is that the official minicaos tool and other official tools use the line:


nc localhost `cat ~/.creaturesengine/port`


And that doesn’t work for me. It just freezes the game and the script, like it’s waiting for something. I don’t know why it doesn’t freeze the game in the context of minicaos. When I add the -w0 parameter, which I guess sets a timeout of 0 seconds, the inject succeeds and the game goes on. I don’t know if that also stops the return value of the commands from printing or what.


Well, with a friend’s help, we wrote it differently:




And it works great with the smaller test cosfiles! But then I tried to inject a larger one and….



Hmm, okay. I wonder what the breaking point is here.


I tried injecting some other scripts and ran into some problems:




1) It doesn’t seem to like files with spaces in the name, and 2) I need to split the remove script off of everything else before injecting.


The first issue was easy enough to fix with a quick search-- wrapping the ‘$1’ in quotes


The second issue was also simple enough to fix with more code I stole off the internet. And since I was splitting the script into inject and remove scripts anyway, I figured I may as well include an extra parameter to run the remove script.




It’s not a real parameter, it’s just basically ‘if there’s literally anything there’ right now. I guess bash is similar to CAOS in that it treats any variable that doesn’t exist yet as a 0. I might add more capabilities eventually, but I’m just trying to get this to work right now.




It seems to work on a basic level, at least!


But I’m running into trouble with scripts, now:






I was afraid this might be the case. The scripts specifically need to be injected in a certain way, and that’s going to require a little bit of an overhaul of the bash script itself. It’ll have to wait for another day, but I believe it’s doable.