How to use Lua scripts

The Lua scripting language allows you to give your plugin more advanced features.
Previous topicNext topic
User avatar
FranchuFranchu
Inhabitant of a Country
Reactions:
Posts: 796
Joined: 27 May 2017, 22:07
Location: Freezing in Argentina
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

How to use Lua scripts

Post by FranchuFranchu » 19 Oct 2018, 00:42

Now Lua can be used in TheoTown. Lua is a real proggraming language. To learn it, read this.

To include a Lua file in your plugin, use this:

Code: Select all

"script":"file.lua",
The file has to be in the same directory as your JSON.
The Lua code can be this:

Code: Select all

function script.nextMonth()
      Debug.toast("Hello Month!")
end
This will show a toast each month.
The full list of the available functions in TheoTown is in https://theotown.com/forum/viewtopic.php?f=41&t=8587.
You do not have the required permissions to view the files attached to this post.
Did you know you can't blink while smiling :) ?
User avatar
Mg3094066
Inhabitant of a Supercluster
Reactions:
Posts: 3217
Joined: 27 May 2017, 23:50
Location: Venezuelan Republic of Mexico
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: How to use Lua scripts

Post by Mg3094066 » 19 Oct 2018, 04:52

FranchuFranchu wrote: 19 Oct 2018, 00:42 Now Lua can be used in TheoTown. Lua is a real proggraming language. To learn it, read this.

To include a Lua file in your plugin, use this:

Code: Select all

"script":"file.lua",
The file has to be in the same directory as your JSON.
The Lua code can be this:

Code: Select all

function script.nextMonth()
      Debug.toast("Hello Month!")
end
This will show a toast each month.
The full list of the available functions in TheoTown is in https://theotown.com/forum/viewtopic.php?f=41&t=8587.
Ummm... What does the Lua test?
I threw my dignity to trash and downloaded Free Fire... But someway i liked it ":'D

But i think it was too early to celebrate... my internet runs at 8kb...

Just wait another month... :bb
User avatar
FranchuFranchu
Inhabitant of a Country
Reactions:
Posts: 796
Joined: 27 May 2017, 22:07
Location: Freezing in Argentina
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: How to use Lua scripts

Post by FranchuFranchu » 19 Oct 2018, 10:04

It shows a toast each month
Did you know you can't blink while smiling :) ?
ElephantEthan
Inhabitant of a Megacity
Reactions:
Posts: 294
Joined: 26 Aug 2018, 12:07
Plugins: Showcase Store

Platform

Re: How to use Lua scripts

Post by ElephantEthan » 25 Oct 2018, 16:29

• Do lua scripts need a building to function? (like fun functionality)
• Can lua scripts be attached to anything? (buildings, terrain, trees, cars)
• How would one make a script that replaces a grass tile with a sand tile?
User avatar
CommanderABab
AB
Reactions:
Posts: 11263
Joined: 07 Jun 2016, 19:12
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: How to use Lua scripts

Post by CommanderABab » 25 Oct 2018, 18:07

Probably not; sure, why not; why not a sand dune blowing in the wind?
my avatar:
User avatar
CommanderABab
AB
Reactions:
Posts: 11263
Joined: 07 Jun 2016, 19:12
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: How to use Lua scripts

Post by CommanderABab » 25 Oct 2018, 18:08

Yay! A triple negative sentencs!
my avatar:
ElephantEthan
Inhabitant of a Megacity
Reactions:
Posts: 294
Joined: 26 Aug 2018, 12:07
Plugins: Showcase Store

Platform

Re: How to use Lua scripts

Post by ElephantEthan » 25 Oct 2018, 18:24

CommanderABab wrote: 25 Oct 2018, 18:08 Yay! A triple negative sentencs!
Your post contains so much negativity that it's actually positive :lol: although I'm not sure if I understand the land one.
ElephantEthan
Inhabitant of a Megacity
Reactions:
Posts: 294
Joined: 26 Aug 2018, 12:07
Plugins: Showcase Store

Platform

Re: How to use Lua scripts

Post by ElephantEthan » 26 Oct 2018, 17:23

Alright, I attached a script to an animation and it works, even if I didn't use the animation. I got the script to run when you open the game. Really cool stuff!
User avatar
TheRetroGuy
Inhabitant of a Conurbation
Reactions:
Posts: 433
Joined: 22 Jul 2018, 15:54
Location: On the edge of a large table
Plugins: Showcase Store
Version: Beta

Platform

Re: How to use Lua scripts

Post by TheRetroGuy » 05 Nov 2018, 23:28

Is it possible to have a Lua app on mobile?
I am in fact, superior.
User avatar
CommanderABab
AB
Reactions:
Posts: 11263
Joined: 07 Jun 2016, 19:12
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: How to use Lua scripts

Post by CommanderABab » 06 Nov 2018, 00:03

my avatar:
User avatar
Bearbear76
Inhabitant of a Multiverse
Reactions:
Posts: 5701
Joined: 10 Feb 2017, 12:53
Location: L2 cache
Plugins: Showcase Store

Plugin Creator

Platform

Re: How to use Lua scripts

Post by Bearbear76 » 08 Nov 2018, 11:29

To be honest I don't like any of the apps that are available
In the store. Rather use a PC or just use a normal text editor that supports Lua (i.e. QuickEdit)
Just my opinion
retired
User avatar
Hadestia
Inhabitant of a Megalopolis
Reactions:
Posts: 721
Joined: 17 Jul 2017, 14:16
Location: Philippines
Plugins: Showcase Store

Plugin Creator

Platform

Re: How to use Lua scripts

Post by Hadestia » 22 Dec 2019, 12:04

Its like a java 😀
 ! Message from: Hadestia
Visit my YouTube channel:
https://youtube.com/channel/UC5qG-r8y21036JZbGRClbdQ
User avatar
Bearbear76
Inhabitant of a Multiverse
Reactions:
Posts: 5701
Joined: 10 Feb 2017, 12:53
Location: L2 cache
Plugins: Showcase Store

Plugin Creator

Platform

Re: How to use Lua scripts

Post by Bearbear76 » 23 Dec 2019, 00:08

rjroldan1 wrote: 22 Dec 2019, 12:04 Its like a java 😀
Not really like Java.
Compared to java Lua is much more forgiving and easy. :lua:
Just my opinion
retired
User avatar
JustAnyone
Honorary Contributor
Reactions:
Posts: 3664
Joined: 23 Jul 2017, 10:45
Location: Easter Island
Plugins: Showcase Store

Platform

Re: How to use Lua scripts

Post by JustAnyone » 23 Dec 2019, 15:08

Also 10x slower.
User avatar
Bearbear76
Inhabitant of a Multiverse
Reactions:
Posts: 5701
Joined: 10 Feb 2017, 12:53
Location: L2 cache
Plugins: Showcase Store

Plugin Creator

Platform

Re: How to use Lua scripts

Post by Bearbear76 » 23 Dec 2019, 22:03

Lua is still on the fast side though
Just my opinion
retired
Previous topicNext topic