#plugin-lua-and-fun
1 messages ยท Page 4 of 1
I reloaded the game so its supposed to be loaded
only if I leave the 2nd line though
iconDraft is probably nil
that's why it crashes
Where do you run it in?
As in, under what script event
it was out of all functions as in examples, I moved it into a function (that gets activated when you click a sidebar button) but it still doesnt work
Are you sure $sim_nationstates_icons is defined
You could Debug.toast the iconDraft value
and see what it returns
should be (if you mean in the json), I reloaded the game and it didnt throw an error
reloaded as in restarted?
yes
then it should work
slap a
"strict lua": true
in your script json object
this will make it immediately crash when an exception is encountered
rather than doing that silently
now it shows nil
that means that draft is undefined at that moment in time
because I moved the toast, was dumb and put it after .getdraft which causes the exception
why could it be if the id is right and draft is defined in json
I tried both one defined by string in lua file and one in json
btw Draft.append(iconImage) seems to cause an exception too
I didnt enable strict lua yet
you should do that first
so this isnt reliable?
it does not give you details on why it fails if it crashes
you'd have to read the log.txt in this instance
oh wait strict lua gives details?
it immediately shows the error in your face rather than silently logging it in log.txt file
According to that error, Draft.append cannot be called outside of init methods
trading
the draft append and merge should be placed outside any script functions, e.g. init, earlyInit, lateInit, and so on. you can put under require function if you use modules or even the first line of your script.
and call Draft functions, e.g. getDraft, inside the script functions. when the scripts initialization, any plugin drafts are not loaded yet. and you will get the nil draft.
after the read line, the draft append and merge are just an abstract function. after the blue line, all drafts are loaded properly.
HELL YES
almost working
these icons are kinda weird
also maybe I should make them smaller
well coal doesnt look too bad
I dont like iron ore, its weird
even though I took a real picture as reference
also I should fix the outline in some places
looks better
@torpid spear sorry for pinging but I think you know the answer best out of people here
does the game have some "standart" icon size? (or sizes for different types of icons)
they seem to just vary from 20x20 to like 26x26
complex industry uses 26x26 for the icons
the sidebar doesnt quite fit that size though
my icons are 24x24 for now
I hate this so much\
it doesnt even show what happened in the logs
after I reload the game it works fine but after any change it disappears unless I reload it again
this makes me want to kill people
kill
this happens because of Draft.append(iconImage)
which I put outside of script functions
as I was supposed to
tried loading from json again but it doesnt work anywhere
apparently thats what you use when you write json code inside lua
seems pretty impractical to me
yes icons should be 26x26
at least it almost worked
well it did
I forgot why it even broke
idk what am I doing
i geuss thats better than mine rn
do your icons work?
fixing a script is probably easier or at least not as frustrating as figuring out how tf do icons work
can you tell me how do you deal with icons?
idk what the issue is
works fine on my machine
i just load them on startup and put them in a table
similar to the game
{
"id": "$industri_gui_icons",
"type": "animation",
"frames": [
{ "bmp": "icons/industry_icon.png" },
{ "bmp": "icons/port_icon.png" },
{ "bmp": "icons/wood_industry_icon.png" },
{ "bmp": "icons/warehouse_icon.png" },
{ "bmp": "icons/import_icon.png" },
{ "bmp": "icons/export_icon.png" },
{ "bmp": "icons/industry_info.png" },
//problem icons
{ "bmp": "icons/warehouse_full.png" },
{ "bmp": "icons/warehouse_problem_icon.png" },
{ "bmp": "icons/input_empty.png" },
{ "bmp": "icons/output_full.png" },
{ "bmp": "icons/industry_problem_icon.png" },
//other icons
{ "bmp": "icons/resource_switch.png"}
],
"meta": {
"names": [
"INDUSTRY",
"PORT",
"WOOD",
"WAREHOUSE",
"IMPORT",
"EXPORT",
"INDUSTRY_INFO",
"WAREHOUSE_FULL",
"NO_RESOURCE_SELECTED",
"INPUT_EMPTY",
"OUTPUT_FULL",
"SUPPLY_NOT_MET",
"SWITCH_RESOURCE"
]
}
},
draft looks like this
then i just Industri.ICONS.IMPORT
pls define on startup
outside of all functions?
some script function?
or when city loads?
script:init for me
i get the draft, then put the frames in a table
function Industri.earlyInit()
-- load icons
local draft = Draft.getDraft(draftId)
local meta = draft:getMeta()
for index, name in pairs(meta.names) do
Industri.ICONS[name] = draft:getFrame(index)
end
end
earlyInit i suppose, but that doesnt matter
its a simplified version of the actual code
doesnt work
oh wait
I put another id
to see if it loads
fixed the id, still doesnt work
you could put them into a listbox to start
easier for dynamic amounts of resource types
provides easier way of boxing each resource
idk the common term in english, just googled
in russian they're called colored metals
I wont have complex industry levels of complexity but you will be able to produce some goods
and sell them
I will also add "consumer goods" which will be surplus from vanilla industry
okay these seem to be different things
maybe youre thinking of noble metals
nah, non-ferrous
maybe I could add both non-ferrous and rare metals
rare metals for most advanced stuff
if youre gonna have production buildings like complex industry oh boy
the complex in complex industry also refers to the codebase
it will be much simpler
also most of industry building will be out of the player managed city
it'll be just clicking a button to construct an abstract factory somewhere else
because the plugin is about countries
yea that simplifies things
you will be able to build factories in your city too, but it'll still be simple
just 1 building
Now I need to "reset" a listbox
to change a button when you click on it
idk the best way to do it so I'll just make the onclick function delete the listbox and generate it again
this functionality probably wont be needed in final version anyway
an issue is that it makes it scroll all the way back up but its not a big issue
(right now there isnt any room to scroll down anyway)
that's amazing
my rock collection
since when was oil a rock ๐ค

