Difference between revisions of "Running Lua Scripts"

From The Powder Toy
Jump to: navigation, search
(Created page with " ---- This is a guide to successfully run a Lua script published by community. There are several ways of doing that. ==== Dofile ==== * Download the script to your TPT folder...")
 
(Update)
 
(4 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 +
This is a tutorial showing how to run a Lua script in TPT.
  
----
+
== Script Manager ==
 +
Using the script manager is the easiest and most flexible solution and allows you to start and stop multiple scripts inside TPT. It also allows you to download moderator-approved scripts from a script server in a few clicks.
 +
* Go to this [http://tpt.io/:19400 forum post] and follow the instructions.
  
This is a guide to successfully run a Lua script published by community. There are several ways of doing that.
+
==  dofile  ==
 +
* Download the script and move it to TPT's data folder. This can be found by entering the options menu in TPT and clicking "Open Data Folder".
 +
* Open the TPT console by pressing the '''~''' key inside of TPT.
 +
* Type in <code>dofile("filename")</code>, replacing <code>filename</code> with the full filename of the script, including its extension
  
====  Dofile  ====
+
If it says "could not find file", you entered the wrong filename.
* Download the script to your TPT folder. (The folder with powder.exe and such)
 
* Memorize the name of file.
 
* Make sure you also know file extension, it is considered a part of name.
 
* Open your TPT console
 
* Type in ''dofile"filename"'' of course replacing ''filename'' with one you memorized
 
  
If it says ''could not find file'' - maybe you did something wrong
+
== Autorun ==
 
+
If you want a script be loaded every time you run TPT, you can set it as an autorun.
==== Autorun ====
+
* Download the script and move it to TPT's data folder. This can be found by entering the options menu in TPT and clicking "Open Data Folder".
If you want some script be loaded everytime you run TPT, you can do the following. Although you might not be able to have several scripts on autorun.
+
* Rename the script to "autorun.lua".
* Download script to TPT folder.
 
* Change it's name to ''autorun.lua''
 
* Make sure you set extension too, so it isn't ''autorun.lua.txt'' or something
 
* Run TPT
 
 
 
==== Autorun and dofile ====
 
Ultimate solution, keeps everything in order, allows autorunning multiple scripts (if they are written correctly)
 
* Download script to TPT folder.
 
* Memorize the name of file.
 
* Make sure you also know file extension, it is considered a part of name.
 
* Create a file called ''autorun.lua'' in TPT folder
 
* Make sure you set extension too, so it isn't ''autorun.lua.txt'' or something
 
* Open the autorun and type in ''dofile"filename"'' of course replacing ''filename'' with one you memorized
 
* Run TPT
 
 
 
 
 
 
 
If you get any errors from scripts, you should report them to the script contributor, unfortunately you cannot copy error from console, but you can open stdout.txt which can be found in TPT folder, and look for it there.
 

Latest revision as of 20:57, 13 July 2016

This is a tutorial showing how to run a Lua script in TPT.

Script Manager

Using the script manager is the easiest and most flexible solution and allows you to start and stop multiple scripts inside TPT. It also allows you to download moderator-approved scripts from a script server in a few clicks.

  • Go to this forum post and follow the instructions.

dofile

  • Download the script and move it to TPT's data folder. This can be found by entering the options menu in TPT and clicking "Open Data Folder".
  • Open the TPT console by pressing the ~ key inside of TPT.
  • Type in dofile("filename"), replacing filename with the full filename of the script, including its extension

If it says "could not find file", you entered the wrong filename.

Autorun

If you want a script be loaded every time you run TPT, you can set it as an autorun.

  • Download the script and move it to TPT's data folder. This can be found by entering the options menu in TPT and clicking "Open Data Folder".
  • Rename the script to "autorun.lua".