#plugin-lua-and-fun
1 messages · Page 6 of 1
Helo
What is this channel for
What is metatables for
finally, a fun channel
metatables are used to give a table "fallback" keys (thats are usually functions) that are retrieved when a value isnt found in the actual table. Theyre also used to overwrite mathmatical operators for tables
but what idiot decided to choose a double underscored name for em
probably a python fan
How can I make a plugin that lets me spray paint any building I desire?
I don't think that's possible
Is this the right channel to talk about this stuff?
I was thinking about it, as I feel like there's not enough crime in this game
Maybe Lobby knows more about this stuff, but I cannot ask him about it as he blocked me
Skill issue
@stoic vector your idea basically means a new sprites for every game building and no plugin compatibility, if i got it right. Just drop it bro
No, not new sprites
You WILL require new sprites
Safely assuming that you want the Vandalism to be visible in your city
that's not what they meant
they just want to issue the graffiti disaster
that's what I think they meant, at least
in that case it's City.issueDisaster
Right
I dont think its a good idea to make plugin which only usage is making the game harder
Well true. But I feel like watching my city crumble is sometimes very fun, especially in sandbox
Dont make it to plugin just then
Just have fun with lua (its actually fun)
Why are you so worked up about a plugin they want to make for themselves? Isn't that the whole point of "private plugins"?
By plugin i meant a plugins store plugin, not a plugin as it is
Language inconvenience
Did he imply he wanted to share or upload it to the plugin store?
By plugin i consider uploaded plugin, so its an issue from my side. You want to continue this useless argument, or whatever it is?
Well yeah, seeing as how you support private plugins. Realistically, their idea sounds good. If they can pull it off, that's amazing. And if they post it on the store, there's no issue with that as long as it complies with store rules. It would add something new and valuable and a lot of time would be put into it as well so 🤷♀️
I didnt even got their idea
Just more spray paint disasters?
Build less police stations 😊
Not understanding isn't a reason to demotivate though. A better approach would be to ask more questions.
Might be more of a visual thing for screenshots and videos. They said specific buildings so I assume that's what it's for. And even if it isn't, who are we to judge lol.
Making "no supply" achievement impossible yeah
Why demotivation? I said, if you making it for fun, for yourselves, just dont upload it
They agreed as i see btw
Would you like me to quote you or what?
Why shouldn't they upload it then?
Because they said that "they love to see their city crumble" and they agree that you shouldn't make plugin which only makes game harder
What are we even talking about?
Hello. How can i fix that ? When use drawCity(), the object seem to be in front of the building, but i want it to be behind all the buildings
Or is there any other function that can help me do it?
if you want to draw on your building you can use script:draw
depends on what exactly you need
I want to draw an object that behind all the building, such as stars 🥲🥲🥲
thats gonna be a hard one
you could draw the stars, then draw the building's frame over it a second time
Are you anhkatori?
Man I love your plugins
Huge fan
Yeah
forgot to mention script:draw only gets called if the building is visible on the screen
so if you draw next to it it might cut off early
thank you 😄
?
@mighty cargo #language-bar
AI plugins go brrrr
it happens more often than youd think
how do i determine whetehr the gui is hidden
thought i ought to fix those screenshots with complex industry sidebar buttons on them
Settings.hideUI or whatever its called
im literally only asking for the key
if i knew what it was called i would have it fixed already
in other news, check out what ive managed to do
try hideUI
looks like the settings table isnt called Settings to begin with
for future askers, it was Theotown.Settings.hideUI
Great!
hey guys, i wanted to ask cuz I'm having "rawget" not implemented on nil error with 1.12.24 when my GUI gets closed calling window.delete() but seemed to work and fine with my other devices having version 1.12.23, any thoughts?
There have been no GUI related changes between 1.12.23 and 1.12.24
ohh thanks for letting me know
does the game support comparator lua function?
depends on what you want to do
Whats the way to make script which sense chat message,"error blahblahblah" if you haven't upgraded some building and trying to build another which requires the upgrade
So like if you have b1 upgraded you can build b2, if not, it just returns error via debug.toast or whatever.
Im familiar with lua but not theotown ways of scripting using it.
i have done this before, you can lock the building behind a FUN variable that is set to 1 when the required building gets upgraded
i will share the script momentarily
this is the script i use
now i just need to find where i put the code for locking buildings behind it
ah yes
in your draft you can put ```json
"requirements": [{
"type":"CONDITION",
"text":"Upgrade a building to unlock this! (or whatever requirement you want)",
"condition": {
"type":"value",
"code":"The id of the upgrade",
"z":1
}
}],
@edgy tundra
this way you can use the game's way to lock upgrades
Oh wait i thought code needs to be lua
Tyyy :3
its a bit of both
It doesn't work
Building is still locked
Or wait maybe I'm stup and this isn't the way it works
did you add the script to the building that has the upgrades
Yeah
Linked it via "script" thing (is this the right way to do it?)
yes
So no idea
I did just copypasted the script and requirements module (inserted id into it obviously)
And nothing works
Like it is locked still
Weird
I love lua
local draft = draft get draft draft draft draft
the code looks sound to me so if it doesn't work, you're doing something wrong
Local draft = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.draft literally
Idk why it doesn't work really
I do understand lua well and heres the proof but i don't really understand why doesn't it work in this case.
The issue is pretty stupid ig but u can't for some reason figure it out
I sent already in #plugin-support
The only thing I changed is requirements thing
can't help without your plugin
actaully, did you let the game tick for a day? Fun takes a day to update
its an old logic system
but i cant help you more unless i have the full plugin
so i can check your implementation
Hi, may I ask something?
I'm currently using a module to cache data during runtime, and I was wondering... does this cached data get cleared when a user switches tabs or minimizes the game, especially on mobile devices?
I'm targeting mobile users in particular and want to make sure runtime data isn't unexpectedly lost when the app is backgrounded.
Any insights would be appreciated!
I'm not aware of any game functionality that would unload scripts in the background. Users switching tabs or minimizing the game should be treated as the game being force closed unexpectedly.
Hi
quick question..
does using function script:init() in a module also get triggered when the main script uses that module with require()?
no
youll have to call an initialization function
can be a problem with a external plugin
dang.. thanks
is there a pedestrian bridge plugin or not
There is.
can you tell me which plugin is it?
What lua does mean?
Another script of code
Ohh
Where can I learn Lua for free?
on the forums/lua api
Can i ask something?
I'm using mt manager to create plugin, but for some reason It's not working. Game doesn't load it anyway,i tried in z archiver, cx but still looks like game can't read my commands.... Guys ignore my grammar....
And please help, if someone can
And can you show your json or lua file?
are you sure this isn't something spewed out by ai...
Are we gonna blame ai on everything now
this is exactly how ai generated code would look
yes???? if it spews out unusable garbage, who else can I blame it on (other than the user of said ai of course)
the code in question uses event functions that dont exist and api calls that dont exist
ai would dream something like that up, humans dont do that
I love how ai will never say 'idk' and it will just make the most ridiculous shid up
and the onCustomButton function does not make sense in the context it is being used
either way its a trainwreck
what is this.. a show off
Ppunish 667883088172285962
pato0mg was banned for the following reason: Sharing or spreading scams or phishing content.
A Helldrivers have arrived
Rather stupid of them to do that in the only channel I read.
the honeypot
if its your plugin, yea
retrieving the gui components can be a bit complex because the id's are hidden
yes
oh you mean 'my' plugin. I mean, if I created a gui, can I somehow show the list of the users currently installed plugins?
compendium; if you have thousands of plugins installed (me) it'll be harder to find that specific plugin you need and sometimes you'll forget its name which makes it harder to search. So instead of going through that hell, I will make (if feasible) a plugins folder maker or something like that, I'll figure it out
It's literally the same as the plugin folder within the game
can I somehow somehow use this?
it compiles all the plugins, so instead of users able to create files, I'll just sort out their plugins ✊🏻
it's not, trust 🙏🏼
Wait hold on
Are u referring to the plugins that have no plugin manifest?
There's two ways to find the plugin file
The actual plugin file in the plugin category or just remember what their ids are
and that
Tbh it's also the creator's fault for not sorting in the right category or alternatively makin their own category
it may be possible if you retrieve the gui objects
im not sure they can be retrieved if the menu isnt open
youd have to figure that out
okay, I'll be back in 3 months, if I dropped no update after that it's safe to say I've given up
I wrote a "discovery" snippet that logs child IDs under GUI.getRoot() during runtime and it crashed 😭
Dawg... Why this image??? 😭
yea a lot of gui objects will just not have an id
I give up 🥀💔
what are you trying to does?
ooo
😔
Never back down, never what?
NEVER GIVE UPPP
I wonder what this channel for, because I never been here before and it seems abandoned
maybe read the channel description......
Oh yeah, never thought about that
Hi
Is there a function that returns the current ui size?
I tried to look for it on the Lua API website, but I failed
As in, the user setting or?
I mean this
Try TheoTown.SETTINGS.uiSize
Works well, thanks
Ppunish 1336067779350102107
Pls plugin ikn plis

Please make an IKN
dont wanna
Hello
Is there a way to get the camera position without isometric transformation like City.getView?
I just want the raw xy position of the camera.
well that was hell lol
figured it out
spent so many hours trying to think out the math lol
I had to convert screenspace coords to world space for my shader so I could properly anchor effects to the city
Like cloud shadows, so they don’t just disgustingly shift around when panning, zooming, and rotating the camera
Cloud shadows! (and dynamic time of day/weather)
Now I'm working on fog:
isnt it just a simple math?
rotation: x, y
0: x, y
1: y, city width - x
2: city width - x, city height - y
3: city height - y, x```
It's cool to see that people still make cool stuff that isn't just more skyscrapers
More progress on my shader plugin
its looking good
Made some tweaks to the sunshine effect so everything gets a dose of sunshine, alongside cloud shadows (I need to make it so that shadows project differently onto buildings so they don’t just look flat):
https://streamable.com/dzeuzz
And of course a comparison screenshot with just the Classic/default shader:
Looking to get this released in the next few days hopefully. Got a lot of cleanup to do.
Also need to figure out how to publish a plugin.
Got the world position calculation for building sprites to scale their Y component to stick closer to the ground position, so that effects such as cloud shadows project onto them differently and don’t just appear flat as it moves across the city.
Hello, I use your help, this is the code but when you click nothing appears
It literally appears as if to build a building but without doing anything, or graphics at all
are you calling the showDialog function?
if you want it to be called when the user enters the tool, you may want to add this section ```lua
function script:event(x, y, _, event)
if event == Script.EVENT_TOOL_ENTER then
showDialog()
end
end
Thanks
Hello, would any of you have a sample for a lua code that generates a sound when you zoom in on a building ? Like when you zoom on roads and they produce a road sound, trees and they have birds chirping, etc...
...how is that related to anything here?
Ii want to use it for animation but it keeps giving me BARBATOS value frames12 speed200 loop true at animation of type info.flowersoft.theotown.utiljson.JSONObject cannot be converted to JSONArray
that's not lua/fun
It's coding problem
use the other plugins channels (and provide json)
json and lua are two separate languanges
Oh ok
You would use City.playSound function. A plugin that makes use of the functionality is attached.
oh yeah that one plugin lol
Thanks JA, that will prove very helpful !
They're multiplying
Thank you so much, it is help me so much. I was looking for it
yo coders
quick question
how do you define 0 pollution on the json?
Or are industrial buildings bound to emit pollution whatever?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
"influence pollution" : 0
Did I write it in the correct place? Maybe the game just ignores it? Because when I wrote "influence noise" it also didn't seem to be changing anything
you cant change influences of rci drafts unless youre privileged
which is a shiddy change and should be reverted, at least for the basic influence types
oh my gof
god*
what if I create a new category?
in the future, please use support or discussion channels if you're not looking for lua related help
will do
Use type building
But no one would live there
also no workers, I imagine?
yep
It's growing.
your intention is to open a dialog when the user enters the tool?
for starters, the onClick in the luawrapper doesnt exist and wont do anything
youll need this code
and you can put the GUI.createDialog inside the if instead of showDialog()
Is it possible to make a bus station compatible with the trans upd,by using the plugin creator Web only?
I guess so. Check the plugin forum.
Thx
Thanks erksmit. I'll try that 🙂
@icy peak please issues from other server's out of this one, and please keep messages on topic to the channel description
I think he underage
Even so, unless I know for sure I'm not going to ban someone for that
Furthermore as staff we do not ask
I need plugin car br
Its not car 🗿
Lua
Hello, a question, What else is missing for it to be another transport system?
where on earth did you find that...
oh that actually exists? zamn
is your plugin privileged
Is in the page of the Guide Plugin Creation, dont is the Forum is other page of Theotown, but there have much import information.
But it still doesn't work and I don't have permissions to see that full information in the Forum
I wish it was
then it aint gonna work
Yes, already see this ;-; just is for privilege user
How can I get of the permission?
become a trusted member of the plugin creator community
And how can i be a trusted member of the plugin creator community?
basically just be active and well-known I guess
enough that the devs take notice
well i guess not just active and well-known bt in a good reputation sort of way - which would not get you there if you try to extract the source code like 5 times
Ok? Active here in Dircord, in the forum?
either or both
What? I don't try extract the source code (I think, if I think wrong sorry) just I use the tools in this link:
https://pca.svetikas.lt/docs/
that was a reference to something else entorely, sorry
you just have to be active to become trusted
oh man youre working with lua?
Ok, is fine
Yes
honestly you can create a privileged creator request through
uh @torpid spear do you remember the new protocol for this
nope
probably shoot justanyone or lobby a direct message through forum maybe? never hurts to ask i suppose. Tell them what you are trying to do with examples of your past work if you do and whatyou are trying to accomplish
I dont remember how I did mine
Ok, thanks
Hello, is it possible to add audio to a plugin with a duration of 30 seconds to 1 minute?
I've tried several Lua codes, but the audio gets cut off after 10 seconds.
However, this issue doesn't occur on PC; it only happens on Android (and potentially iOS as well)
Yo does anybody know how to get the empire State building as a plugin just asking
Plugin store.
Can you not spam this everywhere
In one channel
hey im new here can anyone tell me where or on which software do you build these plugins
Ptag creation
Step 1: Download a baseplate of your choice It is recommended to keep it small if you are just starting.
Step 2: Download a pixel drawing app. It is recommended that you get one with layers and transparency options. You can find a list of suggested options here
Step 3: Here are some tutorials that show how to make a house. One by Theo and one by Kulche
Here's a tutorial by rtobby that provides tips on improving the plugin quality
You may find more tutorials in the getting started page and on the forum
And even more tips pinned in plugin discussion
Step 4: Last step is to create a json. You can create one by using PCA or use this tutorial here to make one. To make one manually, you can use any text app which allows you to save files as a .json
Feel free to ask for help or suggestions on the forum or on the server
Bonus step: Once done, you can upload your plugin on the store which once approved can be downloaded in-game by anyone or post it on the forum showcase or both! Remember that store plugins must oblige to the store rules
plugin thats make more income please
Wrong channel, you might be looking for #plugin-suggestions
You can type income or monthly income on the plugin store to find buildings though
thanks a lot and sorry
.
i wish we could have websockets e_e relying on log.txt suck
Hello
TheoTown files are located under such directories:
- Windows: C:\Users(insert username)\TheoTown or %USERPROFILE%\TheoTown
- Linux: ~/TheoTown
- MacOS: /user/TheoTown
- Android: /storage/emulated/0/Android/data/info.flowersoft.theotown.theotown/files
By default you should be in /storage/emulated/0/. Uninstalling the game on Android will delete all files, unless you decide to keep the files when prompted by uninstaller. (android 11 onwards restricts access to external storage for apps, so if the files cannot be accessed this way, opt for the in-build manager explained below) - ios: Search "TheoTown" in the file manager app
If you cannot access game files through these directories, game has an in-built file manager for mobile devices which is accessible from the region view menu.
You can find your plugin, music, region and city files there as well as logs for debugging purposes.
Ptag creation
Step 1: Download a baseplate of your choice It is recommended to keep it small if you are just starting.
Step 2: Download a pixel drawing app. It is recommended that you get one with layers and transparency options. You can find a list of suggested options here
Step 3: Here are some tutorials that show how to make a house. One by Theo and one by Kulche
Here's a tutorial by rtobby that provides tips on improving the plugin quality
You may find more tutorials in the getting started page and on the forum
And even more tips pinned in plugin discussion
Step 4: Last step is to create a json. You can create one by using PCA or use this tutorial here to make one. To make one manually, you can use any text app which allows you to save files as a .json
Feel free to ask for help or suggestions on the forum or on the server
Bonus step: Once done, you can upload your plugin on the store which once approved can be downloaded in-game by anyone or post it on the forum showcase or both! Remember that store plugins must oblige to the store rules
in the future, please use #plugin-discussion or #plugin-support @peak pine
Any List For Type Value?
https://forum.theotown.com/viewtopic.php?f=41&t=1355 again, not lua related
Oh ok
What script function is used to make local news appear when a building is being built?
Yes, it's like that, but the notification only appears when the building is being built, is that possible?
so a notification on building placement? use fun or lua
there are tutorials on the forums exactly for that
you can listen for event.building_finished and send the notification from
there
or use fun 🥰🥰🥰
may as well end it all now
I'm using "script:event", but why does it come out three times? during construction, when it's built, and when it's destroyed.
how does your script look like
you're probably not actually checking what event it is
what should it be like?
😭
I won't comment on the quality of your code but you're missing the event type check
sorry i'm so bad, i just learned about lua😅
lol
I used "EVENT_FINISHED" before but nothing happened
how did you do it
just changing part of the script function, I don't understand😭
you have to pass event as a function parameter and compare it to the constant
Is this?
can't help without code
function script:event (0,0,0,0,0)
what.........
I don't even understand what I'm writing🗿
yeah you're gonna have to either have someone do it for you, or learn programming basics
You’re right, thanks for helping me out😔
Hey guys Can I ask something? Where can I get the Sunray pluglin?
not in this channel, thats for sure
He said if you share the code (as text or a file) he can help
help😅
not lua related
plugin can use json?
yeah..?
hi, how can u use plugin on windows??
what is fun ? is it Json too ?
It's extra code
It's a bunch of stuff, you'd learn it later in plugin developments
Hi
im currently on the json stage of plugin creation
I'm a new member
you can use fun to create more advanced feature
unlike the ame suggests, it is not fun. Trust me.
you can use it to make a building make noise on click etc
does this work also for Lua?
no idea but you'll be better off using TheoTown.translate
how do I actually use TheoTown.translate? Do I just write the dialog in English and the game will automatically translate it?
ah, wait
Does anyone else find the Lua documentation somewhat confusing, particularly the drafts section? It appears that many functions include parameters related to drafts, but not all of them clearly explain what drafts are or where they can be found. This can be quite overwhelming for new developers who are trying to use Lua. I only understood this better after discovering the “list of drafts” plugin by 1code. Thank you to whoever created it.
yo guys can u help me for make a income code
Not possible without being a trusted plugin creator
Also exploiting the game like this will get you banned in the future.
Dont get me wrong im against cheating but getting banned on discord for single player plugin is wild
Maybe just let the game itself block the OP code?
it wouldn't be a problem if theotown was a normal paid game on all platforms
but with the freemium model we do have to enforce stuff like that
Whats the corelation with Theotown being freemium or not? isnt the difference is only about the existance of diamonds instead of income
Also idk if he meant to publish the plugin or not
it's probably a pretty thin line, but most "lazy" ways or getting extra money are gated behind diamonds
I really fail to understand why would you want to figure out such an elaborate way to cheat when there's literally a free sandbox mode
anyway, let's stick to lua here
Are people still cheating in this game where it literally give you diamonds in a daily basis. Impatient
omg.....
Okay, guys, I have a problem, so, i was making a supermarket plugin right? I added Price, Monthly Price, Build Time attributes and etc, I typed the numbers in on the other attributes, but when I tried to type the numbers on thr price and monthly price, it won't work, I clicked multiple time, but still won't work
not lua related
then use the correct channel
I'm going to warn the next time someone misuses this channel
thats exactly what happens
Where i get a template?
still in island development
im sorry, but.. anyone here that have a sun beam (ig) plugin?
sunlight you meant?, search it on theotown forum
plugin buar kerajaan gitu ada gak?
Tuto oii gwe newbie
Can you two speak English please
Flezi asked if there was a plugin to create a kingdom or not.
As for Dadang, he asked for a tutorial on how to play because he is a beginner.
Do you want to make a spidermon logo 😭😭😭
That’s either a ribcage or a tree
pls help me, is the coding correct? please correct
No, it is not.
I love ai slop
Bruhh
I tried using AI bro, and yep it turned out to make me even more dizzy
Dawg ... Are you seriously trying to make a money-making plugin?
The code doesn't work like that
Actually, I'm just confused about trying to make a plugin that makes the game easier, it does have a sandbox mode but I just want to try using a plugin, because if you just use buildings the logic sometimes doesn't work.
sorry, I mean if you only use the building, sometimes the bugs become - all of them, and the residents' section becomes -2, I want to make it using Lua but I don't know what the logic or Lua coding system is like
"i want to exploit the game so that i don't have to play it" get out of here
Peak user
Comes to the official server and ask the official staff on how to exploit the game
what do you mean?
I'm looking for a plugin that generates money and city level; could it be one?
No, that is not allowed
¿¿No?? y el de cocacola? genero muchos ingresos
Sorry im not use traductor wait
No?? And what about Coca-Cola? It generates a lot of revenue.
Income generating is restrcited to privileged creators
For me, this is a plugin that generates a lot of money.
There's a plugin that generates diamond
It's called diamond mine project
I got 410 diamond and idk where that came from but I think it's the diamond plugin
(it doesnt do that)
maybe read the description before claiming there are cheat plugins
there are no cheat plugins
if you want money and city level, why are you not playing in sandbox
Okay then who gave me 410 diamond?
.
It that possible make this?
As the view zooms in, the building gradually becomes transparent, rather than suddenly disappearing.
probably not, you can make the building stay when youre zoomed in with the correct build height but not make it transparent
that wont be possible with lua or fun
unless you do some magic with 39825203853 draw calls
that just sounds like the volumetric fog plugin
you could draw a explosion animation and use the Builder to remove buildings and spawn debris
or just spawn a nuke lol
Hello dev,
How can I show a dialog when a building is fully constructed, and also when it is deleted?
Which function or callback should I use for this?
I tried using the "onClick function", but when I do that, the notification always appears and the building stats window (like hospitals, etc.) cannot be opened.
Thank you.
This my json dev 🫰🏻
you have to use lua and use the events
Plugin ap ni bg
Try make anti polution building
Could you please explain this in more detail?
I would like to understand how it works and how to trigger it properly.
I have read all the information on this website, but unfortunately it did not provide any clear instructions or guidance.
https://doc.theotown.com/modules/Script.html#Event_types
You can make the building a park type and add anti-pollution.
But this no longer works properly because the developer has fixed it, so it’s basically just decorative now.
Wow it's work man, thanks a lot 🙏🏻
Now how to show my icon?
How to make like, a thing blow up a certain moment after it's built, and play a custom sound
Nothing in documentations
use fun
:D

Alhamdulillah

Could you help me?
how do I add sound to a plugin?
Try screenshotting the file contents and the json
Could you check what I’m doing wrong?
I want the sound to play when the building is placed and when it is removed, like a notification.
Is that not how it works?
I need the file
Btw what are you make?
👍
@urban hemlock ada plugin cuan ga yah
Speak English please
No no Indonesia
Never mind, I’ve already managed to get it working for the icon.
I just have one question: is it normal that sounds in this game can’t play fully?
It keeps looping every 5 seconds.
Is this expected behavior, or should it be able to play the full sound?
I’ve already implemented it exactly as shown in the example.
Could someone help me?
who have Ren's Wilderness plugin?
Even if I change the song, it still doesn’t play fully.
Is this a limitation of the game?
help.. i need info on commercial plugin zone
Try asking in #plugin-discussion instead
whats triggering the song to play
I'm using
if bx and shouldPlay() and not song then
if CEOsong then song = City.playSound(CEOsong, bx, by, 1.0, true) end
elseif song and not shouldPlay() then
song.stop()
song = nil
end
that's... your entire code?
Cek this
This my entire code
jesus christ
what exactly are you trying to achieve
First I think that is a song code ?
Play fully song on building, if impossible I'll give up
Exactly
Is that hard lua
?
what does "play song on building" mean
something like ambient sound from the building?
Exactly That's on my mind
@torpid spear Please check this video.
The original music is 2–3 minutes long, but it keeps looping every 4–5 seconds.
Does that make sense?
you need to keep track of whether the sound is already playing otherwise it just restarts
also the logic you copied from the sample plugin is partially wrong
So what exactly should I do? Could you point out what needs to be changed or fixed in my script?
This is actually keeping me up at night 😵
Where i can see this ?
Got it, thanks.
So the issue is that playSound is being called repeatedly without checking whether the sound is already playing, right?
I’ll try adding a state flag and test it.
don't take it as a perfect solution, but maybe you could try playing the sound on construction complete and city load instead of every day
I'm not sure about moving/deleting the building though
I'm unfamiliar with how the playsound function works
That makes sense , thanks for the suggestion.
I wanted to try this because I don’t see many plugins exploring this idea, so I’ll experiment with the approach you mentioned and see how it behaves.
Especially among plugins in my local Indonesian community, or maybe I just haven’t seen many yet since I’m still new here 😅
Btw, after trying it last night using event_place, event_finish, and other events (day, month, & year), City.playSound only plays the song for about 4–5 seconds. Even when not looping, it’s still the same.
I’ve decided to stop this project for now. This might simply be a limitation of the game.
Thank you everyone for taking the time to answer my questions. Much appreciated.
Di antara ku dan sawit di antara ku dan sawit
Super easy
Teach me lua
guys hwo you guys can program plugin with lua even tho you can only upload it by json and images?
the json can mention a lua file that will be run
the json defines the building and lua can do extra things
So Json makes the building and lua adds🤔 some fun stuff?
I dont think kulche particularly likes lua, but he also like torturing himself with new lua experiments every now and then
In the name of fun
I wish theotown used a less unhinged language for plugins
but at least lua is pretty flexible and easy to learn
Sometimes I wish the game supported Java too, so plugins could be more flexible and fun haha.
Oh that would not end well
Imagine all the chances of it being malicious
Someone had in the past figured out how to make a malicious plugin
Java would probably make it so much easier
Oh, I didn’t know about that. If there’s already a history of malicious plugins, then it’s probably safer to avoid that idea.
True, Java could make it easier to access user identities or abuse devices.
I was thinking it might be safer if Java plugins were restricted to the creator only and not shared publicly, but even then it could still pose a security risk to the game.
Never mind that idea.
Please post your city in #city-showcase , this is not related to any plugins
Hello, is there a script that gets called when the settings panel is closed? Like script:leaveSettings or something similar.

You may want to look at stage enter and leave events
Thanks
what kind of animation
Animation that is adjusted according to random frame, so if a random frame of certain set of wall colors is selected, the animation will automatically be adjusted so it has the same set of wall colors with the selected random frame
thats doable but couldnt you do that with regular animations
My lua doesnt work
Was trying to randomise my animation frames when placed
My json worked fine before I made the lua file
I dont know why it crashes loading the template
Guess ill throw in he log file as well
I dont know what the issue is, I even added an object for the lua
What the hell is "Ě"? Did you really put that on your code?
what is oncreate???????????
your indices have to start from 1, not 0
Can someone give me a code example of random animations using lua?
it's easier to just have a bunch of identical frames and attach a different animation to each frame
Ask chat gpt 😭
Its like I understand any of that
Can I pretty please have the code you used
Clearly not, is sent my json and script here
you'd use script event and then check if the event is placed (or whatever event you want to use)
Damn.
But how?
How do you attach an animation to a frame?
But I want a certain frame in the animation to be selected randomly than painstakingly code everything manually
yeah, and I gave you a solution to that...
Or do you mean to use fun instead?
Hi, somebody. I come here for know where server to download rock and grass decal. Sorry my English so bad.
I spend 5hours for searching that decal on forum. But didnt find it, a friend said it was only on discord.
Not here
is this true?
it told me that doesnt make sense but anyway my json doesnt even reach the script before it crashes. It crashes at the template of all things and I cant figure out why. It tells me I have a trailing comma at price but like what?
guess send me the plugin
theres a misplaced comma or } somewhere
id need to see the whole thing
vscode should point it out too
There isnt, vsc showed 0 errors
Can you show me an example, i don't think you can just put anim index in the frame attribute directly
"animation":[{"id":"id", "frame": index}]
or
"animation":[{"id":"id", "frames": [index 1, index 2, ...]}]
But I'm still curious how did they make random roofs like this?
Erionit? He makes a lot of roofs and a lot of buildings and then uses json animations to make building variations
I am very sure he doesnt use lua
but that’s the european buildings expansion by lobby
and it is the case that every time you place one of those buildings, the roof and colour get randomised
i will kill you
Thats not very nice kulche
the plugin does, in fact, use lua and animations
Ive seen his files though
I remember going through the json
But I assume that your European pack
it sure is
It's easy if you use Lua
Kulche, since you're the one who also made the European tenement pack (besides Lobby), can you teach me how to do these random roofs, or can you just give me the code?
you can either set animation's transparency to 0, or use an animation with speed 0 and an extra empty frame that you can switch to
Can you explain it more?
no, because there's nothing left to explain
if you have any specific questions I'll answer them
I'd advise against dabbling in lua if you have no prior experience in plugin creation
So, do you just use math.random for generating random roofs in European tenements plugin, or do you tweak it further to increase randomness?
I tried setAnimationFrame where i use math.random, but the animation didn't generate randomly
I used the code from this
#plugin-lua-and-fun message
And adjust it to my own plugin
And it didn't generate randomly
Already try math.random as frame but it still didn't work
That code is non functional whatsover
my guy, did you really use code from a message that says "my lua doesnt work"
what did you expect
Can you just give me the code that you use in the European tenement plugin to randomize roofs?
Ppunish 667407171859775499
Hi Dev, where can I find the complete list of language IDs used in the game?
I checked the Lua documentation, but it seems incomplete. It only shows default [de] German and [fr] French.
which language are you doing?
this is the tutorial on inline translations
I’m planning to add a few more languages, maybe around 10 major ones, based on the countries where most players are from.
Oh, this is exactly what I was looking for, and it turns out it’s already in the GitHub repository. Thank you so much
Can someone tell me how to get all the coordinates of a specific building by draft?
as in you want to find all the instances of a select building and get their positions?
Can i use countBuildings ([draft]) as index in getBuilding?
that's the intended use
Sir, where can I find the complete list of available icon enums in the game? For example, all Icon constants such as Icon.CITY, Icon.RESIDENTIAL, Icon.EDUCATION, etc.
use the assets plugin from lobby
I believe it was called plugin creator tools or something
Thank you very much, sir
What is the ideal size for a thumbnail?
Sir, would making a plugin like this break any rules?
I noticed the weather control feature only exists in the vanilla version of the game.
If it’s not allowed, that’s totally fine, I’ll just keep it for myself and won’t publish it 😄
Considering the vanilla weather thing costs diamonds, this would be unfair to the game as it doesnt have any negative consequences. So it wouldnt be allowed.
Also no idea why you always ping kulche, he will answer even if you dont when hes available
Oh, that’s my mistake, I probably mentioned him accidentally. Sorry about that.
Yes, I was thinking the same, it might be a bit unfair. But what if I set a high diamond price for it in the store, since it adds some extra features? Would that still not be allowed?
I’m just curious, that’s why I experimented with making a plugin like this.
Well for that you would have to ask the dev
You can reach out to him on lobby@theotown.com or through forum dms
Usually for any features ikey that you acquire permissions for from lobby since its related yo monetization
Can someone help me?
I want the toast to appear right after the building finishes but it didn't
function script:init()
local house = Draft.getDraft("$coalition_mapping.decoration.2026-02-06-23:25:29.64")
end
function script:event(x,y,level,event,source)
if event == Script.EVENT_FINISHED then
Debug.toast("thanks for building "..house:getTitle())
end
end
house is declared as a local variable inside script:init(), so it’s not accessible in script:event().
Move the variable outside the function (script scope) so the event can use it.
who knows how to make it like this
the plugin creator tools code could provide some insights
I have reviewed it but not very helpful😭
when json i relax, but when lua i surrender🥲
if you don't have experience with lua, I'd recommend starting with something simpler
wait wait what are you doing here?
Yes, it seems like it's also an easy thing, but indeed information about Lua scripting in Theotown is not yet massive.
..whatever that means?
I mean there are still not many tutorials about Lua
for theotown
u feel me?
no, what kind of a tutorial do you expect
most functions are documented
I've just taken a look, the plugin is in fact all you need https://forum.theotown.com/viewtopic.php?t=12183
the bottom fragments of the code are probably the most important
hmm I reviewed it yesterday, but it didn't refer to what I wanted, but never mind I'll try it again
@torpid spear wow, thanks its work
congratulations
Can i set an animation inside another animation using lua?
Why would you want to do that exactly?
For efficiency, of course
Random animation
random animations? what do you need an animation inside an animation for that?
So i don't have to write much code in JSON for a consistent anim for each floor
So each floor is an anim and has an anim inside it for consistency
By the way, thank you for the suggestion. I’ve already received permission from the lobby 🫰🏻
Thanks you so much @zinc isle
amazing, good luck!
So, Can i set an animation inside another animation using lua?
Now I have one major problem left, I absolutely can’t draw at all 😭
Would it be okay if I use the sample assets?
Yeah you just have to credit theo and lobby
Of course, I’ll credit them. Thank you so much!
How does draft:setFrame(frameIndex,frame) work?
Since frame is an int, if i set it to 2, does it take the second frame in the specified draft?
it sets the buildings frame to the specified index
although frame is a number you should only use numbers you got from a getFrame call
if you set it to 2, youll set it to the 2nd frame ever loaded by the game
and who knows what that is
or it might crash, who knows?
should I make a transpiler for javascript -> lua?
I do have alot of experience in both so it wouldn't be hard
plus I've made python -> other language compilers too
why does nobody does nothing here
you have to wait for someone who has knowledge of this
ohk
sure
Most contributors focus more on visual design than Lua or feature development, so technical topics don’t always get much attention. That’s probably why discussions like this can take a bit longer to get responses.
i simply dont need it
and i dont think a transpiler would handle the intricacies of metatables properly
complex industry works just fine without it
and yea of all the scripts CI has the gui ones are by far the longest
it's made for simpler plugins with simple logic
perhaps I could make the transpiler advanced
or potentially loca ai powerd or using my frnd's online ai powered transpiler
only downside it'll be unreasonable large for a plugin
it's for those who know javascript but also want to do theotown plugin scripting, context switching from a language to another (unless python -> lua) is always a pain since you are already adapted to do In a language
I'm gonna make for more languages, just not those like c, c++, java etc
i dont see the application since lua is very easy to adapt to if you know javascript or python
it would need to be able to handle script event functiond well at the least
The game can do with json 90% if what most people want to do
Theres very few people that actually know how to use theotown lua
there's bugs in the current version (v1.2) but script event works quite decently
JavaScript is roughly 100x more popular than Lua globally,. so making a JS→Lua compiler could make TheoTown plugin dev more accessible to more devs
one of the problems of this is context switching
I don't think thats happening
theres only like 30 poeple actually doing scripting
I do think that's happening
that's the 2nd reason I'm making this transpiler forr
It’s not about mass migration. It’s about lowering the entry barrier for people who already know JS and are interested in Theotown plugin dev
Im not going to argue with you but im just saying that the probability of that happening is close to none
well were not going to stop you
Can i use Draft:getContent() for other draft types?
nope, data type drafts only
youll need to use the other get functions for other properties
So, is there a way to count animations inside a building draft?
doesnt seem like it, you could ask lobby about it on the forum
Hello sir, may I release this topic plugin on the store?
This plugin allows players to write their own custom topics, and it will not interfere with the game’s default topics, as the chance of appearing is very low.
If this is allowed, what would be a reasonable diamond price? 👀
Sounds cool actually. I would be willing to bet a normal price of 30 also works for this.
Okay, thank you, @zinc isle 💜
this is one of the things I don't know how I didn't live without
What do you mean?
i mean that i didnt knew it was a nessessity for me :)
Thank you!, It is fully built with Lua.
Halo
Is it possible to change the game’s day/night cycle and in-game clock using Lua,
or is it limited by the engine?
The documentation only exposes getTime, not setTime.
yea thats not possible
you used to be able to change a users settings but that may not work anymore
if you want to force only day or night
Understood. Thank you.
Do Tile and Building libraries be use during enterCity?
i think there's a bug using Tile.getBuilding(x,y) always returning nil value on version 1.12.61a
i can confirm this happens to me too
@potent jolt any way to make finishInformationDialog not display the default building info panel
no I'm not waiting for a response from anybody else
you literally return false 
and it wont open
wait finishInformationDialog?
i mean
at that point, its already finished
why not use script:click
doesn't change anything
let me refer to complex industry
yea no it is script:click you want
function script:click(x, y)
local building = Tile.getBuilding(x, y)
if building:isInConstruction() then
return true
end
x, y = building:getXY()
local id = City.hash(x, y)
local export = IndustriBuilding.getById(id)
if not export then
error(string.format('User clicked on a export building with id %d but it is not registered.', id))
end
---@cast export export
ExportGui.showExportDialog(draft, export)
return false
end
just returning false will prevent the default dialog from opening
alternatively you can just wipe the contents of the dialog in finishInformationDialog
oh yeah that works fine, thanks
any ideas if I can automatically open a building info panel via lua without reconstructing it manually?
aka the dialog from when you click a building in the build bar
I can't find anything in the docs about that
oh that panel? yea no idea
guess it's time to dm ja
you could try dumping the gui structure while that menu is open and check what its made out of
sounds like effort
indeed
indescribable how much i love the word indeed
Ppunish 784062770256543744
quick question, how do i update the "tool" title realtime while using it?
its probably a label with a certain id, youd just need to find the id
you're right nice..
Anyway, is there an event listener that triggers when a GUI is deleted? something like an onDelete event for a target GUI?
i dont know if gui tables are read only or not
but if they are not
you can get the onDelete function and overwrite it with one that calls the original ondelete at the end
Sir, I want to ask, when I try to open the video, nothing happens. Is something wrong, or does it require a privileged key or something else?
i dont know how this works, but i am certain privilege is required
Oh, got it. No wonder nothing happened. I already tried changing the whole script and JSON, but it still didn’t work. Thank you, sir.
i want to share my plugin codes, but there are undocumented function and method.
Can someone tell me, how do i check if an animation in certain slot (for example, 10th animation) even exist in the first place, using Lua?
@zinc isle apologize for pinging
Im working on lua script and shader stuff
I had a question, if possible, could future updates allow setting custom #define values from lua side before shader compilation?
(im using translator, sorry for my bad grammar)
have you looked into using https://doc.theotown.com/modules/Drawing.html#setUniform
Yes, I’ve seen that documentation before. Currently it only allows setting uniforms, but not #define directives.
If I use a uniform (for example a float used as a boolean flag) to enable or disable certain shader effects
uniform float enable_waving_trees;
if (enable_waving_trees == 1.0) {
...
}
it would still require branching in the shader.
That means the code may still run even when the feature is disabled, which can be less efficient
But if using #define would allow the shader to exclude that code path entirely at compile time
#define ENABLE_WAVING_TREES // enabled
// #define ENABLE_WAVING_TREES // disabled
#ifdef ENABLE_WAVING_TREES
...
#endif
Yes, it can be toggled using Lua. Maybe this example can help.
But I'm curious why you want to use #define for the waving trees if you plan to enable it again later.
In Lua, you can't rewrite or remove code from inside the game, so changing a uniform value is usually the only way to toggle the feature at runtime.
then it is not possible
setUniform is better for runtime toggling, especially for adjusting values like multipliers (like waving speed or color grading values).
But for heavy features like clouds or water shader, using #define is more efficient than if-else branching. Even if the branch is false, the GPU may still evaluate parts of it.
With #ifdef, the code is completely stripped at compile time, so there’s zero cost when disabled, which improves performance and reduces unnecessary computations.
It also helps avoid maintaining multiple shader variants (like lite/low/medium/high), since I can control features through compile-time flags instead.
You’re right about #define being more efficient in general.
But in TheoTown Lua we don’t have access to shader compilation or preprocessor, only uniforms at runtime.
https://doc.theotown.com/topics/00-intro.md.html
why not make it first and then see if the performance is ok
premature optimisation is usually a bad idea
plugins/tx-terminal-exchange/scripts/station_assigning.lua:365 vm error: java.lang.NullPointerException: Attempt to invoke virtual method 'char[] java.lang.String.toCharArray()' on a null object reference
stack traceback:
plugins/tx-terminal-exchange/scripts/station_assigning.lua:365: in function <plugins/tx-terminal-exchange/scripts/station_assigning.lua:361>
Is this a bug?
the error occurs when a building has no custom name. function works correctly once the building is manually renamed.
it should return nil when the building has no name (or is using the default name). However, instead, it triggers a NullPointerException
probably related to tile.getBuilding not working, try it outside of the beta branch
how can i rollback with playstore
Rollback in what sense?
time to pick up the pen again
Also wait in confused do I use json or lua I read the tut on how to create plugins
Press the link for a more comprehensive guide for plugin creation for beginners
The key points are summarised below:
Step 1: Download a baseplate of your choice It is recommended to keep it small if you are just starting.
Step 2: Download a pixel drawing app. It is recommended that you get one with layers and transparency options. You can find a list of suggested options here
Step 3: Here is a tutorial on how to make a house by Kulche
And tips on how to improve plugin quality from rtobby
Find more tutorials in the getting started page and on the forum
And even more tips pinned in plugin discussion
Step 4: Last step is to create a json. You can create one by using PCA or use this tutorial to make one. To make one manually, use any text app which allows you to save files as a .json
Feel free to ask for help or suggestions on the forum or on the server
Bonus step: Once done, you can upload your plugin on the store which once approved can be downloaded in-game by anyone or post it on the forum showcase or both! Remember that store plugins must oblige to the store rules
That's it?
Wait if lua is limited what's the point of using it instead of json
limited slot?
Edited
I mean in September I used to code lua
okay?
Like what
I'm assuming the API is like a translator from one coding language to another right?
Not literally
please just read the link
Ty I understood everything
cant believe I opened the channel for several seconds and a scambot popped up out of nowhere
do we have custom filter for specific drafts using TheoTown.setToolFilter?
undocumented functions! yipeee!!
how refreshing
Wow interesting
He knows I think
This for you sir @weak mural
there's EVENT_PLACED, but can I somehow differentiate whether a building was built by the user, or automatically by the game (as rci)?
It should be possible. The only difference lies in the “Untouchable” building. When it’s enabled, the building is placed by the user, when it’s disabled, the building is generated automatically by the game. Is that what you mean?
But in cases like this, I believe that distinguishing between manually placed buildings and those generated automatically through zoning (RCI) can be handled by checking is.Untouchable in Lua. I suspect that privileged access may be required, although I’m not entirely certain since I haven’t been able to test it myself.
as i said, that doesnt work
a building placed by the user doesnt have to be untouchable
Hmm, I didn’t know that. Thanks for the clarification.
?
What the
Ban them please
@zinc isle
i like your plugins
okay im glad but this is lua support
ok
So guys about road decorations fun, can I set the condition to road usage to check whether there's something on that tile, then make the road decorations switch to another image?
In what line specifically?
-# loud warning
Are you reacting to my questions or, to different people?, cause if I answer it then it's not reacting to my questions it'll be very embarrassing
Nyawit ni orang
I'm trying to figure out my lua issue
Would need to see the log or the source code, it probably happened in a gui callback or something
It loses the line number sometimes
Pmodmenu 1374764571323138059
Pmodmenu 1374708137961197569
cheers
Cheer
Derived from ian` 's code
Looks like freakin complicated logic
im pretty sure drafts need to be gotten in script:init and you cant get them outside of it
otherwise the code runs before all drafts are loaded
Question, say I use the same logic to that barrier to detect the train to change the state of a road deco I place on the train track, does that work?
im not sure, its not how ive wouldve written something like this
But the logic is the same no?
yea looks like it
Does anyone have the Discord link for Yakka plugin center?
😭
Join the server in his bio @digital kindle
I deleted the server,merged with kri.
Can anyone share the Rays Overlay plugin like this? Please 🙏
KRI server at plugin creator share channel
How to use require()?
Have a question, do fun have a condition Index for the time of day, and the weather conditions?
You'd check weatherTime variable against a constant value defined here:
https://forum.theotown.com/viewtopic.php?t=5959
Thanks
But that's for controlling it no?, what I'm curious about is whether I can set up the fun attributes to detect the current time or weather
For example, this building will have animation playing when there's rain, or when it's in the middle of the day
https://forum.theotown.com/viewtopic.php?f=81&t=5903
Last sentence:
You can also read from these virtual variables.
Now I get it thanks
how to write a click fun that change the specific frames of roads?
or change the total graphics of it or turn it into another id?
To change it to a different ID, you'd need to demolish and build a new road. There is an action for frame changing, not sure what you want to accomplish.
I just wanna change one of 64 graphics of a road id when click it. forum's tutorial doesn't have how to make it. so I think it may need to change another id that with graphic i wanna
I'm pretty sure changing the road frame will also change its connection status, unless that's what you intend.
I think so. that way doesn't work so I may find another method.
and is it possible to replace the existed road id to another one by click fun? could you show an example or a tutorial?
return to this question, if I though a method by road decos, how to make it change graphics when click it?
Something like this?
yeah, that's I wanna
https://forum.theotown.com/viewtopic.php?p=152001&hilit=Slow+traffic#p152001, That's basically what you want
thanks~
try privileges
This has nothing to do with lua
Is this right?
‘’"meta": {"tags":
{"elevated_train_station"{}},
{"elevated_train_platform": {}}
},’’
Mmm... No, cuz "station" is a thing and "platform" is other thing... You can put:
"meta" :{"tags" :
"elevated_train_platform": {},
"elevated_train_station": {}
},
But is as say "Tea with Tea"...
The difference between "Station" and "Platform" is:
-
Station: Is for open the Transport Panel (This depends of the System mentioned, for example "elevated_train_station" that is for open the Transport Panel of Elevated Train).
-
Platform: Is for extended or mark the build as part of the station... If you put a "Platform" without a "Station", the platform is just other build, but with the "Station" close this work in conjunction
So it's click on fun, it's just adding another one instead of removing the other and replacing it, did I miss something?
Thanks
Did I mess up somewhere?
what eerror are you getting/
This
Not an error per se, just it didn't remove the other and replacing it
You probably have multiple road decor on in settings
Soooo, nothing I can do?
turn off your multiple road decore
"exclusive":true?
Bmp?
BitMaP......