I wanted to add diamonds but I cant come up with an use for them
maybe sell to your rich population for extra money
gonna start implementing abstract buildings
I thought that players will only be able to build in cities (you'll be able to found them on any tile) which are also abstract
but then you'll have to make cities almost everywhere
so I'll make it just need at least 1 city within 2 tiles
if I make it like 3 or 4 tiles, and make cities very expensive it'll create an interesting mechanic where you have to plan city placement to cover as much resources as you can
I wont even try making logistics
so resource storage will just be global (country wide)
and independent from buildings
but buildings just affect how much can you store
Unbelievable low quality plugin
i like the icon
Literally making the military industrial complex
I want to have rockets and planes at least
Maybe land warfare but this means I have to code pathfinding
I kind of want to add bricks or concrete as resource
But it feels weird to have them separately
Maybe it's a good idea to add some combined "building material" resource representing bricks, concrete, stone, asphalt, etc.
Which will be used with steel to construct most buildings
now you're looking sharp
idk I'll fix that now
industry buildings in the city consume a bit of timber
but if there is no timber nothing will happen
I dont think I can make random industrial buildings get abandoned
more balancing, also made amount of forest on tile count
gonna make sawmills produce a bit less wood
for context this is my horrible testing city
of 150k people
I'm gonna give management buildings in my plugin an actual use
I will have political power unit like in hoi4
which will be used for some decisions
you will be able to get more of it by building a management building in your city
Yo what plugin is this
It's not finished
I mean, this channel is usually used for taking about progress on unfinished plugins
But it'll be called nationstates mod or something
wow simon implementing a whole ass system
Oh ok
Cool system tho, so i will be dowloading it when it finished
new resources (except the one in the middle)
building materials, plastic, non-ferrous metals (old), rare earth elements, uranium
man, how much i need to wait for this Warsaw Radio Mast plugin
oh right I should finish it
I feel lazy rn but I just need to add the cables
I'll do it at some point
Wth someone still makes an incredible mod like AoS
how's aos doing btw? I know its likely not being developed anymore but is there a playable public version at least
Yeah it is. I have it
the great and proud country of gm_vanillastruct
๐ซก
For now treasury is just the tax from your main city
I want to start adding random things but I have to do important features first
It is right
So it will be just the more detailed version of Theotown or the thematic mod?
Well the goal is to have a wider world with countries
With which you can trade or wage war
So it mostly spices up gameplay and adds more stuff to manage
I'll also come up with more mechanics affecting the city building part
E.g. your city will have its own resource map, and potentially it has more resources than any other region of your country
This isn't very realistic but it encourages developing your city and establishing camps for surveying resources
And gives purpose to building stuff like oil pump sites
I'd say a feature of nuking other countries will already make people download it
hey give me some credit, i work on complex industry sometimes
complex industry
beautiful
Complex industry pro max
Meh it looks interesting. So when you want to finish this masterpiece?(i guess)
honestly no idea
especially since I have some other coding projects im switching between periodically
yeah it'll probably be the second major lua mod after aos
I dont know any other ones
well, and complex industry
but ci is unfinished
So good luck
finally added save&load
now my world doesnt get erased every time I reload the script
i think you making smth like CI
I thought there was a script:nextWeek but turns out I was wrong
I guess this will do
nextDay for updating everything seems too fast and nextMonth is too slow
wait this isnt c
thats probably not how I only count the 7th day
nvm it works
settled a tile
I suspect that for some reasons saves can break
but maybe its just because of me changing the code
my solution was to just wipe the plugins city storage and then rebuild it
whats a weird looking crop
have you ever seen a grain
i dont think it looks like that ๐ฅบ
its wheat but tortured by horribly low resolution and me not knowing how to draw it
the artstly doesn't look very theotowny
simon can smash them together :)
hes very good
basically early gameplay is
- Set up a sawmill to start getting good amounts of wood
- Build a timber storage to store wood
- Build farms and grain silos, less necessary than other steps but grain is needed for rural population to grow, and more population means more taxes
- Build a granite quarry (needs timber)
- Build an iron mine (needs timber and granite)
- Build a coal mine (needs timber, granite and iron)
- Build copper mine (needs same as coal)
- Build steel factory (needs granite, iron and copper, consumes iron)
- Build construction material factory (needs granite and steel, then consumes granite, steel and copper)
then more advanced thingamabobs follow I guess
rocket industry when
I think I'll add rockets if I get into that stage of development actually
(spy satellites)
to detect rocket launches n stuff
(if I get to that stage of development too)
this is advances, i love it
I should make categories for my building tab
half of this is implemented, gonna start working on the other half
also population consumes a bit of wood and wheat
but you can actually produce a tiny bit of wheat by building real farms in your city
how should I call the category of crop & timber related buildings
I guess I'll call it renewable resources for now
added steel mill, testing now
damn, I dont have coal on my territory... I guess its time to EXPAND
there is a minor inconvenience with a bug that prevents me from expanding vertically but im too lazy to fix it and reopen the city
thankfully I found a tiny coal deposit
I forgot to make copper generate and when I fix it the savegame will break ๐
now thats a real minor inconvenience
at least for now the gameplay process is fast
but before release I'll slow it down by making everything slower and more expensive
since otherwise you wont have time to actually manage your city, and will finish setting up everything in your country before your main city becomes big
actually it doesnt break, but tiles are already generated and dont have copper so same outcome
it works
I didnt even have to conquer a single tile for this
OP
but I will fix

