#plugin-lua-and-fun
1 messages · Page 3 of 1
- me blatantly pointing out your mistakes won't make you learn, you'll have to figure it out on your own
- you've got the whole internet to browse, get searching!
there's a whole lot of websites that teach you lua because I've used some of them ages ago
you don't understand, it's physically easier for me to just look at the code and think how it works, and all the guides I find fall into three types
- GMOD
- general information
- roblox
I just hate to sit and read boring documentation, so I'm much happier sitting and pounding on non-working code to figure out how to fix it
you're free to find some
thank you, you almost put me off learning lua.
that's your choice, I told you what to do
I'm just asking for help with the script, you don't have to tell me how to learn.
I also told you what to fix in your script, I'm not writing lua for you
I understand the help, but I already found the guide.
I said, I'm a newbie, I have NO clue how to fix this one, I don't know what you mean when you say I'm accessing boolean incorrectly and that some values I can find in the json forums.
that's why I told you to read some documentation
you won't learn what a boolean is by just looking at someone's code
learning is a balance of theory and practise, you can't just skip one part and expect it to work
How does that help me? It's programming for theotown, not just general scripting
you are trying to write a lua plugin for theotown
it's obvious that you're gonna need lua knowledge for that
also, what is "general scripting" to you?
I'm doing it the way I know how, the fact that I'm accessing a boolean incorrectly doesn't mean the whole code is wrong, so I'm asking for help.
general-purpose scripts that do not use data, for example, from here https://doc.theotown.com/modules
as I've already said, I pointed out the obvious mistakes already - fix those and see if it works
nice 403 error
they are unlikely to help me understand what budgetitem is or where to use City.
how do I fix them?
to study for a month only to realize that I made a small error in syntax?
why are you even trying to use budget item? it's an optional parameter for pretty much every function I'm pretty sure
City is the module, which you'd have known if you studied basic lua theory
Okay, then how do I release the money to the city?
it would be nice to see the code you're working on right now
I don't want to learn three weeks to finish a script I made for an example, I'm sure it can be fixed in a minute now, but I have no idea how. I'm writing it to figure out how to structure and write it, and you're telling me I have to learn it, even though I'm writing it to learn it
well you are
but it will probable be like 3 weeks before you arrive at a usable script
The purpose of this script is that if there is a certain building on the map, and if the profit exceeds the city budget, a certain amount of money will be added to the player's bank every month.
lol nobody prepared you for the fact that programming isn't something you learn in 5 minutes
well that is possible
but you really ought to focus on the fundamentals for lua
but this can be a good exercise for it
._.
now, can we see the actual code
I wrote above, that's why I'm writing this, to learn, just not with theory, but with practice.
.
refer to my messages above, I'm not going to write the same thing again
well theres some indent problems that make it hard to read
your variables have just a single letter
you should pick a descriptive name for them
removing that redundant space in the first line would be a solid first step
#plugin-lua-and-fun is active? no way
you should right click -> format document
on file?
what now
in your ide...
right click and format the document
(I assume you changed the language to lua already)
i literally told you to right click
!!!
I have none and it works just fine
only 1 is enabled
but it could probably help to have something
and what is it
what i need in this way
now that your file is formattted and looking nice
you should rename that a b and c
to something that actually represents the value they hold
thats looking nicer
next time you can use f2 or right click -> rename symbol
that way it will rename it everywhere
double control+r renames variables in all occurences so you might want to use that
oh that might be something from regular vs
double control r is a intellij thing idiot
smh
its f2
shortcuts
bruh guys
it wasn't even 2 minutes
IsBuildingIn is an integer and not a boolean
never seen this channel this active
i'd recommend naming it "buildingCount" or something like that since it doesn't actually answer the question "is"
you also have some typos
some as in atleast one
you need precision when you're scripting
That's not the point here
then what is
also earning income is restricted to privileged plugin creators
@light plinth can help you with that
IsBuldingIn equals the number of buildings in a certain id in the city
no idea how to convert it to boolean
I'm sorry, but I'm not familiar with the Lua scripting language or the game TheoTown. Therefore, I wouldn't be able to provide specific guidance for your script or request. Is there anything else I can help you with?
I'm not telling you to change types
I'm telling you that it's nice to have a uniform naming scheme and not use names starting with "is" for representing integer types
but, anyway, fix the citymoney typo
bunny, you're clueless when it comes to lua, stop even watching this chat
ok
not like i have anything better to do
whats next
CityMoney?
yes
show me the whole code, not completely random 1 line snippets that tell me nothing
anyway, you wouldn't use a while loop here
the code runs only once every month, there's no iteration needed
make it a single if statement and type all your conditions in there
brackets () and and statements will help here
😩
it works, but you made it look horrid
an if body needs an indent, not 2
then you close it
and so it goes
there is a function in a start
pretty sure he needs json "privileged":"*********" on his jsons to function that ```lua
City.earnMoney()
that has been said
????
my bad
function ...
stuff
if something then ...
stuff
end
end
that's how indentiation works
please learn lua theory 😩
what wrong
format document again and see for yourself
it's not wrong, per se
damn my soundtrack album looped like thrice now..
I understand the problem is the structure
the only thing that should be left to fix is to remove the optional, redundant parameters from the earnMoney function
that should do it, in theory
now format the document and make sure it's actually attached
attached as in json
as I realized, the main error was in the format and space in the function
yes
dont working tho
It's a new month, budget is 1,000, profit is 111.
income won't work without a privileged key
was supposed to add 1,110 to the budget
???
also, earnMoney simply adds a value to estate, so the income readout won't be accurate
that has been discussed at least twice now, refer to those messages
you might want to add an additional Debug.toast('text') in your script to detect whether it actually does something
No, I just have no idea what you mean, what's the key? I'm not a native English speaker, it would be very hard for me to find it in the dialog now.
what he refers as a "privileged key" is a thing some trusted plugin creators have
you need to be an approved plugin creator before you can use op features like income or diamond spending
^
bruh what
without a privileged key you can't do that
you have been warned before
also do what I said and check if the script actally works
debug working so
because youre not allowed to use it
learn to read, god
how does my Discord have anything to do with the game? lol
you've been told several times
this chat would be half as large if you were to actually read our remarks
no but your game account does, and your account doesnt give you the permission you need to use it
why
because you arent trusted with that code
thank you
the process is: create good plugins > apply for privileged code > get code > use said code > profit (literal profit)
i need create plugins to get new abilities to create plugins?
basically
bruh
income above 1t is restricted for anyone who's not privileged
simply because people would create 1x1 buildings that generate millions of theons per second...
I mean, I can only make the income for this building less than 1000?
and how hard do you have to work to get the key?
well
at least that's how it worked for json, no idea if it's the same for lua
quite hard
a privileged key.
and, I understand this is a limitation in both Lua and json.
not sure about lua
you can't
json for sure
you'd have to read more about those lua functions
anyway, your script isn't tied to a single building
so count doesn't matter here
it blocked so
earnMoney in lua
just dont working
still
thanks for help
so much
earnMoney isnt openly usable since it would make it too easy to cheat
lua seems like a pain in the butt too
if you have 0 scripting experience, yes
Is real time Lua editing still works on mobile?
why wouldn't it
Gonna try
Real time Lua editing doesn't work on me (is it broken?), it still needs to import on file manager (I mean, requires restarting)
You need to save it on every changes you've made
so it's not realtime?
I already saved it everytime I make changes though I cant see the result on realtime
nvm, it's now resolved, back to realtime again
yo
why i cant call a function
The game shows an error at startup, they say it requires a closing } on line 13, although it is not needed there, if I replace Plus() with function(), it will work
youre running plus() and giving onClick its result, instead of giving plus itself to onClick
i need to do something like onClick.Plus()?
onClick = Plus
or
onClick = function() Plus() end
thx
guys, is the setXp command blocked by the privileged key?
😦
there are no such functions as getX or getY in the City module
that looks like the only module that has those functions
yes I have access to the api
how does your code look like
i think slider code is wrong, but i just teaching it now
functions getX, getY don't have overloads for drafts
they operate on building types
sometimes you wont get a line or file number in your error
then, how i need to write it? dont see this information on API site
you use city.getbuilding
there is, you just have to read it....
you first get the building and then operate on that
you can't get the position of a building if you don't have the building
i need to use City.getBuilding with draft to get XY a then operate with them
got it
yes
If I write a variable with the value City.getBuilding it will have the value X, Y? Like 64, 76.
?????
mmmm
I have 0 idea what you're trying to ask me
City.getBuilding returns the position of a building of specified index
you'd need to have the index
still nil value lol
indices are positive integers
where i need to find index? Building.getId()???
😦
I don't know what do you want to do
how i can know it?
you'd probably iterate through every building of your draft
where i can find building's index?
I have just told you
count all buildings of your draft and iterate through each of them
I can't help more, I don't know what do you want to achieve
iterate 😩
patience kulche patience
I don't recommend you to try lua if you don't know that word lol
Okay, in another way, how do I use City.getBuilding?
you input the index and it returns two int variables - x and y
how do I know the index of a building? (I can't understand what you were saying before, I mean, go through all the buildings from draft?)
I have already told you, each building in a city gets assigned an index
thats the nice part
you dont
you dont know what building youll get from a certain index
but if theres only 1, you can be sure its that one
And where do I get the index? I realized that it is different in the city and unique for each building, but what then?
index of 1 = 1st building
Building tables are stored in lists that you can access using City.getBuilding(draft_id, index of the building in the list)
You can obtain how many buildings there are in the city using City.countBuildings(draft_id) or something similar.
Then it becomes a trivial loop to get the building that you need.
if you have maximum 1 building of the same draft you can simply use City.getBuilding(1, draft)
starting indexing at 1 🤮
cry about it
lua moment
i had to write complex industry in this
shame on lua
should work
it returns 2 variables
you only assign 1
I'm not sure if that's a problem in lua
good
still
same with function arguments
feel free to toss 50 arguments into a function
well
are you in a city?
becuase your error says the city table doesnt exist
which indicates that you are not inside a city
i cant to come in game
then you're calling the script improperly
call it when you're in a city, not immediately =
got it
you must be calling it in script:init
you should use another function instead
something like nextDay, which only runs inside cities
script:enterCity
that ought to work
well
i forgor to place building
is your building in the city?
lol
lol
that might help
skill issue
good joke so
anyway should be all good
you have to place the building, save and reenter the city
script reloading ought to make it work
yeah and
it would call entercity again
are you sure your draft id is correct
by the way you can use script:getDraft()
that way you dont have to manually put in the draft's id
ah
you don't have to create two identical functions, you can put the toast in the function at the top
yea you cant define nextDay twice
the 2nd will overwrite the 1st
thats why x and y are nil, the first one is never ran
do I need to remove the second function?
well
you never obtain the dialog youre trying to add stuff to
you have to change the signature of your finishInformationDialog function to include it
like (x, y, _, dialog)
im using _ for the 3rd argument to discard it
and how can i call json alert using lua?
you can install the plugin developer tools plugin by lobby
it contains some example gui code and a list of available icons
where i can found it's code?
I would like to add an external link on my dialog box, what lua function is that?
how to make a fence plugin?? where I need to go
oh
What is plugin-lua-and-fun about? Like what do you do here?
lua scripting and fun
you can see what they are here
https://forum.theotown.com/viewtopic.php?f=41&t=2965&sid=dbf6187d472cfa332cbd7dae32e01035
Ok
Is tollbooths created using fun attributes? Or how it was implemented?
Lua
From this function I expected that it will simply every game day to increase the number by one and output, but it just takes and from the beginning starts to output 5, wtf?!
sorry, wrong, it doesn't output 5, it alternates 1 and 5 in a row in the output
there is probably some code offscreen that messes this up
but it falls outside your screenshot
nope, all the code behind the screen is written with --[[, and it doesn't matter, basically it's just the code for which I need the counter, so I removed it for a while.
show your whole script
ah
you might accidentally attempt to invert amae
what it is doing is first negating emea, then comparing it to 100
It's working now, but in a weird way
it first outputs 5 and then the number in order (5, 1, 5, 2, 5, 3...).
make breg local
look there must be more to your script then
i really dont trust that thats all
because if it was it wouldve worked
well now youre just assigning 1 to it every day
what's wrong?
youre setting it back to 1 every day
i know
that's the reason I made it global, but if I make it global now, it'll go back to alternating with an 5.
you can put locals outside your functions
they dont need to be global for that
global just makes it manipulable by other scripts
which is dangerous and you shouldnt do it
I know, I know, but now we have to figure out why it's alternating five
just put it as a local outside the dailt function
you can read this https://doc.theotown.com/topics/01-lua.md.html if you won't read the documentation from LUA official site.
to be fair, lua's official documentation is really bad
i agree
I strongly agree
Accede
Omg yes. I have to go to third party sites to find a list of params and return values every time I look up a function from lua
It also doesn't help when the version of Lua I use is 15 years old
its neat
nice
If the intersections are big they probably meet each other at the center, || and act just like a man pushing stone endlessly ||
You know exactly what it is...
this is gonna fry your device lol
oh god
finally, theotown is now a real game
device is ok
I had to allocate more memory for jvm cuz oom spam
but it seems like I can't get a better framerate
someone is actually doing it
how is the video stored in the script
well
dear god
perhaps you could check if a tile actually needs to change before placing new tiles
to reduce the amount of calls to java
or just draw it with drawing calls
I dont know TT api very well yet, so optimizing is a bit difficult :DD
according to the docs, i can use buildGround with drafts
like
Builder.buildGround('$black', 10, 10)
but
i guess using buildings for this is bad idea
I would probably check the previous frames, rather than call to TheoTown to check if tile ground draft equals current frame that is required
Hope you cache Draft.getDraft call
oops
thats gonna hurt performance
see, not setting the lastms simply adds to the exponential increase in speed
its a feature
switched to ground
pain
ah ye, thx
switching to ground gave real perf boost
lol 1.10.42?
yep, I guess it’s outdated
but I can’t access steam rn 
probably means the game doesnt have to figure out as much about how to place it
getting the draft object on startup and using that should improve performance too
64x64 now feels acceptable
using the drawing module would probably give a massive performance boost
drawing is ui
doesnt have to be
you can draw on tiles if you want
here i am using drawing
which is also why it looks terrible
piccle
as you can see its drawn in relation to where the building is
drawTileImage?
thx, let me check this
youll have to get the black and white frames from the drafts
is there any ingame log or smth?
Drawing.setTile(lx, ly)
Drawing.drawTileImage(white)
not ingame
but in the theotown folder in your userfolder there is a log.txt file
also, you tried to call setTile while not inside a city
youll have to use a different event function to run your code
script:drawCity () is a suitable one
ahh thx
i guess im just missing somethin but...its not working 
local black = Draft.getDraft('$black')
function script:drawCity()
Drawing.setTile(5, 5)
Drawing.drawTileImage(black)
end
or maybe texture..
try putting your getDraft in script:init
as ```lua
local black
function script:init()
black = Draft.getDraft('$black')
end
function script:drawCity()
Drawing.setTile(5, 5)
Drawing.drawTileImage(black)
end
didnt work(
maybe smth in json?
im on latest now
1.11.13p
dunno
i guess json
{
"id": "$black",
"type": "ground",
"author": "Neon",
"width": 1,
"height": 1,
"frames": [
{
"bmp": "flatblack.bmp"
}
],
"edge frames":[{"count":12,"h":48,"w":16,"x":0,"y":96}],
"level": 1
}
maybe you can check your json with pickle idk
did you specify your script anywhere
ofc
there is two scripts
one with table, generated from video
and second for rendering
already, working
call Drawing.reset before drawing
just in case someone else set the opacity or something
ah i see the problem
my script was passing the draft instead of the frame
it should be
local black
function script:init()
local draft = Draft.getDraft('$black')
black = draft:getFrame()
end
function script:drawCity()
Drawing.setTile(5, 5)
Drawing.drawTileImage(black)
end
yep already tried this
but still nothing
also, checked image with drawImage - works
you can probably just use drawImage, if your tile image aligns with the tile
drawimage is ui, it should use screen coordinates or I’m misunderstood something..?
also, seems like storing big table with pixels in memory cause game to freeze every n seconds
even if not using it(
if you have used setTile it will be drawn on the tile's location
drawImage should end up exactly on the tile you set
this is what ive used and it works for me ```lua
-- Draws an icon ontop of a building indicating the building has a problem.
---@param draft draft The draft of the building.
---@param building industriBuilding The industriBuilding that has a problem.
local function drawProblem(draft, building)
-- check if the building actually has a problem, and ignore the SUPPLY_NOT_MET problem since the game already draws an icon for that.
if building.problem and building.problem ~= IndustriBuilding.PROBLEMS.SUPPLY_NOT_MET then
-- get the center position of the draft
local width = draft:getWidth() * 32
local icon = Industri.getIcon(building.problem)
-- use the width of the draft and the size of the icon to get a offset that will center the drawing
local offsetX = (width - Drawing.getImageSize(icon)) / 2
-- draw the icon in the center of the building, 60 pixels above it
Drawing.setTile(building.location.x, building.location.y, offsetX, -60)
Drawing.drawImage(icon, 0, 0)
end
end
thx, I’ll check this out
it wont work without a lot of additional surrounding code
its just a snippet i grabbed
yea I see
ah
the x and y argument for drawImage are not optional
i just use Drawing.drawImage(icon, 0, 0)
thinking about random freezes due big table
as I understood, here I can’t use any external things like luvit
or access os/io from lua ingame
no, theyve been blocked for security
understandable(
i'll share everything later
||code is too cringy now :D||
"Will be called once per frame after UI has been drawn. Will also be called outside of cities."
badapple-v is just a lua file with one (large af) table
{
"id": "$badapple-v",
"type": "script",
"script":"#LuaWrapper",
"meta":{
"luawrapper":{
"script":"file.lua",
"dev":true
}
}
}
then why does debug show this..?
is there any legal way to disable this profiler or idk how to call it
it measures timings every second and it causes game lag (big table :D)
theres a setting for that in settings
this setting only hides ui, i guess
this looks pretty good already
but every-second lag is killing me
here i loaded only ~1000 from ~6600 frames to reduce lag time
but still 
||also irl it looks better, some recording issues||
pretty cool
I feel like that will be the garbage collector, rater than the timings measuring
not sure if theres anything to be done then
afaik lua collects garbage automatically
changing jvm gc settings didnt work
||or im just too dumb for this||
perhaps you can store parts in diffrent draft's meta tags, then load those piece by piece
theyll still be entirely loaded in java, but maybe that wont lag as much
well, its lagging even if im not using it
looks like only way i have is splitting them to ~500 frames and record one by one
but this is cheating(
at first I thought maybe i can provide frames using tcp or smth
but since i cant use anything external..
looks like using strings is better than tables 
That was painful :D
Source code will be published later
Amazing
actually it can render video with better resolution and framerate
but it will lag every second
so 64x64 ~15fps
or decrease video length
overall, not the worst
maybe one day we’ll have way to get pixels from another sources and it’ll able be to run doom
doom would honestly probably be easier since you dont have to store an ungodly amount of data in memory
besides having to run doom
yeah
maybe there is some chance of getting an "unsafe" mode for lua idk
maybe io.popen is enough for running complex things, dunno 
io module doesnt exist in TT's lua environment
I know, that’s why I said about “unsafe” mode or smth
anyway not sure if it even possible

Hello i need help about fun,
There's any documentation about creating new notification convo by pressing check or ok?
you lookin for this https://forum.theotown.com/viewtopic.php?t=4730 ?
Can u give a sample
shush dyno
"id":"$cool_notif",
"type":"notification",
// ...
"question":true,
"ok fun":[
{
"actions":[
//stuff
]
}
],
"cancel fun":[ // optional
{
"actions":[
//stuff
]
}
],
// ...
coolio!
more cool stuffs on lua
{
"actions":[
{"type":"notify",
"id":"$notify_discription_abandoned_tanker",
"question":true,
"ok fun":
[
{
"actions":[
{"type":"notify",
"id":"$notify_discription_abandoned_tanker_run",
"question":true,
"ok fun":
[
]
}
]
}
]
}
]
}
],```
Thats fine its for future messenge convo
remember that is not chat for JSON
My problem is it won't work
I dont think, nested fun is working
did you actually read the channel name/topic
yeah definitely won't work
you're supposed to put those arrays in your notification definition
not building
or whatever calls those actinos
{
"id":"$dummy_object.trigger_mess",
"fun":[ // you may use `on click fun`, or `random fun` here
// triggers your notif message
]
},
{
"id":"$notif_message_00",
"question":true,
"ok fun":[
// triggers next ok message action
],
"cancel fun":[
// triggers next cancel message action, optional
]
},
{
"id":"$notif_message_00_ok",
"question":true,
"ok fun":[
// triggers ok action
],
"cancel fun":[
// triggers cancel action
]
},
{
"id":"$notif_message_00_cancel",
"question":true,
"ok fun":[
// triggers ok action
],
"cancel fun":[
// triggers cancel action
]
}
it basically notifies user, and after they answer ok (check mark) on the first notif, the second notif (00_ok) will appear
or if they cancel (cross mark) the first notif, the third (00_cancel) notif will appear
Oww thanks for effort
coolio
What should i put inside of ok fun and cancel fun
more notifs or the actual disaster itself or any actions listed here https://forum.theotown.com/viewtopic.php?t=5961
Yah i already figured out that
Im still confused about making message convo
"actions":[{"type":"notify", "id":"$notif_message_00"}]
It is possible to add color on text?
||no lua pls||
no
Sad
Help
{
"id":"$notify_discription_abandoned_tanker_upgrade",
"type":"notification",
"text":"Starting now, this tanker will be operational again.",
"frames":[{"steal":"$anim_people_source01","frame":10}],
//"question":true,
"fun":[
{
"actions":[
{"type":"rect","w":1,"h":1,"inner":
[
{"type":"remove"},
{"type":"build","id":"$rusty_industry1","z":1}
]
}
]
}
]
},
If you wanna use "inner" your type should be "type":"or" or "type":"and"
@cerulean crypt ganito format nyan
no condition, direct into "actions":[]
Thanks
I have multiple fun notifications convo that can notifi the players when they pressing bulding ...
I want to use the similar notifications convo for other building...
My question is can i make similar convo for multiple building, but they have specific results for each building?
How can i do that?
Can i use only 1 convo for multiple building but i want defferent results for each,
Should be specific,It is possible?
You lookin for ```json
"template":[
"$temp_00",
"$temp_01",
"$temp_02"
]
It should be like this
Maybe?
If i separate the final fun
How can i connect it on the first line?
Fun
1 convo ⬇️
2 convo ⬇️
3 convo ⬇️
4 final fun ⏫⏫⏫
Output = 🌝🌚🌜
.
Define all fun in a single template and then use building checks at x:0
Thanks
I dont have any about what im doing 😅
Is this write?
"id":"$notify_discription_abandoned_tanker_temp",
"type":"template",
"on click fun":
[{
"actions":
[{"type":"performance",
//im the first 3 message {fun id}
"id":"$notify_discription_abandoned_tanker"
//{what should i write here?}
}]
}]
},
probably
formatting kills
Wth happened ?
Y everything can be burned .
"condition":
{
"type": "date",
"min": 0,
"max": 365
},
"actions":[{
"type":"burn" ,"id":"$rusty_industry_1"
}]
}]```
I put specific id on it
Y this was happened
probably, bcoz of format 😩
"condition":{
"type":"and", // if you wanna satisfy ALL inner conditions
"inner":[
//more condition-type index here
]
}
your inner would look smth like this
"inner":[
{"type":"building", "id":"$bldg_id"},
{"type":"date", "min":int, "max":int}
]
is there an attr on json or fun to set road deco index when build it without LUA?
Thanks
There's "on built fun"
There's a frame action, otherwise there's no dedicated fun action to change index.
There's a call action, which, well, calls Lua
unfortunately, I dont have time right now to finish the plugin
so here's the source code
very unstable
Hey how to find id busway
U mean "targets": [id1, id2, id3] ?
Help about this 😂
Type temp
},
{
Type Building 1
"ok fun":[{
"actions":[ {"type":"notify", "id":"gen notification","z":1}, {"type":"remove","id":"$building01"}, {"type":"build", "id":"$building1"}
]}]
}
{
Type Building 2
"ok fun":[{
"actions":[ {"type":"notify", "id":"gen notification","z":1}, {"type":"remove","id":"$building02"}, {"type":"build", "id":"$building2"}
]}]
}```
How do i can connect
General notification template,
For each of building has different have different results. 😅
x:0
where do I attach it?
I already connect it but they're not changing
Ok
Test something
You'd check what the current building is and execute specific action accordingly
I don't think it's possible
templates only works for the whole "fun":[ ] attr
{
"id":"$temp_text",
"type":"template",
"text":"I'm a notif for all"
},
{
"id":"$notif_00",
"type":"notification",
"template":[ "$temp_text"],
"fun":[
// actions for bldg_00
]
},
{
"id":"$notif_01",
"type":"notification",
"template":[ "$temp_text"],
"fun":[
// actions for bldg_01
]
},
{
"id":"$notif_02",
"type":"notification",
"template":[ "$temp_text"],
"fun":[
// actions for bldg_02
]
}
That's how I can see this
The "fun" tag above can be any fun attr, like random fun, ok fun, and alike
Fun conditions can triggered separated fun attribute?
For example
Action 👉}
{Hi im seperate fun 1 condition if 👉✅ my result 🌝}
{Hi im seperate fun 2 condition if 👉✅ my result 🌚}```
How can i do that?
Or
{Hi im separate fun 1 if building was remove i build 🌝}
{Hi im separate fun 2 if building was remove i build 🌚}```
If any of these 2 are possible
How can i do that?
"fun":[
{
"condition":{}, // your condition 1
"actions":[]
},
{
"condition":{}, // second condition
"actions":[]
},
{
"condition":{}, // and more
"actions":[]
}
]
"fun":[] works similar like this
if condition then do actions
These work on separate fun?
what separate fun?
{Fun temp}
//template user
{Fun action 1 if}
{Fun action 2 if}
I already said it, you cant do that
{
"type":"template",
"fun":[ ] // NOT condition:{} or action[]
}
What if notification conditions
same logic for all
This json is by lobby
{
"actions":[{"type":"frame","code":"$vars_switch_myvar"}]
}
]```
Can someone explain what is use of ``` "code"``` tag?
There's any link for documentation?
Hi can i ask again why it won't work ||"random fun":[ {"condition":{"type":"and","inner":[ {"type":"date","min":0,"max":5}, {"type":"building","id":"$rusty_industry_1"} ]}, "actions":[ {"type":"burn","id":"$rusty_industry_1"} ] }] },||

Idk y they're not burning
Hmmm I have a script, I want to know if it is json, and what it needs
{
"id": "farmatodo",
"type": "commercial",
"width": 3,
"height": 3,
"frames": [
{
"bmp": "farmatodo.png"
}
],
"title": "Farmatodo",
"text": "Una farmacia que ofrece una gran variedad de productos y servicios.",
"level": 1,
"price": 10000,
"monthly price": 100,
"influence park": -10,
"influence noise": -10,
"influence pollution": -10
}
This
Sorry for the stupidity, but it's just to confirm
Looks fine to me
its missing the outermost square brackets
Ok
So?
[{
"id": "farmatodo",
"type": "commercial",
"width": 3,
"height": 3,
"frames": [
{
"bmp": "farmatodo.png"
}
],
"title": "Farmatodo",
"text": "Una farmacia que ofrece una gran variedad de productos y servicios.",
"level": 1,
"price": 10000,
"monthly price": 100,
"influence park": -10,
"influence noise": -10,
"influence pollution": -10
}]
should be alright
although you should really consider using english if you intend to publish it
Oh thank you, that's right, I had forgotten
Is there a function that allows you to not display a building?
theres a "hidden" tag you can use
by setting "hidden": true in your json it wont show up in the build menu
"hidden":true
No, I mean make it stand on the tile but not display
frames: [null]
Turn it off so you can show it again
ig you're looking for virtual variables or lua functions
use upgrade is more simple.
Drawing animations with Lua
😭😭😭
😭😭😭
thats a json, not script
I'm sorry lol
try #plugin-support
also i dont see anything wrong, send what the error apearing is also when you send there
OK, thanks a lot
I really want to say something but it is too dangerous for the sake of this server
No LUAers?🥺
Theres like 5 people that use lua
And two chickens
its me
waluigi?
no, the chicken using lua
Hey, does anyone have a json template to make a cable car?
lua moment
Notice how this channel is for lua and fun. Not json
Use the proper channels please
(what channel even is for json?)
I have a question can someone teach me the JAVA language please?
thanks in advance
not json?
is this for a plugin youre making? if yes youre probably looking to make a json instead, you can find what you need on the forum and if you need help you can ask in #plugin-support
now, if youre actually looking to learn java, i suggest using a website or watching youtube videos as this channel is for lua and fun
ok thanks
Although theotown is made in java, plugins cannot use the language
thanks pidroid, very cool
Pidroid hate everyone
Everyone hate Pidroid
so what's the difference between City.move and City.setView
The setView function is not intended to be perfectly reversible as getView does not take elevation into account. If all you want to do is to scroll the map this future function may be useful to you: https://doc.theotown.com/modules/City.html#move
cinematic camera tool is so back
What the lua line for building on slopes?
and where would you need lua for that?
Idk, I ask if there is a specific code in json to make it possible
Thanks Kulche
The Tag list doesn’t state that the tag ‘supports slope’ manages the concrete foundation under the deco. A not clear or not relevant description makes everyone bomb the same questions every time. Just remember me a month ago. I asked the same.
Exactly. ‘Handles on its own’ is a very vague description of what the tag does. It can mean many things. Add the words about triggering the concrete foundation under the tile.
you do you, ask lobby
How?
dm, or simply comment under that post
@steep stream Hi, Lobby, plz, change the description of the tag ‘supports slope’. Add words:”It handles whether to build the concrete foundation on the slope under the object.”
i think thats a pretty vague and undescriptive addition
since it can apply to other situations than just a bridge
I don't understand how to put in this operator the building whose coordinates will be output?
what?
you pass the building and the function returns it's x position
it's as simple as that
how do I tell the script which building coordinates to look for? I don't see any input value on this site.
building:getX()
please read the introduction
I kinda knew that, it's just that I did some scripting three months ago, I'm trying to remember again
how do I find the coordinates of a building by its draft?
use City.getBuilding
I've used this before, but I didn't quite understand what its output is, I just can't run the plugin right now, can you explain what the output of this command would look like?
it outputs the coordinates of said building
-- let's get the first building of the draft
local x, y = City.getBuilding(1, someDraft)
you ought to check if the city contains the building at all using city.countbuildings
thx
two variables, I got it, thanks.
I have to update it every game day, otherwise it won't work correctly
sounds like a horrid idea
you ought to collect your building on entering the city
why would you have to find the building every day?
then keep track of any new ones being built using script:event
you can just keep the building object around
I need to check if a particular building is within five tiles of a given building, if I don't check this every day, the action being performed simply won't work
then track it manually using events
Forgive me for being stupid in this matter, but I have to learn as I go, I can’t do it any other way
because im generous
here is an example
local draft
function script:init()
draft = Draft.getDraft('somedraft$00')
end
local locations = {}
function script:enterCity()
-- get all the buildings that already exist in the city
local count = City.countBuildings(draft)
for i = 1, count, 1 do
local x, y = City.getBuildings(i, draft)
table.insert(locations, { x=x, y=y })
end
end
function script:event(x, y, _, event)
if event == Script.EVENT_PLACED then
table.insert(locations, { x=x, y=y })
elseif event == Script.EVENT_REMOVED then
-- find the coordinate pair in the locations table
for key, location in pairs(locations) do
if location.x == x and location.y == y then
locations[key] = nil
return
end
end
end
end
to track the locations of buildings of a certain draft
Bruh
`bdraft = ...;
bsecdraft = ...;
shielddraft = ...;
local function nextDay();
local buildx, buildy = City.getBuilding(1, [...]);
local buildposplusfive = buildx + 5;
local buildposplusthree = buildx + 3;
local buildposplusone = buildx + 1;
local whatbuildisplusfive = City.getBuildingDraft(buildposplusfive);
if whatbuildisplusfive == bsecdraft then
Builder.buildBuilding(shielddraft, buildposplusthree);
Builder.buildBuilding(shielddraft, buildposplusone);
end
end`
Works only for x+ coordinate now, but it easy to increase
what
there is no City.getbuildingdraft function
also semicolons are not required
and it still uses getbuilding every single day
you could just use script:daily
and your script will only work if the other building is exactly 5 tiles away
i dont get what youre trying to achieve
The draft will be written here as a variable, so it will be easier for me to work with it
if you only want to build the building near the main building, use fun is enough.
[{
"on built fun": {
"condition”: {"type": "buildable", "id": "$id", "x": 5},
"action": {"type": "build", "id": "$id", "x": 5}
}
}]```
cuteee
Figuring out what goes wrong in your code without a debugger is one of the programming experiences ever
excessive amounts of print and log will fix that
and copious amounts of restarting the game because i turned on strict lua
I wonder if is there any copyright free perlin noise code in lua I could borrow
Note that if I do, it'll be more like a cheap strategy game
But I'll make it so your city can get nuked with DSA ICBM
how hard can perlin noise possibly be
Apparently it's relatively not that complicated but I havent understood it or made my own yet
interesting
maybe you can i can work together and make our own stragery game lol
thanks
Agreed
thanks
now I just have to fix runtime error in unknown line and countries being colored black for some reason
What are you working on exactly? Terrain gen?
making a war game
theotown war update confirmed?
Ah I gotcha
It looks interesting. If it's on android I may pick it up
its a plugin lol
Oh
Kinda
I want to try making a thing where you can develop a country
With some policies
And building cities/mines/factories/etc. Around it (but done via mining)
And trading between other countries
And war, but I'm not sure how it'll look
It may end up very simple
But making trading and resources is just a matter of time
If I make this plugin it may actually be worth 40 diamond price or something
(If I ever finish it I'll still upload it under the price of 30 diamonds)
Hell yeah waiting for this bomb plugin
intresting
some color changes
@potent jolt do you know how to track clicks (just clicks)
I need to add the ability to select tiles
damn
these seem to be screen coordinates
but idk whats the max value
well they stay consistent when I move the map
and both increase towards bottom right
I hate how screen width and height seem to be a random number
and there's no easy way to get canvas x and y (probably there is but I haven't found it yet)
ok good
it doesnt work in dialog which is what I need :(
maybe canvas/dialog has onClick function or something
well I dont need the dialog itself
I need the canvas
but dialog could let me make a workaround
im not sure if the onclick for a canvas includes the location it was clicked on though
youll have to check
just try ```lua
local canvas = parent:addCanvas{
onClick = function(self, ...)
Debug.log(Runtime.toJson(arg))
end
}
and see if the args contain anything usefull
where is the log file btw
I guess not?
now what
I guess players will have to type the coordinates
unless there's a workaround
geuss not
why is there no GetMouseX() and GetMouseY()
I hope there is, but I couldnt find it in docs
it should be in my text placing tool somewhere
i had it to preview where the mouse is hovering
ah
i used ```lua
function script:draw(tileX, tileY, hoverX, hoverY)
this only works on pc
pretty sure this only works while inside a tool though
and only the tile coordinates
still not what you require
think youre gonna have to ask lobby
simply put a canvas on every pixel of the screen 
I will add a number grid on the canvas later so it'll be less painful
these buttons have the same y value
nvm im dumb
where tf is my label
okay I had to try with constant defined text first
I forgot there is no round()
I also forgot how lua string joining works
I keep typing c++ stuff
finally
I need to figure out how to add my own icons
Im 100% sure its possible
(saw in complex industry)
aren't icons just animation drafts or something?
no idea how it works but no way im figuring it out without seeing an example
I guess I have to ask erk
kulche were you adding icons in ci, or were you only in charge of drawing them?
only the graphics
but I've done similar things in the past
I think the forum drawing tutorial has what you're looking for
the one by bear
found this
trying to figure it out
doesnt work for me for some reason
of course it doesnt tell me what exactly is wrong
what does not work exactly and why
trying to add icons and this is the only example I found, but it doesnt work for me (shows error unless I remove draft.append line)
i tried with normal json too but it doesnt work either
this also shows an error