FreeSpace Releases > Scripting Releases

ship save/load script

<< < (3/18) > >>

Nuke:
just an amusing piece of code from run_sexp() in sexp.cpp.

but i followed the calls and run_sexp(), does some string magic (namely the hack above) to process the string and dump it into a buffer. then set a pointer to the buffer. this pointer seems to be a global. at some point in get_sexp(), a call is made to get_sexp_main(), which makes use of that same global pointer (*Mp). and in that function there is this code:


--- Code: --- savep = Mp;
if (!strncmp(Mp, "( )", 3))
savep++;

Assert(*Mp == '(');

--- End code ---

and theres yer problem. seems it expected to see a ( character, but saw an 'i' instead. thus the assert. i think your sexp needs to be in a set of (). that is assuming my understanding of how asserts work is correct.

Admiral MS:
Adding some () so it looks like:

--- Code: ---if (mn.evaluateSEXP("(is-destroyed-delay !0! !"..shipname.."!)")) then
--- End code ---
seems to work. I get no error and there are the right results in the savefile.  :)

That much about the documentation of scripting  :rolleyes: and error messages telling the user what's wrong :wtf: Why is the syntax of evaluateSEXP() different than that of runSEXP()?

Thanks for looking for it in the code, would've been stuck without your help!

Nuke:
seems the only difference between evaluateSexp() and runSexp() is this line:


--- Code: ---snprintf(buf, 8191, "( when ( true ) ( %s ) )", s);
--- End code ---

which is present in runSexp() but not evaluateSexp(). to make the syntax more uniform, i could just add it to evaluateSexp but use:


--- Code: ---snprintf(buf, 8191, "( %s )", s);
--- End code ---

which would essentially put anything in your sting in parenthesis for you, but this feels kinda like yet another hack in an already hackish system. im gonna ask the coders if this is a good idea to do this or not or not. it also kind of makes me question why we need both functions.

Admiral MS:

--- Quote ---it also kind of makes me question why we need both functions.
--- End quote ---

I need both evaluateSEXP() and runSEXP() because what they return is completely different. Evaluate does return whether the statement is true, false or whatever and run just tells me if the game could process the sexp or not.

Nuke:
in that case i may just add more info to the description strings so scripters aren't at a total loss about syntax.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version