Why the developers doesn't make similar stuff for the updates
probably because tt is not a rts?
I'd rather take on making rts myself, so devs can finally make the transport update
I don't know what is "rts" but i know his mod looks awesome
Your plugin reminds me of worker ans resources lol
added a basic energy system
๐ฆ ๐ฆ ๐ฆ ๐ฆ
American states
only most of them
Yes
ok gonna turn this into usa battle royale temporarily
Tell me which state wins
I'll just change the placeholder names, I didnt add war yet
but I'm gonna start implementing basic ai, so they'll at least build stuff and settle nearby tiles
Cooool
And Russian Komi
(had to fix a lot of bugs on the way) Now they build sawmills
and once they have enough timber, they build storages for it
Player is my favorite state
well technically countries expand now
but I have no idea why are they doing it this way
nvm figured it out
if I said how I truly feel about lua, I'd get demoted for breaking server's record of excessive swearing
real
rn they expand, build sawmills, timber storages and farms
wtf is new mexico up to
omg they are growing???
thats so cool
on mobile this will probably be only playable with a smaller map with less countries
but it'll probably be absolutely playable with a map 2 or 3 times smaller
(in fact I think I made it too big anyway)
now countries can reach the stage of getting oil
worth noting that they have infinite money for now tho
looks nice
saves properly, (size of stg.nations is right), loads 0
thats after reloading the game
@potent jolt do you have experience with saving and loading tables, how to do this properly?
oops attached the same screenshot twice
storage itself seems to be working
as long as you got the reference from a table out of storage itll update it storage correctly
okay now it works
but simple values like numbers and strings must be set directly in storage
better to use tables
map is a 2 dimensional array (table)
you should nest all your storage in a dedicated table
for your plugin
that way you dont accidentally have a number that doesnt get saved
local stg = getStorage()
return Util.optStorage(TheoTown.getStorage(), script:getDraft():getId())
end```
function I totally didnt steal
yea basically
I use this already
pretty much how ci does it
-- Gets the industri storage table from gamewide storage.
---@return table storage The gamewide industri storage table.
---@nodiscard
function Industri.getStorage()
return Util.optStorage(TheoTown.getStorage(), Industri.INDUSTRY_ID, {})
end
-- Gets the industri storage table from city storage.
---@return table storage The city industri storage table.
---@nodiscard
function Industri.getCityStorage()
return Util.optStorage(City.getStorage(), Industri.INDUSTRY_ID, {})
end
then whats the problem in my script
why dont nations load normally
or map
whatever
my load function clears nations array and then loads it from the save
but for some reason nothing changes
how does it do that
i dont have dedicated save functions
i just work on references to the storage directly
as long as the table was retrieved from storage itll always update in storage
then local stg = getStorage()
val = stg.val
honestly idk how am i supposed to do this
and I dont know why
nations = stg.nations ```
doesnt do anything
youre assigning an empty table to nations
then overwriting it with a referencr to stg.nations
which is nil
youll have to initialise stg.nations first
so
stg.nations = stg.nations or {}
nations = stg.nations
if you edit nations after that point it will save automagically
you could use util.opstorage to simplify those 2 lines too
stg.nations = Util.opStorage(stg, 'nations', {})
becausr thats really all the function does
so it copies reference, not value?
I hate lua
save:
stg.nations = nations```
load (called when you enter city):
local stg = getStorage()
stg.nations = stg.nations or {}
nations = stg.nations
after I click save, wait, and click load nothing changes (it should)
or when I reload the game it doesnt load anything either
I thought it just copies values
and they are independent
yea tables copy references
dedicated save function is not needed
should I do smth like nations = stg.nations somewhere in the beginning of the code or what
when city loads
and dont use save or load?
or just replace every mention of nations with stg.nations
which if tables copy references would be the same thing
tried it, also the opposite, still doesnt work
I may be stupid
i got
function IndustriBuilding.enterCity()
Industri.debugLog('IndustriBuilding module enterCity')
-- get all buildings from storage
IndustriBuilding.buildings = Collection.new(Util.optStorage(Industri.getCityStorage(), 'buildings', {}))
for _, building in pairs(IndustriBuilding.buildings) do
setmetatable(building, IndustriBuilding.meta)
end
end
function IndustriBuilding.exitCity()
IndustriBuilding.buildings = nil
end
and it just works
i just work on the buildings table
this is in a module, but it should work for you
dont mind the Collection.new, thats a wrapper class i wrote for tables
i dont think i even use it
what does it do? load some kind of buildings and loads&assigns their information to them when you enter the game?
I'll try figuring out save/load tomorrow
the only important part is that it just fetches a table from storage and assigns it locally
from there i can manipulate it however i want
the exitcity isnt even needed
the whole setmetatable thing is cuz i wanted to pretend its object oriented
id have to see more of the code to know what youre doing wrong
Don't want to deal with saves for now so I'll do something else
im gonna take a 3-4 day break because I have another unrelated project I promised someone I'll work on
hi, I need to code my plugin, I donโt know how since Iโm doing it for the first time
you can start by checking the guides on the forum
๐
stop spamming and use proper channels, thanks
some sprites for nationstates plugin
Cool
looks like PCB
What's PCB
Do you think your plugin could have multiplayer functionalities? It would enhance the interactions between players a lot if so, and would be pretty usefull for roleplay
theotown doesnt offer any ability to do this
Yeah, sadly true
Although resource sharing is already in game
So it could work like that
There is even ways to share the money of two cities, so maybe at least resource sharing could work
Not sure I can code that in, especially for online regions
Still how far is the plugin from release?
Pretty far
K
Still, it would be funny if for the npc nations names you used the names of the nations of the reddit rp community
why is this? I'm new to creating plugins, please help
You have two of the same ids
Remove one or rename it
Could someone tell me how to alter a tool plugin's title in the building tool(Pic. 1) without changing its title in the toolbar(Pic. 2) programmatically in Lua?
"title":
It will also change its title in the toolbar.
theres no way around it
also you should use #plugin-discussion ad lua is a different coding language
So, how does this plugin(Terrain Tool++) implement it? It has a mutable elevation counter in the title.
who made it ian?
not possible if you are not in TPC. you only can obtain the tool name with City.getToolName, but can't change it.
maybe lobby should add City.setToolName.
what plugin ๐ฏ
the one hes still working on....
no i mean
nationstate plugin??
yes a war ish plugin
theres resources and trading between imaginery cities
it all really sounds cool and simon is doing an amazing job
did he has a server or something
i do love to see the developtment
not that i know of, he posts them here
I don't have a server for it
Is there some guide or documentation for creating plugins?
in #plugin-discussion yes
they are pinned there
print ('hello i will steal your food')
this isn't a channel to mess around and if you keep it up you will simply get warned
thanks
Ppunish 480662509096009739
kaijuno.87980 was banned for the following reason: Sharing or spreading scams or phishing content.
I hope I'll have more free time and motivation to work on nationstates plugin in late december
(I haven't forgotten about it)
would this kind of building look good in theotown?
The contours on the house in this game are strange to be honest
i dont understand sir
This is an example of a building that you are going to introduce into the game, is the sprite ready?Because it confused me a little
This is nothing, I just made the design. because I want to know first whether this style is suitable for the game
Ahh I'm very sorry sir, I don't know, I'm new here
How can I edit the GUI โโthat appears when I click on a drafted building?
if you want to replace the dialog entirely, use https://doc.theotown.com/modules/Script.html#script:click and return false
okay so
now it kinda works, just not the way its intended to
it doesnt stop after animation has ended and both animations run at the same time
Asking something for the Lua pro experts:
- Would it be possible to make a plugin centered on ski resorts that relies on a system of "tickets" to provide income? Essentially, a share of your population + a number of "tourists" (who need hotels to sleep in) would generate income based on the number of ski slopes and lifts that you have.
- Reaching a certain treshold of tourists / skiers would unlock new facilities.
I am currently trying to see if modding a ski resort mod would be possible, essentially a new "free dlc" centered around giving an additional income.
you very much could
Okay thanks Kulche!
I think there are even some inbuilt lua functions for adding a custom 'currency' like tickets
its very much possible but it will not be easy
also earncurrency and spendcurrency require privilege
its probably easier to just manage the currency yourself
Which I got so thatโs good
I dont think on tap fun is working as intended
I press and it does nothing. Very anti climatic
should I post the code of my atmosphere shader?
with ids changed because I think thats how people do it usually
maybe it could help some people with understanding glsl
but also maybe anyone who cares about it will just read the tutorial
have you seen the tutorial lol.
all i saw was a lot of math
Yeah that's how shaders are
Although the atmosphere shader isn't too complicated
https://doc.theotown.com/ - Lua api
https://forum.theotown.com/viewtopic.php?t=12185 - GUI compendium forum post
https://forum.theotown.com/viewtopic.php?t=16838 - Forum GLSL shader tutorial
a reason why im not really interested with shader. lol
I thought i wanted to make a shader, until I saw the tutorial and didnt
I guess then im the only one working with them lol
although I havent made any shaders in a while
especially complex ones
I wish there was a postprocessing shader
where I can work with the whole screen and not separate sprites
shader monopoly
Their conversation actually got me to look into shaders for love2d
I think I'm going to use a fragment shader to improve rendering performance for my falling sand game
compute shaders exist
outside of theotown though
and I have no idea how to make them
(yeah ik 3 days passed)
Helo
maybe he wanted to ask a question about lua, or fun even
it's ian's Brazilian alt account
unreal
Lmao
lol
im prefer make japanese alt account
Is it normal some fun function not work properly on IOS?
what do you mean "not work properly"
Where to get this ?
The TNT plugin for example
It cannot detect activated firework wires
Only on IOS
this is how to fix your issue.
ian i need this railway platform which works as bus station
isnt it there?
Are these acc hacked
yeah they are
also i would do setting up routes as with Bus depot
but this will be on train depot
Sorry, what does lua even mean?
Its a programming language which you can use to implement complicated features in your plugin.
Ouh i see, thx for the explanation. ๐
Can someone help me with my code?
Its giving errors for no reason
Oh wait wrong place sorry
ip stealer
Ping
I have a problem with the vanilla plugin mainfest
From the pickle
As i didint have a problem before importing it
that's not lua
also how are we supposed to help if you didn't even say what's wrong
Well
When you download the one from the pickle
It comes set with the stuff you need to put it into the plugin to have a mainfest
But
When i did that
This appears
manifest files must be called Plugin.manifest
Thank you
Ppunish 983497746772295703
:+
Hello, does anyone have the code that is set when a building does not have a floor?
โdraw groundโ: true, //this will make your building donโt have floor
note: remove the comma when you wanna put it on the last line
Thanks
should be good, but wrong channel
A sry
Can i redact or create a json file, using lua?
yes
this isnt the place for that
Hnn
Soo can we make plugin for the leftovers of a destroyed building?
Dont like the dirt blob we have rn
I want a bit of destroyed structure
At leasr
If we can make it then great!
how is this lua related
Dang :(
You can specify the destruction attribute with an ID
It will replace the destroyed building
the building of the specified ID must have to be 1x1 or match the size of the building thats being destroyed
Ouh i know its official name now
Scraps
Yea i dont like the texture. I want to make plugins that bring the building leftover atmosphere
Like an actually destroyed city like in ww2
Scrap as hell WHY DOES FIRE HAPPEN TO ME
i mentioned RESIDENCIAL COMMERCIAL AND INDUSTRY
You sure this is the right channel?
This channel we can talk about animation too right?
no
Wow so cool
i know lua from roblox ๐ฟ
ok?
Hi. Srbios. Rename and remove .json
with all due respect that was almost 3 months ago
Aprilfools
Ppunish 1174724196807491685
apeng0803 was banned for the following reason: Sharing or spreading scams or phishing content.
Unless you are searching for soething specific, here the lua forum https://forum.theotown.com/viewforum.php?f=115
theres a reason programming is a job
Never give up ๐ค
Perhaps i should just stick to JSON untill i really need lua
why would you use lua when you can use json?
because fun sucks?
That's the attitude never give up ๐ค
I check a little and hell it is more understandable than lua
Yep im really thinking things weirdly
more understandable until you try to make anything statefull
Please ๐ฅบ explain me?
What you mean with statefull?
Example please ๐ฅบ
probably meant something like meaningful
tapping a building and the buiding remembering how many times you tapped it
Wait talking about that, what if make 100 frames for 100 taps, of a building
For whatever reason it could be a thing piling up like gold
๐ค
was that a question
More like a tought ๐
Lmfao
What happened to you with fun?
Most complicated theotown related coding ever
you dont want to know
also it just didndt work
Bluds traumatized
they way i wanted
๐ณ
i have it as a lua file but its sitting to be released with new buildings this december ig
fun is deginitely not fun
apparently fun works faster than lua and its all json but fun ๐ฉ
The fun be like
Expectation Reality
Fun ๐ ๐
You didn't fun ๐ ๐
Hahaha ๐๐
I have a problem, I need your help. Is there any way I can tell if a building is present on the screen? I really need it.
yes, like this
Still waiting :3
that's basically what I did before fun variables were added
that's how the Theos worked if you guys even remember that plugin
I tried to make a plugin that would give you info about a building you're looking at, but could never get it to work with the elevated terrain. So that might pose an issue to you if you try to make something like that
But im not sure what lua functions are available to you guys these days, so maybe that's easier to figure out now
It might be more understandable on the surface, but lua and fun actually do similar things when you take a closer look
In fact, much of the fun stuff is simpler to do in lua. It just takes a little bit to figure out how to type everything if you've never programmed before
Lua is a very forgiving language though, so there's really no better place to learn how to code than with lua
ye it do similar thing
but now when i try to learn, i realise for what i must learn these? i dont make weird mechanics
Can I play the sound only once/turn off (stop) the sound?
*custom sound
**custom sound, played by lua
I think we can, but i dont do that
Can I track whether this sound is playing now?
I can only tell you it can be done, I cant tell you how, I do not know
Not cool
Due to my inexperience with programming, I would like to ask what is the most effective way to check tiles? Like how I wanted to make from #plugin-discussion how can I check all the tiles of residential zone on all map?
doing this would be very inefficient
why do you want to check them
maybe we can find a method that doesnt require doing that
Whether zone on sand tile
for what purpose
Doesn't matter yet
Can we access an object by its index?
If yes then I have an idea
It would be possible to enter all the residential areas on the map into a large array once, and then check each object in turn, assigning it a variable depending on its location. This way we can check all zones only once. Then all that remains is to compare the number of elements in the array.
matters, a lot
if you cant program you cant tell me if it matters
your solution is incredibly slow and what if the user builds new areas
you can attach a script to the residential zone draft that will check for the EVENT_PLACED event
then check the underlying terrain
Can i get x y with this thing?
So, any suggestions?
Yes, by the way, it is written there that periodically the array of the number of buildings will be checked, if it is not equal to zero, all operations are repeated
yes
Cool, but how i saw, it requires x y
a script would look something like this ```lua
local attached = false
function script:init()
if not attached then
local name = script:getName()
local residentialDraft = Draft.getDraft('residential zone id')
script:addScript(name, residentialDraft)
attached = true
end
end
function script:event(x, y, _, event)
if event == Script.EVENT_PLACED then
-- a residential tile has been build, now we can do other things
end
end
do not blindly copy this, i have not tested it and ive never used addScript
What if the city already had zones that met the condition when the plugin was turned off?
we can run through those on entering the city
What if the map was already built before purchasing the plugin?
on entering the city
then use script:event for times that they are placed while inside the city
As I understand it, this script only tracks the option to build new zones. What if the zones were already in the city?
Well youre going to have to restart the game and enter the city
use script:enterCity
and check the tiles
but only then
this is already a bad idea, this will make entering cities pretty slow on phones
yes
but you may want to reconsider the whole thing
it could end up too slow to release
Would comparing <300 tiles really tax the CPU THAT much?
<300?
what about a built up giant city
thats going to have thousands of them
you can make a naive solution first reading all the tiles every time
and later add a system to store the tiles in city storage
i reccomend you just start trying things
consider a city that is very big, 1024 tiles in length and 1024 in width
you would have to check
Pjsk py 1024*1024
1048576
tiles
You might have to chunk that sort of thing with coroutines to avoid causing so much lag, but that's a pretty advanced topic tbh
Maybe you could attach a script to the zone for a single frame when the city loads that gets all their positions and then remove it afterward
But I'm not sure if that's possible in the game since I've never attached scripts either
i would do the collection process once, save it between reloads and use events to register new zoning
Well the issue with that is when the user uninstalls the plugin between saves
Then if they reinstall it later the data will be stale
So you would need a way to overcome that
A refresh button might do, but it would be better to automate that somehow so the user doesn't have to manually refresh it
Or maybe you can somehow track when the map was last saved and compare it to when the data was last saved. If the plugin data is older then you can recount the tiles
thats a case where i call it good enough
the worst case is that sometimes, when reinstalling the plugin multiple times it will leave some tiles unchecked
alternatively we ignore existing tiles entirely and only check newly placed ones
this way a user won't be griefed by unknowingly getting his entire city's zoning replaced
the time to collecting the tiles from the 512x512 map with coroutine. 
actually i want to share about the coroutine, but the advanced thing is to make the process run safely since you need to call coroutine.resume for each frames.
What do you mean about running it safely?
the coroutine will produce the "dead" coroutine and it will give you the infinity errors if there is a fail to clean/stop the coroutine.
or at least the fps will drop because of it.
Ah, I see
Hehehe
Draft.getDraft('id')?
Oh thanks
Hi to all! I'm a new member here and I need help to create a plugin for TheoTown game in lua because I don't understand this topic, can you help? Plugin description: when building, for example, a school, the happiness of the inhabitants of the education increases by 50
you can't modify happiness with lua
Pity. Are there other ways to change happiness?
provide the actual influences
Which TheoTown system features can I work with in lua? That is, those system functions that the developers themselves added when creating the game.
Thank you.
Would be cool if this was officially established as the main channel for talking about glsl
but nobody does that for now
shaders make my brain hurt
you gotta complete Warsaw Radio Mast plugin
Is possible make something similar to the military rocket launcher in LUA ๐ฅบ
Just asking please ๐ฅบ
why ask him specifically? theres a couple more people around that knows lua
Because he's a pro
everyone who provides actual lua help is profiecient in it
like erk, ian, ja and kulche!
yes
Thank you ๐
any ideas if I can append multiple lua script files to a single draft?
can't find anything anywhere
Is it possible to write random fires in lua? And as?
random fires?
that's a pretty vague description of what you're trying to accomplish
Here is a detailed description of what I want: I want some building to catch fire at a random time, it should also be random. P.S. I hope you understood what I want.
yes it is possible, but can't you just enable fires in the random disasters menu?
So only: a meteorite, a flood, a tornado, an earthquake, a nuclear weapon and a UFO and there is no accidental fire.
hm they must've removed it at some point then
well, depending on your implementation you'd probably just select a random building/tile every once in a while and just set it on fire
doesn't sound particularly difficult
Well, what will you do? But I don't know how to do it.
what will I do?
not much, best I can do is give you links to the resources
have a look around
Thank you.
I'm not really sure what to make of that

