-
Notifications
You must be signed in to change notification settings - Fork 5
Important Info for the Scripting System
Some people are having trouble with my script language. So here's a thread to ease those troubles... I won't promise anything, but there are a few things I'd like to say.
- The script system was the very first thing I wrote for this game. It works as intended. If there is a problem, it is 99.99% likely to be due to the script itself.
- The script system is not careful with where you access memory, so you can crash the game that way. Be careful.
- Don't attempt to use Lua. Trying to switch over would be nearly impossible.
- Use the Emacs tool. It allows you to recompile your script as you go. Just make sure you export, save, and backup often in case you have trouble.
- I decided to use an indent system to force clean code.
- To use the tools while playing the game, open up WMESSAGE.SRC and change around the first line... That'll allow you to hold down C while you're playing to pop up some tools... WSTATUS has a similar cheat commented out.
There's more, but that's enough for now. Some of the important scripts are GENERIC, STANDARD, ITEMREG, and MAPGEN.
CTRL-K to Kut. Several lines.
CTRL-C to Copy. Single line only.
CTRL-V to Paste.
The script system is basically a mini version of C with a few peculiarities... What things in particular do you need help with?
When you have something like self.x = 5.0, make sure you have self set correctly... It should be a pointer. So if I do...
target = FindTarget()
target.x = 5.0
I might crash the game, because I never bothered to check if target was valid... The "good" way to do it is like this...
target = FindTarget()
if(target)
target.x = 5.0
The FindIndex() and FindByIndex() functions are useful too... FindIndex() will return a character number, FindByIndex() will translate a character number into a pointer... For example...
target = FindByIndex(20)
if(target)
target.x = 5.0
target_index = FindIndex(target)
if(target_index == 20)
target.y = 5.0
Also, this is probably important... Always Export, then Recompile, then Save...
There is the source code (the .C files), and then there are the ingame script files (the .SRC files). Start up SoulFu DEVTOOL. Hold down the C key at the main menu. Go to the hidden tools menu. Use the text editor. Type in WMESSAGE.SRC. Change the first line to read...
#define CHEAT (SystemGet(SYS_DEVTOOL, 0, 0) && SystemGet(SYS_KEYDOWN, 99, 0))
...press the Recompile button, and you'll be able to use some of the tools while you're actually playing, by holding down the C key. Some of the other script files, like WSTATUS.SRC and WSPAWN.SRC and IRING.SRC have similar cheats built in... The logfile also gives a complete listing of all the .SRC files in the game.
Hope that helps!