Hard Light Productions Forums
Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: CP5670 on March 05, 2007, 01:57:35 am
-
Can one of you tell me how this sexp works? How is the script specified in it? The sexp description is useless and I can't find anything about it on the wiki.
-
You specify a function in the scripting.tbl and use the script-eval to run the scripted function. There are some big limitations with the string lenght though so you may have to use rather short function names.
Scripting.tbl - probably to gameinit hook
function runme()
ba.error("script-eval test")
end
Would toss an error to the screen and stop (ctd) the game when the 'runme()' function is called via script-eval sexp. So you can build complex lua functions and then execute them via script-evals. Well.. in theory at least.. that is i havent really even tried these.
-
I tried that out, but I can't get it to actually detect the function (the LUA syntax is runme = function() ). The sexp seems to have no effect, although the function works fine if I call it in the HUD hook or something like that.
-
AFAIK you'll have to write the function to the sexp.. it doesnt appear in pulldown menu
And actually Lua is supposed to accept both syntaxes for functions but that isnt important...
-
Yeah, I was entering it in manually, but the game itself didn't seem to recognize it.
Does it need to be placed inside any specific hook in order to work?
-
I tried this one and got only errors
Sexp
$Formula: ( when
( has-time-elapsed 5 )
( script-eval "runme()" )
)
+Name: Script
+Repeat Count: 1
+Interval: 1
Scripting
runme = function()
ba.error("script-eval test")
end
Errors
LUA ERROR: [string "runme()"]:1: unexpected symbol near '<eof>'
I even tried to look help from the CVS code but my feeble skills were no match for the dark powers of C
-
At least it's giving you an error. I am trying a very similar thing, but the game doesn't do anything at all. Could you post your entire scripting.tbl?
Wanderer
Wiki Warrior
Posts: leet
Didn't know the forum software did that. :D
-
I use new builds from HEAD branch... 20070228.
Full scripting.tbl:
#Global Hooks
$GameInit:
[
runme = function()
ba.error("script-eval test")
end
function metoo()
ba.error("script-eval test 2")
end
]
#End
And full sexp list
#Events ;! 2 total
$Formula: ( when
( has-time-elapsed 5 )
( script-eval "runme()" )
)
+Name: Script
+Repeat Count: 1
+Interval: 1
$Formula: ( when
( has-time-elapsed 4 )
( script-eval "metoo()" )
)
+Name: Scrtest
+Repeat Count: 1
+Interval: 1
-
It must be a build-specific thing then. I'm using one of the Taylor builds. Does this script-eval sexp work at all in the builds from the stable branch?
I need to get WMC in here... :p
-
Stable branch scripting is unsupported. Try adding "[" and "]" (without the quotation marks) around the script, so:
--script-eval
----"[runme()]"
-
I tried that out, but game was throwing up a LUA error with it (something about an invalid string type, the same error I got when I wasn't entering the function parentheses correctly).
The current head builds have a particularly bad bug in them (the pilot file thing), so I'll wait for that to be resolved before trying them out.
-
Try adding "[" and "]" (without the quotation marks) around the script, so:
--script-eval
----"[runme()]"
Yay! That worked.