Hi, I'm new to Doom modding, but I think I found a way to expand the things you can do with ACS scripts using python.
Perhaps this was done before, but to my knowledge this is the first time someone has done this.
This paragraph is about how I got the Idea to do this so if you just want the technical stuff you can skip it. I got into Doom modding through the myhouse analysis videos by DavidXNewton. It was really cool how myhouse used the relatively simple ACS scripting language to great effect. I wanted to make some more complex scripts that are beyond the capabilites of ACS so I started with Writing files (haven't figured out reading yet but I'm working on it).
To my knowledge ACS scripting does not support writing files to the users computer at all. So I had to get ACS to tell a python script to do so. ACS can't do this, however, there is one way I can get ACS to shout into the void, if you will, so that my Python script can listen for the right things and then execute its functions. It turns out I can make ACS log some text and using a commandline argument to write this log to a text file. My Python script then reads this file and when certain text is written there it executes a certain function. To run both Doom with the log argument and my Python script at the same time I used a batch file.
Here is a little demo that uses this algorithm to exteract a text file from a zip when the player picks up a chaingun:
ACS:
script 1 (void) {
Log(s:"Call1");
}
Logic.py:
import zipfile
#Extract file from zip
def Pull(target):
if getattr(Pull, 'has_run', False):
return
Pull.has_run = True
with zipfile.ZipFile('Data.zip') as zf:
zf.extract('Data/'+target, 'Files')
print("Pulled: "+target)
def Call1():
#do stuff
Pull("Text.txt")
print("started")
while True:
with open('log.txt') as log:
if 'Call1' in log.read():
print("Here")
Pull("Text.txt")
print("done")
Batch:
start gzdoom.exe +logfile log.txt -file Bunker.wad
start py Logic.py
Here is a video demonstration: https://www.youtube.com/watch?v=-7AghV91gJk
Any questions, suggestions or criticism is very welcome.
(I posted this on the ZDoom forum under a different name so if you see that don't be confused)