the point is, an image still gets rendered by gr.drawImage if I call the associated function in the script locally, but not from script-eval in FRED.
With the code I gave you, gr.drawImage() should always be being called with the same timing, regardless of if readfile.showcbanim() is called from script-eval or not. Did you make any other changes aside from "!=" -> "~=" and sprinkling some warnings?
Oh, duh! I'm sorry, I just realized it was actually my leftover script-eval from the near-blank FRED mission I'm using to test this that was causing the anim to disappear so fast - when it triggered (one second into the mission), the image vanished.
I just re-pasted the script in to test, with my only changes being the "if not nil" bit and adding "readfile.showcbanim(some line number)" to execute the script locally at the bottom of $On Game Init. I then removed the event from FRED and the anim now automatically loads and plays all the way when the function is called locally..... but it only does it once and doesn't loop, which is OK since I probably want to use FRED to ultimately control the looping anyways (when I figure out why the FRED call won't load the image in the first place).
So I guess we're at roughly the same symptoms - the image definitely will load with your version of the script and play through, but only does it once (whereas mine loops indefinitely). And in either case it still doesn't draw anything if I try and invoke the function from FRED.
Have you checked the coordinates where the script draws the animation?
This part seems a bit suspicious:
screenx = gr.getScreenWidth()
screeny = gr.getScreenHeight()
Admittedly I haven't paid much attention to this just because the image DOES render fine if I call the script locally - it's only when I'm using script-eval in FRED to call it that it doesn't appear at all. Would this cause some kind of strange variance in the coordinates used?
Just to be sure, I tried statically setting the gr.drawImage xy arguments to 200, 200, but this made no change in my symptoms (still works fine from the script and appears where expected, but doesn't appear when triggered from script-eval)
Here's the basic event tree I'm using when trying to call the event from my mission, if it matters:
#Events ;! 1 total
$Formula: ( every-time
( has-time-elapsed 1 )
( script-eval
"readfile.showcbanim(2)"
)
)
(Note: I've tried both "every-time" and just "when" as conditionals)
This 'should' load cb_sm1-01_d as per what I have in cbanims.txt and play it as per the function. And it
does - my ba.warning hooks throw alerts indicating it's processing the image file and advancing the associated frameindex, and I can even see it expressly loading the .ani asset (cb-sm1-01_d.ani in this case) in fs2open.log:
Got event GS_EVENT_ENTER_GAME (2) in state GS_STATE_BRIEFING (10)
Entering game at time = 70.523
ANI cb_sm1-01_d with size 440x200 (21.9% wasted)
ANI cb_sm1-01_d.ani with size 440x200 (21.9% wasted)
WARNING: "i is 15.149917602539, totalframes is 171" at lua.cpp:12105
Frame 46 too long!!: frametime = 4.433 (4.433)
WARNING: "i is 18.899917602539, totalframes is 171" at lua.cpp:12105
Frame 47 too long!!: frametime = 1.084 (1.084)
WARNING: "i is 22.649917602539, totalframes is 171" at lua.cpp:12105
But nothing actually appears on the screen if I do it this way.
You can try all this yourself if you want as well - this should work with an unmodded base game (or any other mod really). After deploying the script, create data\scripts\cbanims.txt and throw a line in with the desired animation (i.e. cb_sm1-01_d ). Then either execute the function in the script locally (i.e. from $On Game Init or whatever), or call it via script-eval and compare the difference. I'd actually be genuinely curious if anyone else can reproduce this, because I'm starting to wonder if I just have something really, really strange with my environment and that this really "should" be working. I'm almost tempted to try a clean install.
I guess to be clear, I should also mention I'm running all this on 3.7.2 RC3.