Porting from RDNH SV3 to SV4

Return to Index

This page documents the steps to port a script from ScriptVersion 3 to ScriptVersion 4.

If I missed anything, please let me know.
-- Mana

General

The save file formats have changed, any .dat files saved by the engine should be deleted manually (including LogWindow.dat if you want it to start with all filters on by default)

Arrays

Arrays are now references, ensure all array usage now takes this into account:

Strings

Strings are now references to immutable sequences of characters, not arrays. The engine will attempt to de-duplicate simple strings (alphanumeric, underscores, dots, and slashes) during compilation to make comparison between strings faster.

Important points:

Collection Type Warning

All collection types (array, string, table) are references and use simple reference counting garbage collection. This means that if you create a reference cycle, the memory can leak.
Strings, despite being a collection type, cannot create reference cycles because they are immutable sequences of char (a non-collection type).

Note: The copy(collection) function can be used to safely store a copy of a collection within itself.

The following are examples of reference cycles that can cause a leak and how to avoid them:

The concatenation operators ~ and ~= always create a deep copy automatically and are therefore always safe to use.

Functions

Some new functions are known to have the same names as functions in existing scripts:

Keywords

Some new keywords that were introduced are likely to potentially have the same names as variables in existing scripts, ensure that no variables are named the following: