#plugin-lua-and-fun
1 messages ยท Page 9 of 1
I'll draw soon
But I am not really sure
So it will be better to just understand placing stuff
How to use onInit function with GUIs?
that exists?
well if it does
you can do lua GUI.createDialog{ onInit = function() Debug.toast('initialized!') end }
I'm not sure what the point of this is though
As you can just run the code after creating it
How to stored and retrieve 2 D array values from Theo/City Storage?
-- retrieve or create the 2d array
storage = Util.optStorage(TheoTown.getStorage(), '$pluginId', {})
storage.array = storage.array or {}
now you have to create the 2d part by inserting tables into the array
you can create rows by lua array[xvalue] = {} array[xvalue][yvalue] = value
im not sure this is a great idea though
maybe investigate vectors to see if they serve the purpose you want
May i ask if i will come out retrieving the same table values from Resources to resources1 with these code?
Oh it seems like i forgot to use "k" What should i do for it?
use Array:add(value, index) if you want to make it as array.
Resources and resources1 will be 2 tables with the same values in them
Since you don't insert with they keys they'll be ordered 0, 1 2 etc
The order might get messed up like that
I think this will work now
Why not use city name as the key?
I will make a connection table with different user's city
I think if user change the name of the city the table will be duplicated
But yeah thisll work
True
You'd have to update it on city exit
Or somewhere else
Still clueless but on my thought , if user change the city name it will store again on that and if matches any key I'll make a function to remove the old values
use city id
Oh that's why Ive never heard of that function before
used for pseudo-randomness
Well in this case that's exactly what's neede isn't it
what are those for?
title id and text id are localisations I think
template is some premade parameters I guess
and I don't know about texture
but may be hill texture
oh okay
funky
these chinese names are good
because
for me they don't make sense just like real chinese names
I spent too much time on this.... but at least it's more advanced than stacking random letters
a template is a draft type that exists only to be inherited
you can have some preset values
and put them in many drafts using templates
I think I wont need those
erksmit rate my ultra realistic chinese names @potent jolt
generation result but all of them are based on Azpilicuetagaraycosaroyarenberecolarrea
@potent jolt wants edge frames but there arent edge frames on the game codes tho
ยฏ_(ใ)_/ยฏ
edge frames are defined by the template
Can anybody would like to help me about formula
Krabby patty formula? No way
what formula?
Nvm btw what's the lua version of theotown has? i need 5.3 to use floor division
math formula? lol
Does these will work?
local v = v//50
Sad
print(math.floor(5/2))
genius