youre in the wrong channel, youre probably looking for #plugin-discussion
Ahh...
Sorry
up
Cool
It's not a library, but some code that is mistakenly being generated a documentation module for
is this plugin just called terrainx?
nope๏ผit hasn't be named
ohh
Cool
Cliff? Hmm
Finally,the cliff plugin.
Is that an actual cliff? Can you build on it?
actually
Man that's awesome! Incredible job ๐
This will revolutionize
Minecraft ร Theotown
Real
Also another question, what are those lines on the floor?
area plugin
JSON?
Is possible to make something like the DSA moon colonization with LUA?
yes
In which programming language you made those?
Where to download?
maybe it's already removed from store? but you may find it in forum
Yep removed,but once i was able to download it on the creator server.
That's pretty sick
You have in your website all your plugins?
Or more in servers?
Kingtut seems like a familiar name
Oh yea hes a youtuber lol
Im subscribed even before i went here st the server
No
I worked on a city building game called cytopia for a couple years as the lead artist, but the devs abandoned the project
That's
They planned to add military just asking ๐ฅบ?
This is what I'm working on rn:
https://kingtut-10101.itch.io/just-another-sand-game-sequel
To cytopia? Probably not
We never had plans for that afaik
Not that it matters anyway. The game isn't going to be finished
Youre welcome!
I dont think it is out yet, keep an eye on #plugin-showcase for when it gets released
oh thank you
Some silly things that one does to test the GUI
This man made the snake game in theotown, this is funny
what plugin is this, it looks fun
Its not a plugin rn, he was messing with lua
I also did a test with Space Invaders
For now I have no intention of making an arcade plugin, they are simply tests of GUI and FPS, to check the performance and how much movement I can put in without overloading the game
wow, thats really impressive man
Nice use of the map size sprites lmao
you can do a ton as long as you dont use too many draw calls
the real performance impact is really just how many TT calls you make
Hey, this might be a dumb question, but my brain is fried today. Is there a way to resize an icon?
Sir,you might post it in the incorrect channel.
ow sorry
You can do that in the debug menu,but also consider if the plugin didn't hide the id.
I'm leaving this lua game for TT here in case anyone wants to experiment with the GUI.
I understand that having a "Tetrix" in TheoTown might seem unusual, but it's simply code for those who want to explore the GUI, conditionals, saving functionality, etc.
Good luck!
//Clarification: The code was only tested on PC, so on the phone you might see smaller UI and larger text. The code is not fully optimized to be a plugin, but rather serves as a guide. Any further improvements will depend on each person.
Damn cool
Hello where can I get stairs plugin
Wrong place to ask that, try asking in #plugin-discussion and be a little more specific about which stairs you are referring to...
Is there a way to change the Setting Dialog Title? (plugins/clouds/cloud.json)
this would be a great minigame for a special building
try to create a plugin manifest.
There is already one, is a specific tag?
no, maybe it depends on the file type, because .plugin and .mpf files have different names.
Got it, it means that if its uploaded to the plugin store it would show it correctly, thx mate
is there a way to make a postprocessing shader?
so it's applied to the whole screen and not individual textures
To continue the conversation about Shaders, there are some usage examples with setUniform (Lua) in the src, and how is it defined in the json? as type Data? Script?
Some small change
Need explanation to this error
So i could repair it myself
For now i'll have to delete this
Fun, no monthly income yay
Nevermind, it requires elevated privelleges
If you do not provide the code, we cannot help
@trim remnant
Pmodmenu @shrewd fable
reinuto772 was banned for the following reason: Sharing or spreading scams or phishing content.
Thanks
Like 20$ to 50$?
5 bucks is 5 bucks
Hey! Is there a way to use the setBuildingIcon without the default red icon? Thx
I mean wouldn't it be easier to just use the drawing module
unless you want all the fancy features like icon merging
True, ngl was just for testing jajaja
Na, it is not necessary, since only one "taxi trip" is possible at a time, thx
nope
Thx, in any case it works spectacularly, I'm about to change the icon to one that looks good with that red background, since doing it with the drawing module gives me pain having to use 10 more lines of code with setTile and drawImage, to just 1 line of setBuildingIcon.
Drawing.setTile(tileX, tileY, ((32 * buildingWidth) - frameWidth) / 2, -50)
Drawing.drawImage(frame)```
Yes, yes, it works perfectly, the "problem" (just laziness), is that doing with that module also requires adjusting Y based on the height of the building and that's practically doing more code for the same function, but that works too.
In any case if I see that when I decide to publish it in the plugin store and it would look better with the other one, I change it, so everything stays with the vanilla icons.
In any case I know that Kulche will come and tell me "Skill issue"๐
Btw, the Cars module is quite fun, I don't understand why there are so few plugins that use it ๐
you can understand because there are so few creators that use lua. maybe less than 10 or 20 persons. 
setbuildingicon also requires you to clear the icon when it needs to be removed
so its not entirely less work
Its just a nil, I do it automatically with onCarReached
In any case what you have in 0dump_ is enough for about 100 plugins, freedom for Lua. 
It seems like Lua plugins aren't nearly as popular as building plugins too
function script.Builder.buildBuilding( draft, x, y, frame)
Would this lua code work if i put it into a plugin?
Wdym? I don't get it
youll have to make a seperate lua file as your script
then use the script event functions
Demonstrate me ๐ฅบ
I don't think anyone's got the time or will to explain the entirety of lua scripting to you
did you read the tutorial and follow the steps
I read some of it
You read all the Lua API documentation in 2 hours? You are a beast and the fastest person in the world, I have 2 months reading that and I still haven't finished everything.
No, i read like a portion of it
Oh. I realised i am reading in the wrong direction
https://doc.theotown.com/topics/00-intro.md.html
Better not to fool yourself, start with the introduction, it is quite simple and gives you examples.
Exactly where i done wrong, thx for the correct place for read
lol
I need the buildings to allign basically, and to some extent maybe colours as well
once you've figured the basics out feel free to ping if you want to learn how the road alignment script works (it's shrimple)

