Difference between revisions of "Running Lua Scripts"

From The Powder Toy
Jump to: navigation, search
(Fixed some typos; Added reference to the Autorun Manager.)
(Update)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
----
+
This is a tutorial showing how to run a Lua script in TPT.
  
This is a guide to successfully run a Lua script published by community. There are several ways of doing that.
+
== 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.
  
====  Dofile ====
+
==  dofile ==
* Download the script to your TPT folder. (The folder with powder.exe and such)
+
* 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".
* Memorize the name of file.
+
* Open the TPT console by pressing the '''~''' key inside of TPT.
* Make sure you also know the file extension, it is considered a part of the name.
+
* Type in <code>dofile("filename")</code>, replacing <code>filename</code> with the full filename of the script, including its extension
* Open your TPT console
 
* Type in ''dofile("filename")'' of course replacing ''filename'' with the one you memorized
 
  
If it says ''could not find file'' - maybe you entered a wrong filename.
+
If it says "could not find file", you entered the wrong filename.
  
==== Autorun ====
+
== Autorun ==
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.
+
If you want a script be loaded every time you run TPT, you can set it as an autorun.
* Download script to TPT folder.
+
* 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".
* Change it's name to ''autorun.lua''
+
* Rename the script to "autorun.lua".
* Make sure you set extension too, so it isn't ''autorun.lua.txt'' or something
 
* Run TPT
 
 
 
==== Autorun and dofile ====
 
This keeps everything in order and 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
 
 
 
==== Using a script manager ====
 
Ultimate solution, allows you to start and stop multiple scripts from within TPT without having to edit the files each time
 
* Download cracker64's script from [http://www.tpt.io/:14596 here].
 
* Follow the instruction inside the forum post
 
 
 
 
 
 
 
If you get any errors from scripts, you should report them to the script contributor. Make sure to copy the error from the console.
 

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".