What's the Gui id of these two?
no id
Ohh since it doesn't have id how can i get if user uses right sidebar tool?
probably by using GUI:getRoot and getChildren, etc ...
No i mean is there any boolean function to check whether user checked the right sidebar tool from settings
Have you tried experimenting with lobby's GUI tool?
Go to lua scripting it's well explained that there
I wanted to get GUI like this
It's better to know how to compose GUI though
Erksmit suggested to use dialogs and that seemed nice
But you need to create templates
Erksmit gave me a layout but I'm dumb and I decided to figure it out soon
I wish I could just use coordinates
I thought you used something else for GUI, that's why I was so curious
local function panel()
local dialog = GUI.createDialog{
width = 180,
height = 200,
icon = Icon.OK,
title = 'TITLE',
pause = true,
onInit = function() end,
onClose = function() end
}
local layout = dialog.content:addLayout{vertical = true, spacing = 2}
local theme = dialog.content:addCanvas{
onDraw=function(self,x,y,w,h)
Drawing.setAlpha(1.0)
Drawing.setColor(145, 129, 116)
Drawing.drawNinePatch(NinePatch.PANEL,x,y,w,h)
Drawing.reset()
end
}
local function addText(txt,height)
local line = layout:addLayout{height = height}
line:addLabel{text = txt, w = 60}
return line:addLayout{ x = 62}
end
local txt = addText('test',-30)
local btn = addText('',-30)
btn:getFirstPart():addButton{
icon = Icon.Ok,
text='i am a button',
w = 30,onClick= function() end
}
btn:getLastPart():addButton{
icon = Icon.Ok,
text = 'button also',
w = 30
}
end
Try not the exact you wanted but i hope you figure it out
Okay thanks I'll try
@elfin geyser https://en.wikipedia.org/wiki/Lamplighter
what about this
Already has
I mean like this; soo there is a lamplighter house and it spawn people in black suits once it is near night time. They pass lights and light them up once they reach them
hmmm gonna seek if there's a function what car id pass on that tile
Btw
I remember there were car related functions
How do they work?
I'm thinking of using them soon and Yusuf had some hard time with them
there is target reached
but are your light fences?
I just stole this
I think I asked you guys about it too
but nobody knew because they didn't experienced it
also asked ja how he did rocket supply thing but he didnt respond, or I am remembering wrong
There's a something called City.carReach? Something like that dunno
i think in spawnCar() you should put the neighborhood tile of the building where it would spawn?
I am kinda remembering I tried that too
I also tried it with adding car spawner to json and without it but I am bad at lua soo it is better if you test them
I'll try now
Well car scripts are hard I guess
not hard, just difficult
@weak mural you tried it?
almost all functions. lol
I think this gonna be need than using City.getBuilding()
btw is ian bearbear on forum?
oh wow
no, why i need 2 accounts? lol
I never heard about him anymore
same
became a Gentoo user
sad that bearbear isn't active anymore
Just analyze the spawn() function
so
it spawns them daily
but
you put the building's x y and not the road's x y
is that true? I kinda forgot lua
Yes
but why it didnt work for me tho
๐
oh you used city spawn car different and not like me
I think it's a bug to store the draft in variables than calling it directly inside the parameters
so you say I should have get the drafts inside the scripts?
My script isn't not in anybuilding type on in type:script
no
no
it needs building
Thank god
roads might be dumb actually
It would be painful
yep
dumb road
I want to make something more complex and gameplay related in theotown
Like something industrial
Or solar swarm idea I mentioned
I have no idea of what to do except some industry
Btw Yusuf
Are you going to finish complex industri?
I started the industrial revolution on theotown
y is that
maybe yes and the target from car draft. i think so.
Hope it's not necessary
Because it's weird to have car spawner in building if it's going to use Lua car functions anyway
build a huge industrial area is the simplest way to do that. 
maybe for a truck or something that can take or drop some stuff to another building.
steel mill ๐
I made a function for you, remember that here in my code, it depends on spawner count how car reach its targeted building
local targetCoordinates = {}
local spawnCoordinates = {}
local function collectLocation()
local targetX,targetY,spawnX,spawnY
if City.countBuildings(Draft.getDraft(targetDRAFT)) then
for i=1, City.countBuildings(targetDRAFT) do
targetX,targetY = City.getBuilding(i,Draft.getDraft(targetDRAFT))
targetCoordinates[i] = {x = targetX, y = targetY}
end
end
if City.countBuildings(Draft.getDraft(spawnDRAFT)) then
for i=1, City.countBuildings(Draft.getDraft(targetDRAFT)) do
spawnX,spawnY = City.getBuilding(i,Draft.getDraft(spawnDRAFT))
spawnCoordinates[i] = {x = spawnX, y = spawnY}
end
end
end
local function spawnCar(targetTable,spawnTable)
for i = 1, #spawnTable do
City.spawnCar(Draft.getDraft(carDRAFT),spawnTable[i].x,spawnTable[i].y,targetTable[i].x,targetTable[i].y)
end
end
function script:nextMonth()
collectLocation()
spawnCar(targetCoordinates,spawnCoordinates)
end
local stuffOnFirstBuilding = 10
local stuffOnSecondBuilding = 0
local truckCapacity = 5
function script:event(_,_,_,event)
if event == Script.EVENT_CAR_SPAWNED then
stuffOnFirstBuilding = stuffOnFirstBuilding - truckCapacity
elseif event == Script.EVENT_CAR_REACHED then
stuffOnSecondBuilding = stuffOnSecondBuilding + truckCapacity
end
end
This code should be clipped on building drafts i guess
I don't know if global variables are accurate since it can be duplicate by other script with the same variable naming
city storage or building storage.
@weak mural have you tried lua with data base?
Hm this looks interesting
You need to put it in building code or...?
Sorry if being very dumb
o soo a transportation storage
i think yes, but with the TT database, not my own.
building with a car spawner.
Oh okay
I thought when using car code like that, you usually use car spawning script too
actually, not yet. lol
Gonna ask, does other script can access and retrieve values from plugin storage using their draft in Util.optStorage(TheoTown.getStorage(), [target draft to retrieve values there])?
Yes
Storage is shared between plugins
That's why we usually use the id for the storage key
--Script 1
function save()
stg = TheoStorage()
stg.var = 60
end
--Script 2
function storage()
return Util.optStorage(TheoTown.getStorage(), 'Script-1-DraftID')
end
function save()
stg = storage()
stg.var = 90
end
Do they work like this?
If they share the same id for getting storage the values will be shared
I've used it for my camera plugin
The values can also be change depending on how other script declared it?
Yes
Whether 60 or 90 will be saved is dependent on which script ran last
Which is kinda arbitrary and can't be ensured
I need to use this just to transfer and trigger events
thats a good application for it
Thanks for the respond, really helpful
Ah one more thing does ** Draft.getDrafts()** also return drafts of GUI's?
[
{
"id": "$city_cemetery_zones+",
"type": "zone",
"frames": [
{
"bmp": "city_factory_tile.png"
}
],
"width": 1,
"height": 1,
"author": "Cerrera",
"placeable": true,
"base": "$zoneindustrial",
"rci": true,
"price": 100,
"needs road": false,
"category": "$cat_zone00",
"separator": false,
"ordinal": 7,
"draw ground": true,
"title": "City Factories",
"text": "Ever wanted a clean industry area? There it is... It just makes noise and it will fit your city sides. There isn't any smoking factories in this zone",
"preview frames": [
{
"bmp": "city_factory_icon.png"
}
]
},
{
"id":"$deco_city_factories_zones+",
"type":"body disposal",
"influence body disposal":200,
"auto build":true,
"need road":false,
"influence park":100,
"provide aspect body disposal":10,
"privileged":"lol",
"price":0,
"monthly price":0,
"build time":0,
"performance":true,
"width":1,
"height":1,
"frames":[
{"x":1536,"y":48,"w":32,"h":16,"count":3},
{"x":1696,"y":96,"w":32,"h":16},
{"x":2016,"y":48,"w":32,"h":16},
{"x":1632,"y":144,"w":32,"h":16,"count":2},
{"x":1760,"y":160,"w":32,"h":16,"count":2},
{"x":1728,"y":240,"w":32,"h":16},
{"x":1920,"y":224,"w":32,"h":16},
{"x":1536,"y":512,"w":32,"h":16,"count":3},
{"x":1824,"y":512,"w":32,"h":16},
{"x":1856,"y":608,"w":32,"h":16},
{"x":768,"y":0,"w":32,"h":16,"count":3,"offset x":1024},
{"x":768,"y":16,"w":32,"h":21,"count":2,"offset x":1024},
{"x":512,"y":256,"w":32,"h":16,"count":2,"offset x":1024}
],
"meta":{
"tags":{
"body disposal":{
"zones":["$city_cemetery_zones+"]
}
}
}
}
]
Experiment
I just want to make cemetery zones
this isnt the right plugin to use codes for it
imo
you should look up kingtut's garbage zone plugin
zones+ is an rci zone plugin
Thanks
no problem
so ill have to use a canvas and draw text on that instead of just adding a label
well whatever works
Hello everyone. I'm making a decoration for the road. I found the code on the forum, but I do not understand what is responsible for what. There is an animation item here. Is there any animation in the decorations?
{"id":"$anim_roaddeco_sample00_00","type":"animation","frames":[{"bmp":"frames.png","x":0,"w":32,"handle y":8}]},
{"id":"$anim_roaddeco_sample00_01","type":"animation","frames":[{"bmp":"frames.png","x":32,"w":32,"handle y":8}]},
{"id":"$anim_roaddeco_sample00_02","type":"animation","frames":[{"bmp":"frames.png","x":64,"w":32,"handle y":8}]},
{"id":"$anim_roaddeco_sample00_03","type":"animation","frames":[{"bmp":"frames.png","x":96,"w":32,"handle y":8}]}
use Runtime.postpone
to run a function at a later time
you can basically call those endlessly without too much consequence
Miliseconds?
I think there isnt a timer code or something ๐ why coding things like that
Also we need tables to save the latest ms value, right?
Why do we need to calculate miliseconds ๐
Just multiply by 1000
So 5 seconds 5000 and I want to have like 10 minutes. Thats 10x60x1000?
And it is a big number, I am wondering if we can store postpone numbers
hm
A player might not even sit in his city that long
Aa
For long durations
You should track the durations yourself so you can save them when the player exits the city
But if we have a store system for i- nevermind you are true
You can use runtime.gettime to accurately tell the passed time
Or os.time if you want less accurate
Things getting more complicated. I think like what you said will use postpone with small values or daily functions
No need to store anything and make things harder for a small thing like this
Daily sounds like something for script:daily
You want your things to depend on in game time no?
Yeah in game time
Daily seems soo limiting tho, I want every thing to have their own times, soo it will allow creativity and combinations
The downside of postpone is that you have no control after running it
For exmaple
If you run it and the user exits the city
The function Will still get ran
Huh
I expected the quit, function stop and reset but didnt know it continues if player leaves city
Cant we make this function to get connected to city enter exit functions?
I dont really know how to make two functions interact with each other tho, dont even know if it is possible
Postpone works everywhere
You have to keep track of what's changed
Like
If you have a big postpone
A user could switch cities
And it will continue in his other city
You'll have to check whether it's all correct when the function runs
Isnt there an easy way for timers?
a line that works in city enter function and works literally timer
Not until you invent it
Well duh
๐
Thats true
Well I think postpone only needs to know if it is in a city or not
This is what I understand
You can make a function to check that
Well
You also have to check if it's the same city
Using city id
I also thought about this whike we were talking but I think it wont really be that bad if we wont. Because postpones are going to reset arent they?
Postpone does not reset
Ah shi
Postpone runs a function after a set amount of time
Regarless of what happens in the meantime
Unless the game exits
What a cruel function
The rest is up to you
Not really cruel
It's generic
Useful for everything
But needs work to work for a specific application
If it was city only I'd complain about it for my plugin that needs it outside cities
Talking about city id, it will just look if it is a different city right? Then there is this problem. Player exits city and waits at region menu, script continues and player enters the same city. Is this a problem?
Basically
You give the function the current city id
Then when the function eventually runs
You compare it to the new city id
If they match it's the same city
If not it's a different one
You should do that after checking if you're in a city in the first place
Okay thanks for help
Also do you know who are adding those lua codes, Is it only lobby?
Because with a little hope I will still suggest timers
@open arch what do you want to do with timer?
Tell me context in DMS, please
Maybe there is another solution...
Or in le server
Yes
Why not convert a certain number of materials per day
Soo like a material comes out after three days instead daily?
I should read things correct, I see. Thats a good idea. And soo we can make calculations for needed cars per new product?
Well I'm just looking at cities skylines
Soo steel; 16 coke, 8 iron and 4 limestone. Coke oven creates 6 carts a day, iron port creates 8 trucks a day and limestone port creates 6 etc etc
Where the industries have fairly high volumes of products
You should probably have ratios though
yeah, thats what I tried to say
Balancing such thing like this is hard
I think I will talk with danek too if he has an idea
my CAS was playing sounds without cords, idk
but I think it won't work with several buildings
otherwise it's probably fine
try it
wait it's on entercity
I thought it would create a mess if I call it too many times
it was already like that at start. It is a landmark building
ik I'm joking
but I think the sound will play when you enter the city and then end
and all
there is a loop for it
oh I thought it was default true
experimenting sounds for factory
AoS doesn't have any sound FX : (
@elfin geyser find 3 or 4 seconds loop medieval sounds from freesounds websites
Gonna try at the last phase before releasing
I am wasting my hours trying to make 4 seconds of sound on my potato pc, this is hella super slow. Pain
You can add some script to your buildings to play them occasionally
soo several 4sn sound clips that plays randomly?
I gues
As long as it's subtle
Unlike some other noise making plugin I have
Looking at ja's party house
Works just fine
But that's just 1 house
I can't say for like 30 factories
Maybe it's a bad idea
And just use custom on click noises
I am going to put a radio effect on sealand, it is also 1 time build but thought could use playsound with really low volume on factory components. Since they are factory components I can just put a really small loop of a sound
Idk what'll happen when you build say
2 clusters of factories on 2 seperate districts
Would the sound overlap?
It'd probably clip like crazy
sounds will be fitable to overlapping
And you can't have 1 sound playing instance either
I dont think overlap for factory sounds is bad, this is what exactly happens tho isnt it
We'll know when we get there
true
I have some sounds of rolling houses recorded in my local area
also tried to give it an effect like it is sounds is how it gonna sound at aerial
I cant find it ๐ nevermind I think I will make it again
Are modules need also to have draft?
Also can I store values to either TheoTown/City storage on modules?
are you talking with me or..?
@open arch 1 sec
not exactly your case
but as example this is the sound code in CAS
@random hamlet can we work with city.sound ?
I will give you the file
file of what?
Need help here
It's better not to use require
At it does not work with luawrapper
And no, you cant use hook into script functions within modules
You could make a seperate script draft and add functions to that
The is just a test I don't know why it can't find my module
Because theotowns implementation is not pure lua
And how can use that function to a new script like how modules work?
You retrieve the script attached to the draft
Then you can run its functions
That are not defined local
Any theo API to retrieve that?
**Draft.getDraft("otherDraftID"):getScripts() ** right?
Free tunnels
Free tunnels
Free tunnels
and then just grab the 1st
We have, but not with Simon's plugin
sir this is not plugin discusisson
Does this works with luaWrapper?
Imagine expending more then 400 bucks to be able to play.
yes
yes
I have no idea what this channel is about. Is this drugs?
I guess
so it errored
there wasnt errors only city play sound wasnt working otherwise toast was showing sound draft id, building id and x,y
in script update
I did copy past the same toast from update to city enter, it didnt show anything
the troll plugin
here
have you ensured all your variables are initialized?
wait my computer is lagging
what does that mean, I tried to open a new chrome tab for translate
@potent jolt I could still get the return values with this right, when using **: getScripts() **?
Gonna ask later
probably
I tried
local AOS
function script:init()
AOS = Draft.getDraft(id):getScripts()
end
And use its function
AOS.getRank()
but it says it's null
require is only need a lua script. you don't need to make a draft. but, you will have some problems without luawrapper.
The AOS is the first script
It still returns an array of all scripts
Even if there is only 1 script
It is wrapped in an array
First you get the script itself
From the array of scripts you got off getscripts
Then run the function
place playSound on update and x, y on the event script or something to prevent lagging.
Okay I will try, do you mean event building placed?
I forgor to do this ๐
he forgor
?
Only the neccesities
how to store variables value after exiting a city?
either transition variables or city/global table if you want persistence
where i can read about city table?
docs
what does it mean 'no guarantee'?
like if the game crashes the method won't be called?
or android kills the app, yes
You should probably save it on city:save
i have an issue.
i have a script which is called from such a json
"id":"$wood_industri_lua",
"type":"data",
"script":"wood.lua"
}]```
and `function script:daily(_, _, _)` doesn't work there. i tried to replace it with such code:
```-- checks for a day change
local day = City.getDay()
if day ~= current_day then
daily()
current_day = day
end```
but instead it is called every frame, despite that the same code for months works correctly
what is the cause of that problem?
erksmit said it should be in every json array..? I dont get it but I might misunderstood
in factory server
I did not say that
Did you read the documentation?
Will be called on a daily basis for every building or road that are instances of the owning draft.
This clearly says it'll be called for buildings
Which your script isnt
You should use script:nextDay
Please read the documentation carefully before labelling something as broken
For anyone wanting to apply for plugin, contributor (Builder) and influencer roles, please PM Pidroid on forums with your role request.
URL to compose a PM: https://forum.theotown.com/ucp.php?i=pm&mode=compose&u=10911
Additionally, please provide your discord username and user ID (snowflake).
You may also provide additional information which may make you more eligible for the role, such as your contributions for the game, etc.
Oke.
Mostly players just quit the game from the task manager or tabs without saving or leaving their cities
Why there's a limit number of variables in a script?
What'd you do to reach that
It toast a runtime wrapper error, of line number used more than 200 local variables
youre probably gonna have to rethink your scripts structure
likely divide it up into multiple smaller scripts
#plugin-suggestions message
@weak mural
so you know composition zone tool in plugin creator tool and the pre-build train stations
soo you make your own pre-build builds using it and it saves those in a special category
I am not sure if lua can create its own json files
so you want to build a composition without build the buildings?
lua can, but you need to restart the game to load the draft.
yes
soo you select the area you want to copy the building and it saves the composition automatically in a category. Next time you open game, you can use it
yeah, it's possible. but you can't share it as a plugin, only for the city on one device.
wdym
if you want to copy an area and save it into the composition, that's only can be used for all cities on one device.
it's like you want to the same area in many cities.
if you want to share the composition with other people, you need to build a composition draft manually.
thats true
hm
but if it already creates its own jsons for compositions, we could just hand the json file to other user but hmm
he has to use same plugins
btw, like your hill and select tool, you can make it a online useable plugin. Soo people can take compositions of other players builds
i think it will be simplest to share the composition if you use the composition tool and make it into a draft. but, if you want to use it for personal only, i can make the tool and store the id and the positions.
so you can build the same area in many cities.
wait, isnt that tool already in plugin creator tool by lobby tho?
I mean it would be nice if it creates composition automatically
it will be loaded automatically after restart. you don't need to create a draft again like pct.
premium buildings can't be used in a composition. 
Can i use a own picture as icon for buttons?
Oh soo ๐
Of course
And how?
You can get the frame from a draft and use it as an icon
[I have no idea what a draft is xD] -edit : I don't know to create one with a frame
Draft is basically a building
Or a category
The JSON you write gets turned into a draft when the game loads it
or an animation
So i create one and how i can use it as an icon ?
Using Draft.getDraft([[string id of the draft]]):getFrame(1) -- gets the first frame
You can store it on a variable or directly on GUI
Why the game doesn't support File/IO :(
loadImage or loadPng function is enough to be added.
Sounds like it would break the assumption that loaded textures never change
How can i create a automatic framechage if its winter?
theres a winter frames tag for that
And how can i trigger the frame with the tag?
I found it but my wifi bugs ... Thanks anyways
What will happen on values on plugins script that used city storage and used them online
iirc thats impossible isnt it
Let's find out
And I'm also curious myself
@light plinth is city storage table stored in the .city or not
If I transfer a .city file to another device, will it keep the city storage
How do i add my building a monthly price ๐ค
yes
o.o
@elfin geyser good news
i dont think thats too big a problem
its more of a security thing
and whos actually gonna use it
It is similar to the price. You just have to add "monthly price" : "Price in Theons"
Is there anything wrong with this?
you're missing a comma after "people": 174
I think, the indentation is all over the place ๐
What you mean by indentation?
lines 17, 18, 19 are not indented properly, but it should still work
it's probably just the missing comma at the end of line 16
I did that
But for whatever reason
The game keeps deleting the animations bit
Is there a script that could like Spond a bunch of cars like create a huge traffic jam along the highway
?
A highway*
wild guess, but should it be "animations" instead of "animation"? since it's an array
No
It keeps deleting the code
You forgot a colon in "people":164, <---- Here
but that's what I said ๐ฆ
Oh
๐
When i place my decoration there is a water under it how do i fix it
Oh okay ill try it later
We don't need to recreate custom tables

If i put script:init() on a module it will execute by the script uses that module actually without calling that function?
How to create a plugin manifest file for bundled plugins
ok thanks i will try
I wish I could enjoy all those plugins (placed in folders) in the online region
@everyone Give me json code for train or car please:)))
@vagrant flume please do not attempt to ping everyone
besides, you can look in the forums
and this channel is for plugin fun and lua
No we won't give you codes vexayse you wanted to ping everyone
there are plenty of examples on the forum
Shhh
I wanna learnnlua scripting i still dont understand it hehe
Ok
need algebra
Uh idk
How to set state for "task"(settings) using lua?
task settings?
Removed feature, seems like the setting was forgotten to be removed
Why
Because we forgot to remove it
It may remove soon?
That setting will be removed, yes
No way
Task is associated with city notifications for building stuff, and its annoying
That's not what the setting is for
What does it for?
It used to be for a feature which to sum up;
Various TheoTown in-game characters would give you tasks for which completion you'd get various rewards.
Just like wanting us to declare zones? That's likely what i mean
Speaking of Xp, setXP will actually do nothing, Game keeps on resetting the xp you had before when opening the rank tab
Shouldn't be the case, it works for me.
me too
It's like how to allocate custom road flags
But what's the purpose
Visible custom influence
Yeah, but the purpose?
Actually nothing, but im done making my defenses with radius range, so i was hoping i can make those range visible if player able to see 'em, just like how visible influence works
it might be useful with some lua functions
Custom influence can be useful if it also has lua functional for that just like how plugin settings does i guess
range sounds more like a thing youll have to make yourself
since its just within range or without with no gradient
gays how many of plugin enough to make a game with eany crashes
Using this trick
Download 1500 Plugins and you will get โ
@stoic vector ok marco i will do that
Did you make sure to use your privileged code?
Depends on your device's specs
Of course
One more thing, can i use Fun var set from lua to used as state for Fun functionality variables?
Fun variables can only store integers, make of that statement what you will
fun doesn't sound that fun to be fair
"fun", of course, is in rainbow text
What i mean is fun from lua to fun on json
should be possible
What are these attributes does?
which
Mute and mute lua?
So if I did that you wouldn't even notice I get an error every frame
Haha ass
Well here you say it doesn't log so
Can't blame me for that
Besides
I am aware of how bad of an idea having errors occur regularly is
My phone gets lags if there's an error on my script
Yeah that was my bases for determining errors
Specially script doesn't use of lua wrapper
segmentation fault: core dumped
The strict lua experience
Is it a tag?
Yes
It makes the game crash if you get a lua error
So a decent alternative to luawrapper
I haven't actually gotten any errors with it
But pretty sure it works the same as other crashes
Think you'll get the line number and stuff
Alright thanks
it's because there is nil variable in the function argument. use assert to know where the nil variable and break the script.
Just theory, Do i need other script to re-enable script that used this?
Also, based on my experience i concluded that strict lua can also detect errors on custom modules unlike luawrapper
Disabling a script means it won't run anymore so it can't reactivate itself
Or is this an edge case where you use runtime.postpone to reactivate?
Or some similar method
I'm going to release a new industrial plugin. I looked but I couldn't find the code to change the images with smoke animation and the number of workers. Could someone give me the json tip?
I would like to include night mode also in my plugins from now on. If anyone can pass a code example thank you
@chrome ginkgo it's not scripting
Btw number of workers is "people":number
Or something
Don't remember the smoke
Check on forum
Thanks

How to print values inside TheoTown.getStorage()?
with the key.
je ne fais pas de vรฉlo#7379 has been warned: off-topic.
N o
Hmm how to create listbox without borders? Just the item's canvas only
Use a custom 9patch for it?
Idk if that's an available option
I'm pretty sure there's a way to access the underlying UI elements
I tried but doesn't work, also the on draw thingy
you can make it yourself. it's easier to customize.
or that
Erksmit troled
yeah, i made it private after someone tried to steal in-game textures.
I don't think if it's possible to had custom color for buttons, if not i wish this may include soon
isn't there a frameDefault parameter?
Yeah but the color
why not provide a single pixel of color
Does this will work on theory?
What i mean about this is can i cached values to module on init, that later can be called?
yes, you can.
-- module
local module = {};
local var = 1;
module.var = 2;
function module.getVar()
return var;
end;
function module.setVar(value)
var = value;
end;
return module;```
```LUA
-- main
local module = require('module');
print(module.var);
print(module.getVar());
module.setVar(3);
print(module.getVar());```
-- output
2
1
3
Why your code has semicolons?
to skip vsc snippets. lol
How to fix? Im pretty sure i put the right path
No luawrapper?
Already fix forgot to mention :)
H
Oh hi?
Is there any function to get touch points like how "show touch point" Setting does, as of now i just used script:tap() and script:update() for this
Why u need to make ur own cursor lmao
For my self lol
Ah
can anyone teach me to do cars and make a spawner for them?
DM me
If I draw text to the screen, is there a way I can determine its width?
[ { "frames":[ { "bmp":"seoul162.png", "count":4, "h":17, "w":20 } ], "id":"$seoul16200", "influencepassengerbus":10, "speed":0.9, "type":"car", "v2":true }, { "author":"gmt2948", "carspawner":[ { "cars":[ "$seoul16200" ], "count":5, "radius":90 } ], "category":"$cat_bus00", "drawground":"true", "frames":[ { "bmp":"seoulstopb2.png" } ], "height":1, "id":"seoulBUSstopb2", "influencepassengerbus":22, "monthlyprice":600, "price":50, "text":"seoulBUSstopb2gmt2948", "title":"seoulBUSstop2", "type":"public", "width":1 } ]
How can I rotate the bus stop in four directions on this code?
It's not scripting it's #plugin-discussion
Can we rename this channel to #fun-lua-scripting
Fun n confusing lua ๐
trust me, fun is more complicated than lua.
im not reading that
there are not so many "smart" people here like you, so for now let them discuss json here
if we leave this channel only for cool and fun lua, only 1.5 people will discuss here
but this channel is for discussing about fun and about lua
I honestly don't know
Bus stops doesn't require some "privileged code" for work?
oh really?
yes thats what I said
then why not discuss lua in the #plugin-discussion
or make for json itโs own channel
and also 100+ channels
ratio
Dint ask + #general ๐
ok
wait really
okay
letโs make json channel
if you want anything changed
put in a suggestion
cuz this argument is going nowhere
Emmm.... I cant find anything in the documentation from the forum, I also cant find any tutorial or something about how to make buildings that can rotate
respec for @merry shale for the reactions
idk what that ratio thing even means ๐ฟ
#plugin-discussion for discussion in general, json too
#plugin-support for support with plugins and that includes helping with json
#plugin-lua-and-fun channel about lua and fun
This
what im saying that next time he should post json in another channel
This
its just like based, nobody knows how to use it
Lel
ohh i see now ๐ฟ
thanks you, now i understand.
good
lmao pepl here keep talking about the argument
Emmm... why the plugins need to confirm multiplayer? Shouldn't every TT version at least support multiplayer at this point?
pretty sure that function wont even exist in versions before multiplayer
I forgot to put glasses, so I misread your message
Lol
maybe has something to do with lua networking
Question
Plugins can get graphics information from other plugins?
yes
Noice
Like, height and wide, or if possible the plugin image, Im seeing if something like "Shadows, finally" is possible
you can retrieve the frame object of a building
and get their height as well
dunno about width though
im not sure how much stuff you can do with the frame object
Just getting the numbers
Im planning to draw the shadows using vectors
Idk what to do with terrain height, lul
Also, Idk how performance will go, lul
hmm
not sure how you will be able to tell between building and baseplate
it probably wouldnt run too well
but probably fine for high end phones and pc
you should be fine for performance
you can always try to optimize
like generating shadows on startup by draft
whatcha doing
Well, since I dont think I could storage the shadows in the texture image, because... no
I was imagining like drawing the shadows every frame = no FPS
Emmm...
didnt know you were a lua coder to be honest
It could just be a generic texture stretched according to the height and wide of the building, since TT graphics are pixel-art I dont think low resolution could be a issue
Im not, Im just experimenting a bit with the lua documentation
Then use the building texture as a mask to avoid the shadow being adobe the building
you cant edit graphics using it
youll have to use the drawing module to draw the shadopw
Oh I'm afraid you can't do that then
Well, Im not expecting it for work, just for experimentation and fun
i dont think itll be possible
itll be too hard to diffrentiate between a buildings baseplate and the building itself
Buildings baseplates?
Ah
Textures can be draw outside the building itself right?
Since shadows are a requirement for plugins and buildings
Like, a 4x4 building, drawing the shadows outside that 4x4 space
if you set the handle you can do that
but it might clip into other stuff
but like
if someone has a baseplate in his graphics
Emmmm, it could use the height data to handle that
Like, if behind the 4x4 building were a tall 4x4 building, the portion of the shadow that should be colliding with the building could be draw in a different direction
For know where the building is, it could verify if there is a building in the shadow path
I don't think this is possible to do
At all
Even for someone who is very experienced
Well, you dont know until you try it
Also, what is wrong with not being experienced?
As I said before, Is just for fun and eventually to get some experience
No dude
I think it's just not possible
I'm not saying it's wrong not to be experienced
I just think that people with a lot of experience in Lua coding can't do this, I don't think shadows are possible
You can't really say "you don't know until you try it" because you usually read a documentation and imagine an algorithm
Btw sorry if being too negative
Even if you somehow could get correct shadows for each building it would still be very tricky to draw them
Well, even if it dont work, or even if it works in a basic way
For example, something more simple, and this is an idea I had for a while, animation for trees, dividing the trees in different parts, and make them react to different situations
Or an tool for create shadows automatically, not necessarily to being useful, but more like a way for me to get used to lua
As I said, Is just for fun, I dont want to make a plugin that I could sell in the plugin store, or even a free plugin in the forum, just for fun, as experiments, I dont publish my plugins, I only use them as a way for me to experimentation, I barely have enough time to play TT, I wont have enough time to support a plugin
Just some probably insane ideas I get from time to time, and even if I waste my time, is just for fun
I dont want to get diamonds, Im not interested in publish plugins, Im interested in learn
I recommend you start with something more basic and then slowly do more advanced things
Emmm... In that case, some simple UI, like panels, sliders, etc
h
Does script:daily is same speed as script:update?
those are two completely different things
update is every frame, daily is every day
also script:daily is not script:nextDay (probably)
TT has json tag "target h", target w"
Oh ok thanks
you're welcome
Instead of stretching a texture it's probably better to draw it directly as a pair of triangles
Or other drawing shapes
They are very different
Gotta read the documentation carefully to not switch them up
Nextday gets called once every day
Daily gets called for every building of the draft the script is attached to
๐ค
I think the main problem is
You can't really see what's in a frame
At least
I don't know of any functions for that
I have no idea
scale up like this?
it's better to directly draw the right size.
however, scaling down will make the frame smoother, some icons are scaled down, like Icon.CLOSE_BUTTON.
target w, h โค๏ธ
Wow giant theoman
Big theoman
