Liberty Unleashed

Scripting => Script Help => Topic started by: Windlord on May 19, 2011, 05:28:09 pm

Title: Before you post...
Post by: Windlord on May 19, 2011, 05:28:09 pm
You may post in this section if you need any help with regards to scripting for Liberty Unleashed.
Please follow these few guidelines:



Make sure that your subject is informative.
Do not set your subject as "HELP!" for example.
Rather, set it as something specific to your need such as:
Code: [Select]
Can't get player to spawn
If you are asking about a problem with a released script, prefix your subject with the name of the release.
For example,
Code: [Select]
[FBS] Help with spawning cars



Make sure that you have checked all available documentation for solutions.
Liberty Unleashed has a wiki which can be found at the following link.
http://liberty-unleashed.co.uk/LUWiki/Main_Page
The wiki contains most of the information you need to know.

Squirrel has quite a few in-built functions however and you can access the Squirrel Language documentation at the following link.
http://squirrel-lang.org/#documentation
LU comes with Squirrel version 3, so you will want to check the documentation linked below the heading: Squirrel 3.x

If you are working on a released set of scripts, check the script's readme or release topic.
For example, FBS v1's topic is over here (http://forum.liberty-unleashed.co.uk/index.php?topic=394).



Make sure that you have tried everything possible before asking.
Sometimes, the solution can be very obvious.
This means that you should debug your code extensively. If you find interesting facts while debugging, do not hesitate to post a snippet (http://forum.liberty-unleashed.co.uk/index.php?board=21.0) or tutorial (http://forum.liberty-unleashed.co.uk/index.php?board=18.0) to help other users!
Some common ways of debugging include:

- Using print() to output useful information.
Code: [Select]
function ABC ( text )
{
print( "Parameter text contains: "+ text );
DoSomethingUseful1();
print( "The function, DoSomethingUseful1 has been executed" );
DoSomethingUseful2();
print( "The function, DoSomethingUseful2 has been executed" );
}
The above example tells you what the contents of your variable, 'text' is and whether a function has been executed without failing.

- Use try/catch
http://squirrel-lang.org/doc/squirrel3.html#d0e871
Try/catch is Squirrel's in-built method of attempting to run scripts and catching errors in the event an error occurs.
A simple example is the following script.
Code: [Select]
try {
print( "Hello World!" );
} catch ( errormessage )
if ( errormessage ) print( "ERROR" );



Search this forum for an answer.
You can search by clicking on this link (http://forum.liberty-unleashed.co.uk/index.php?action=search) or the "Search" button above.
Your problem may not be new and someone may have already solved it.
Maybe someone is currently having the same problem. You could then work with that person to solve the problem.