#plugin-lua-and-fun

1 messages ยท Page 8 of 1

potent jolt
#

how can i cause a memory access violation via lua

light plinth
#

memory safety in erksmit's code?

#

Good joke

misty python
#

hmmm

random hamlet
#

I downloaded some lua coding thing and learned if conditions and stuff

potent jolt
#

hard to not be memory safe when you keep all your variables

light plinth
#

What you want to start with is C++

random hamlet
#

Imagine not starting with scratch

#

๐Ÿ˜”

#

People these days

light plinth
#

Scratch is garbage

potent jolt
#

imagine not knowing c#

light plinth
#

It introduces to programming concepts, yes

random hamlet
#

I mean it's for children

potent jolt
#

i started with arduino

#

epic

misty python
#
io.write("hello, world!")
potent jolt
#

so were where we

light plinth
#

I started with Java

potent jolt
#

excellent code

light plinth
potent jolt
#

full of bugs im afraid

misty python
#

sounds about right

potent jolt
#

although c# is my first real programming language

misty python
#

the chad programming languages

potent jolt
#

when i did arduino i didnt properly know what i was doing

light plinth
#

By that logic

#

I don't have a real programming language

potent jolt
#

fair enough

#

then i joined my current study

#

now i gotta do javascript and java

light plinth
#

Anyway

#

This is getting offtopic

potent jolt
#

anyway

#

how about plugin fun ey

#

whats up with that

misty python
#

anyways, i think knowing how to write a hello world message in lua is enough knowledge to get me through this whole theotown lua thing

light plinth
#

plugin fun?

potent jolt
#

plugin and fun are not words that go together

misty python
#

thanks, lobby, for that very useful comment

potent jolt
#

fun is like

#

a propriatery thing right

misty python
#

hm

light plinth
#

Proprietary?

potent jolt
#

well like

#

made up

light plinth
#

Fun isn't even fun

potent jolt
#

it doesnt exist outside of plugins right

light plinth
#

It's transitions internally

#

Yeah

potent jolt
#

yeah ok

#

guessing its been kinda abandoned now that lua exists

light plinth
#

Just like the Draft objects

light plinth
potent jolt
#

it oozes legacy feel

potent jolt
#

with pidroid

#

for as far as im concerned

#

fun is not understandable to mortals

light plinth
#

Pidroid is what you call technology from the 1970's

potent jolt
#

and documentation is non existent

#

so cobol then

light plinth
#

It exists

potent jolt
#

yeah like 5 lines

light plinth
#

Looks like Lua

potent jolt
#

its your code

light plinth
#

I have no recollection

potent jolt
#

epic plugin

#

in the big commented out block

light plinth
#

No idea what you're talking about

potent jolt
#

bruh

#

you sure

#

ignore the todos

#

might fix

#

maybe

light plinth
#

It's 11kB too big for my liking

misty python
light plinth
#

and you call my code broken

potent jolt
#

outplayed

#

see i can even break discord

#

i should become a qa tester

south garnet
#

Is this an OpenTTD industry set

potent jolt
#

feel free to remake my plugin

misty python
potent jolt
#

sike you need another lua file for that

random hamlet
#

I know I am late

#

But what are erksmit plugins tho

potent jolt
#

Cinematic camera and text placing tool

#

And a water tower I guess

#

Scripts available on the forum zoop

random hamlet
#

These sound pretty interesting

#

Especially cinematic camera, I wanted to check it out

#

Why does ๐Ÿ‡ฉ๐Ÿ‡ด call them bad tho

potent jolt
#

ยฏ\_(ใƒ„)_/ยฏ

#

Apparently they're sexual too

light plinth
#

yoo, that meme is overused

#

and I hate it

#

Don't ever do that again

potent jolt
#

You mean the report

light plinth
#

flag of Dominican Republic

potent jolt
#

Ah

#

Would you prefer ย ๐Ÿ‡ฑ๐Ÿ‡น

light plinth
#

I prefer ๐Ÿ’ถ

potent jolt
#

I prefer ๐Ÿ‡ฆ๐Ÿ‡ถ

light plinth
#

dutch bird incompatible

potent jolt
#

I'll just wear a coat

misty python
potent jolt
light plinth
#

Is it?

potent jolt
misty python
#

oh really

potent jolt
#

Well

misty python
#

seems all fine to me

potent jolt
#

I guess

#

But it's not gonna work in tt

open arch
#

The most easy thing to do is counting buildings turning them to spends or income @misty python

potent jolt
#

Wait

light plinth
potent jolt
#

The prints go somewhere?

light plinth
#

ASS console

potent jolt
#

Ok so nowhere

light plinth
#

Helps find lua bugs in DSA production

potent jolt
#

That's like

light plinth
#

ASS = Android Studio

open arch
#

Use Debug.toast()

potent jolt
#

When you Sudo without perms

#

Optional console window for lua debugging when

misty python
#
print(string.upper('hello world!'))
``` then this will work, ripped straight out of lobby's code
light plinth
#

When TheoTown 2

potent jolt
#

Idk

light plinth
#

It's not a question

#

It's a statement

potent jolt
potent jolt
misty python
open arch
#

Oh okay

light plinth
#

discord system wide notifications

potent jolt
#

You can run that code outside of theotown

open arch
#

I am not gonna lie, I read those veriables and other things for like some seconds then kulche really helped me a lot about those

potent jolt
light plinth
misty python
potent jolt
misty python
#

thank you lobby

potent jolt
#

Cool code from lobby

misty python
#

this channel should be renamed to

#

#bully-lobby

open arch
#

Kulche should rewrite whole api ๐Ÿ˜ณ no that would be soo hard I guess

potent jolt
#

That's always been the plan

#

How would that even work

light plinth
#

Hold my beer

potent jolt
#

Oh dear god

#

Wait a minute

misty python
#

let's bully lobby even more, shall we?

light plinth
#

use theotown interpreter

potent jolt
#

Was looking if you could go the other way around

#

But no

light plinth
#

available here

potent jolt
#

Now that I have your attention

#

Plugin dependencies when

light plinth
#

TheoTown 2 when

#

if we ever do add dependencies

#

I will make sure you have to deal with a mess like gradle

potent jolt
#

The logistical nightmare isn't my problem

misty python
light plinth
#

:bear_python:

#

hm

misty python
#

:bear_c#:

potent jolt
#

Just steal factorios system smh

#

I don't know how they do it

light plinth
#

ignoring high severity issues isn't a fix

potent jolt
light plinth
potent jolt
#

Oh no the 2 high severity issues in my cypress

potent jolt
light plinth
#

that's how pipelines get hacked

potent jolt
#

With a forum account

light plinth
#

imma need those too

potent jolt
#

Well if I update my cypress it don't work

#

So 1.4.4.0 it will stay

#

Or whatever it was

light plinth
potent jolt
#

I haven't logged in in years

light plinth
#

Alright

potent jolt
#

Could be connected to Steam now

light plinth
#

Just send your RDP creds

potent jolt
#

They don't have a standalone anymore

light plinth
#

to your PC

potent jolt
#

Just use my server smh

#

Factorio is in c

#

You could run it on a Samsung smart fridge

light plinth
#

Your server is in nt

potent jolt
#

Well

#

My main pc isn't set up

light plinth
#

Can hook it up real quick

#

Just plug in arch linux installation medium

#

and enable ssh

potent jolt
#

Ech

#

Just dowload the game

#

How much space can it be

#

There's like

#

5 sprites

light plinth
#

More than a floppy disk

potent jolt
#

And it's more optimized that tt will ever be

light plinth
#

well duh

#

it's in C

#

But not memory safe

potent jolt
#

Well yeah

#

They didn't spend 10 years making it for nothing

#

They actually have a lighting engine tho

#

Better than TT already

light plinth
#

Look

#

I was an infant 10 years ago

open arch
#

๐Ÿฟ

potent jolt
#

Look

#

I couldn't code until 2 years ago

#

Although that implies that I can competently code

light plinth
#

you can't

potent jolt
#

As I said

#

although

light plinth
#

No, locking a thread which is an instance of Db isn't a good idea

potent jolt
#

What

#

When have I done that

open arch
#

I will try to make the code more fancy

#

it wasnt fancy before but

#

wow I killed the english grammar again, ops

#

dude I am too lazy to paint for this

open arch
#

how do I put veriables into tables

potent jolt
#

Table.spot = variable

#

Or table['spot'] = variable

#

Or table.insert(table, position, variable)

#

But thats only for number keys

open arch
#

I just wanted to add some veriable number into notification

open arch
#

after 2 or more hours I have set the balance of the plugin and now the codes look more meaningful

#

is there anything that I can turn the calculations I made into an app using lua

#

hmm yes now I have 8 notifications for false combinations and factory stops with the right informations and also for one new thing

weak mural
open arch
#

Ah I see

#

Then how do I implent it into a notification text?

torpid spear
#
City.showNotification{
  -- Image for the notification, can be extracted from a draft using :getFrame
  icon = frameDraft:getFrame(1),
  -- Text of the notification
  text = 'count:'..variable..'lol'
}```
#

won't this work?

open arch
#

Oh hmm

#

Soo I have to write the veriable without ''

torpid spear
#

depends on what do you want to achieve

potent jolt
#

.. puts 2 strings together

#

so 'hello' .. 'world' will become 'helloworld'

random hamlet
#

how do I put an optional argument in a function? I tried TheoTown.playSound(chosenSound, loop=true) and it didn't work for some reason

#

what's the right syntax?

#

nvm, let me try one thing

#

TheoTown.playSound(chosenSound[[loop=true]])

#

this looks weird

#

but doesn't error at least

#

nah doesn't work even after i changed it

#

@potent joltsorry for dumb question but how do I apply parameter?

#

and skip volume

potent jolt
#

you put TheoTown.playSound(chosenSound, true)

random hamlet
#

I mean

#

there is a volume parameter

#

won't this apply to it instead of 3rd parameter?

light plinth
#

optional parameters are nil by default

random hamlet
#

this didn't work for me

light plinth
#

that way if for example you have a function and you only need the last parameter

#

you do it like

#

TheoTown.playSound(chosenSound, nil, true)

random hamlet
#

okay, thanks

random hamlet
#

the plugin works on phone... but the sound is weird for some reason:(

#

mabe It cut off the sound when I exported it to .plugin

#

nah it doesn't on pc

#

wtf is with phones

#

yeah on mobile sound starts playing and then restarts

#

like half of it is cut out

open arch
#

@potent jolt hmm strange, the notifications I put in my script:nextMonth are poping up every day even tho I dont have a script:nextDay. Is this how this is intended to be?

potent jolt
#

have you reloaded it

open arch
#

?

#

probably not

#

what does reloadedit mean?

open arch
#

what happens is, it does start showing notification once new month starts and then continues to send same notification ever day in this month if the problem isnt fixed

misty python
#

although come to think of it, i barely understand lua, so i'm just gonna take my time and read through those tutorials and then probably make some simple lua plugin, maybe a new disaster or sth

open arch
#

although I am not gonna work on codes for a time, my mind is heated up and eyes are bleeding. Might work on textures when I am feeling okay

potent jolt
#

as long as you understand general object oriented coding concepts you should be fine

open arch
#

I dont even know what you are talking about, I shouldnt be fine then

#

you guys should be making fun of me in a hidden channel

light plinth
#

ooc? never heard of it

open arch
#

trying to understand a yt vid

potent jolt
#

well ok maybe not object oriented

#

but in general

#

how lua works

#

and how it interacts with theotown

open arch
#

I see, soo you meant that I have to know how functions, veriables and tables work and also making them a lot more compact?

#

I just want the annoying notifications popup once a month and not once a day in a month

weak mural
#

OOP bear_yes

open arch
#

sighs

potent jolt
#

OOPs

light plinth
#

reminds me of oops role

open arch
potent jolt
#

What do you mean

#

It is a table

#

He declared it with some contents

open arch
#

Today I couldnt stand and tried to fix notifications, now again I am fed up with theotown plugin making.....

open arch
# potent jolt What do you mean

I wanted to make a notification for all stuff. Like if there are two stuff have to be fixed there will be one notification with the right sentences

random hamlet
#

And can you remind why does it need to be sent every month?

open arch
#

It is city. notification and I want it to only send once a month and not every day of a month otherwise it is annoying

#

It is in scrip next month, it does start poping up once it is next month but looks like we cant really control notifications without estra codes to stop it

random hamlet
#

Is it in some condition or something?

potent jolt
#

you shouldnt do popups anyways

#

unless theres an actual problem

#

or it requires the player attention

#

not for monthly income

random hamlet
#

Is your notification for reporting a problem?

open arch
#

It is for attention otherwise spends increase, factory stops or calculated income is negative at year's end

light plinth
random hamlet
#

wdym how does it work?

#

Do your spends increase at usual?

#

and you need to do something about it every month?

open arch
#

Spends increase if there are too many chimneys per factory soo a notification comes and warns you about it

random hamlet
#

so this should popup only if there is too many chimneys?

open arch
#

And also if players has too many bfg silos for blast furnace because they increase income but for balance I wanted to limit them

random hamlet
#

just troll le players

#

no notifications

#

extra hardcore

open arch
#

Might have to do it to release this plugin earlier

random hamlet
#

I have a small urge to draw but it's not big enough for me to actually start drawing

open arch
#

Or I can make a gui ๐Ÿค” that has a factory theme. It shows problems and estimated income yearly income

random hamlet
#

gui?

#

it's harder but it's cool

#

make it viewable from that skyscraper

#

so it's like hq or something

open arch
#

Wont it be easier? I could just use drawing with enable disable function once player presses on skyscraper (or accountants office) it shows it

#

I can even make my own gui and it wont occupy space on screen

random hamlet
#

I just assumed, I was going to learn gui soon but don't know much for now

open arch
#

Kulche taught me how to make coordinates on screen also with the tutorial at forum and enable disable scripts it shouldnt be hard I guess

uncut field
#

I would probably show a notification like yours once a year

#

One month passes by quite fast in TheoTown

#

I tried doing a similar thing with the prison expansion

open arch
#

But income also comes at the end of year, If I make it yearly than people wont realise their factory wasnt working

potent jolt
#

You can display a warning sign if it's not working

#

Similar to the warnings that appear on buildings with problems

open arch
#

Oh

#

Is it in building api?

potent jolt
#

No you'll have to draw that yourself

open arch
#

Oh I see

random hamlet
#

how do I fix this stupid fence overriding my pretty diagonal roof

#

to make it more understandable

open arch
#

hmm yes pounkiller's decals json

random hamlet
#

if it works it's good

potent jolt
#

no

open arch
#

is just a decal json, probably pounkiller wasnt using an app for the json

weak mural
#

how to prevent people from copying your code.

open arch
#

it really did lmao

light plinth
#

shift alt f

open arch
#

well I had another decal json in australian bush fire pack

#

also gotta say that pounkiller's code kinda has unnecessary stuff too

open arch
#

he probably knows that

random hamlet
#

I think it wasn't a question

torpid spear
#

please read the whole conversation before replying (again)

potent jolt
#

context my man

#

lua obfuscation when

stoic vector
open arch
#

oh

#

what is that?

potent jolt
#

Ah so a world texture viewer

open arch
#

yeah

#

but I am wondering if it is taking x and y coordinates of them?, there is a thing at the bottom but

stoic vector
potent jolt
#

that will not get approved if it shows any iap purchase textures

stoic vector
potent jolt
#

how did you set up your dialog

stoic vector
potent jolt
#

why not overwrite the games 9patches with dark ones

#

also there insnt really a way to have readable text on dark backgrounds

#

at least the way the game draws it

torpid spear
#

i once tried to replace game ui with dark ones and most of them were unreadable

#

I can't edit color of the text so easily sadly

potent jolt
#

Yeah there's no way to make the game draw text differently

random hamlet
#

make it just dark grey

potent jolt
#

oh ok so the plugin creators will have to implement the dark mode

#

that could easily lead to inconsistent ui if you dont provide premade frames

stoic vector
median condor
trim remnant
#

The real question is what that incognito tab was for

median condor
#

He was most likely making charity donations to help starving childrens.

uncut field
#

I use incognito so chrome doesn't open my links with the apps

#

That's irritates the hell out of me when I use YouTube desktop on my phone

open arch
#

I use incognito for discord web for phone, otherwise it is spam of suggested discord links at search bar

stoic vector
weak mural
#

?

light plinth
#

Those are not default Lua libraries

stoic vector
#

the table with it's first letter d in lowercase seems seems to be a default library
debug not Debug

light plinth
#

Also, some standard libraries may be disabled for security reasons.

potent jolt
#

they are documented

potent jolt
light plinth
potent jolt
#

oof

#

mans fixed it himself

light plinth
#

yes

#

the entirety of luaj is part of theotown now

potent jolt
#

imagine reading into the libraries you use

#

wouldnt be me

light plinth
#

the same way I cloned discord.ext.menus into Pidroid

potent jolt
#

glorious open source

light plinth
#

But that's too much maintenance

potent jolt
#

dear god

light plinth
#

yes

potent jolt
#

not a fan of single line if's with brackets

#

but that nitpicking

light plinth
#

usually, it's all ternary operators in tt code

potent jolt
#

i find those to be a little hard to read sometimes

#

but im cool with them

#

i only really use them on return statements

light plinth
#

wanna see new android file api?

potent jolt
#

not realy

#

but sure

light plinth
potent jolt
#

man

#

not a fan

light plinth
#

it's crap

potent jolt
#

i get boxing off what apps can access

#

but that seems excessive

light plinth
#

yeah

#

just a sandbox feature for those apps

#

if user disables it

#

then app can access files no problem

potent jolt
#

yeah

#

that wouldve been fine

#

would put 0 extra effort on the devs

#

well mostly

#

and be backwards compatible

light plinth
#

ah yes

#

backward compatibility

#

that's why we can't have modern java on android

potent jolt
#

backwards compatability

#

i say as i change the way my bot config is setup almost every update

light plinth
#

my bot config is the only backwards compatible feature

potent jolt
#

or my plugins where i radically change the functionality

stoic vector
#

What does Vector do in the game?

potent jolt
#

a Vector can represent a lot of things

#

a vector is an object holding an x y and z value

#

you can use them for example to calculate the distance between 2 points

#

in my camera tool i use them for the cameras location, its target location etc

#

and also the distance it moves per frame

#

they have a z axis but if you dont need it you can just not use it

#

for example

#
local vector1 = Vector(0, 1) -- makes a vector with x 0 and y 1
local vector2 = Vector(2, 1)

local vector3 = vector1 + vector2 -- will create a vector with values x 2 and y 2
vector3.x -- is 2
#

you can also easily get the lenght of these vectors

red sedge
#

Well Vector in programming is most often used as coordinates

potent jolt
#

yes

#

they can represent offsets as well

red sedge
#

yeah that

potent jolt
#

you can do some funky maths with it

#

much cleaner than doing lua local x1, y1 = 0, 1 etc..

#

**subject to change

#

also probably not the best code

#

-- current camera location
camera.location = nil
-- the distance between the camera's current position and the target position
camera.targetDelta = nil
-- the distance moved per frame
camera.frameDelta = nil
-- the target position for the camera
camera.target = nil
``` are all vectors here
#

theyre given values later

random hamlet
#

Vectors are some math sticks which are used too often in coding

#

Example: "huh so vector is just a math stick/smartass line? This is useless"
Tries to code something
"I was wrong"

#

By the way, there are scripts to move camera? @potent jolt

light plinth
#

vectors make the game 3d

potent jolt
#

Imagine using the 3rd dimension

potent jolt
#

valid scales are 4, 2, 1, .5 and .25

#

with a higher number meaning more zoom

open arch
#

3rd dimension in theotown is like 4th dimension in reallife

potent jolt
#

you could use it for like

#

2 level ground decos

#

i guess

#

or ground level

#

but im pretty sure there isnt really any lua api functions around height

snow arrow
#

local denKC = [[
[
{
"id":"denKC",
"type":"animation",
"frames":[
{
"bmp":"denKC.png"
}
]
}
]
]]
Draft.append(denKC)

local topFrame = Draft.getDraft('denKC'):getFrame()

#

is this correct ?

#

i want to get the frame of denKC.png

potent jolt
#

uh

#

well first off a disclaimer

#

using draft.append is a bad idea and should only be done if theres no alternatives

#

but yes

#

that will get the 1st frame of that

snow arrow
#

thank you

#

but i don't know why the game report that :

potent jolt
#

this is a json error

#

unless

#

where are you calling that script?

#

in script:init?

#

you can declare denKC at the start

#

but you cannot call draft.append before script:init

#

as that will not have been set up yet

snow arrow
#

[

{
"id":"$circleKanight",
"type":"animation",
"frames":[
{
"bmp":"circlenight.png","w":320
}
],"light":true,"light switching":true
},

{
"id":"$lop2KC",
"type":"animation",
"frames":[
{
"bmp":"lop2.png"
}
],"light":true,"light switching":true
},
{
"author": "DucAnh",
"frames": [
{
"bmp": "circle.png"
}

],
"height": 10,
"level":3,
"id": "KatoriCircleTower",
"monthly price": 10,
"needs road": false,
"price": 65000,
"text": " Katori Circle Tower  ",
"width": 10,
"type":"award",

"animation":[

{
"id":"$lop2KC",
"x":0,
"y":-323
},
],
"habitants":5000,
"people":4500,

"draw ground": true

},
{
"id":"$circleTrans",
"type":"data",
"script":"circleKat.lua"
}
]

#

this is my json code

snow arrow
potent jolt
#

you have a trailing comma on line 46

#

{
"id":"$lop2KC",
"x":0,
"y":-323
},
],

snow arrow
#

please help me

#

local animDraft = Draft.getDraft('$denKC')
local topFrame = animDraft:getFrame(1)

function script:draw(tileX, tileY)
local daytime = TheoTown.daytime or 0
if Tile.isBuildingInConstruction(tileX, tileY) then return end
if 0.1 < daytime and daytime < 0.8 then return end

local time = City.getTime() + tileX + 2811 * tileY
local freq = 0.1
local phase31 = 0.5 + 0.5 * math.sin(freq * 0.001 * time * 2 * math.pi)
local phase32 = 0.5 + 0.5 * math.sin((freq * 0.001 * time + 0.33333) * 2 * math.pi)
local phase33 = 0.5 + 0.5 * math.sin((freq * 0.001 * time + 0.66667) * 2 * math.pi)

Drawing.setAdditive(1)
Drawing.setAlpha(1)
Drawing.setColor(255 * phase31, 255 * phase32, 255 * phase33)
Drawing.setTile(tileX, tileY, 12, -365)
Drawing.drawImage(topFrame)
Drawing.reset()
end

local counter = 0 -- A counter variable

function script:update()
local daytime = TheoTown.daytime or 0

local time = City.getTime()
local freq = 0.1
local phase31 = 0.5 + 0.5 * math.sin(freq * 0.001 * time * 2 * math.pi)
local phase32 = 0.5 + 0.5 * math.sin((freq * 0.001 * time + 0.33333) * 2 * math.pi)
local phase33 = 0.5 + 0.5 * math.sin((freq * 0.001 * time + 0.66667) * 2 * math.pi)

Drawing.setColor(255 * phase31, 255 * phase32, 255 * phase33)
Drawing.drawImage(topFrame, 30,26)

Drawing.drawText('This is frame '..counter, 30, 26)

counter = counter + 1 -- Increase counter

end

#

the function update() works, but the function draw don't work :((

potent jolt
#

Does this script even load

#

You should assign values to animadraft and topframe in script:init instead of immediately

#

Well anyways 1 issue is that you cannot call Drawing in script:update

#

Like at all

snow arrow
#

thank you ๐Ÿ˜„

potent jolt
#

99% sure

#

pretty sure the Drawing table doesnt even exist in that function

torpid spear
#

if I remember correctly I always used Drawing in script:update

potent jolt
#

hm

#

i remember having to move my drawing functions elsewhere

#

ah right

#

that was because of the build menu

#

while in building mode the black line grid will overlap with any drawings

#

if you draw in update instead of drawcity

potent jolt
#

yeah i couldnt because of building mode

#

just keep it mind that your drawing will not be drawn correctly then

#

still reccomend doing it in drawcity so the drawing order will always be correct

#

this problem might be diffrent now with the new way water is drawn

cerulean crypt
#

Help

hardy stream
#

Hm?

odd hazel
random hamlet
#

what

cerulean crypt
#

How to allow bus stop in lvl 3 bridge

potent jolt
#

im not sure scripts can help you there

stoic vector
#

i have a question

#

if i have a GUI bound to a building, how can i make it show before the info panel of buidling

#

I want to make it so only my own GUI will be shown, without the information about the building

#

and also, how can I get rid of the black background

open arch
#

I thought it automatically doesnt shows buikding info

ebon tundra
#

Hey guys I want to build cricket stadium in 12x12, I know stadium in TT is 8x8, but those stadiums are football stadium, but cricket stadiums are bigger u know, anybody knows something abt that
How to contact developer , or who approves plugins.

potent jolt
#

vscode is a good ide for lua scripting

stoic vector
#

is it possible to change max value of the slidebar in gui after initializing?

elfin geyser
stoic vector
elfin geyser
# stoic vector how?

Use math.floor()

local value = 0
local slider = dialog.content:getCenterPart():addSlider{
 x=50,
 y=-34,
 width=170,
 height = 30,
  minValue = 0,
  maxValue = 0.30,
  getValue = function() return value end,
  setValue = function(v) value = v qty = math.floor(100 * value+ 0.5)end,
  getText = function(value)
  return ''..math.floor(100 * value + 0.5)..''
  end
}
stoic vector
#

it's not really what i needed but thank you

#

it seems that this code is for showing value which is not percentage

#

but i needed so if i'll move one slider, the other slider's max value will change

weak mural
#
  ...
  setValue = function(v)
    value = math.floor(v+0.5)
    fVar = value
    sVar = mainValue + fVar
    tVar = mainValue + value
  end
  ...
potent jolt
#

Have you tried making maxvalue a function?

random hamlet
#

bruh my siren plugin doesn't ignore illness disaster

potent jolt
#

why not filter that out then

#

just check for DISASTER_ILLNESS and dont do anything if its that

random hamlet
#

yeah I am doing that

#

I have several other disaster filtered out

#

I just realised I forgot to add illness just before I was going to release

#

I am releasing the fixed version, I hope it'll work for everyone

open arch
#

Is it pending aproval now?

#

Also be sure to select version of plugin

random hamlet
#

It's pending

random hamlet
#

Why?

open arch
#

Like game version

random hamlet
#

Ah

open arch
#

See minesweeper

random hamlet
#

What version should I put

#

Where was disaster code added

#

When*

open arch
#

I think you should look at when sound code added because it is newer

random hamlet
#

Bruh

#

I should probably get it off plugin store and upload sooner again

#

Any way to do that without just removing it from store?

#

I don't want to get low ratings now

#

But I guess not much people on store play with old versions

#

Still need to update it

open arch
#

Nah you can edit your plugin

#

And change minimal version

random hamlet
#

But I will need to wait for approval again

open arch
#

If you edit it, it is soo easier

random hamlet
#

Well I don't thing it will get approved/disapproved in less than 3 hours

#

So I can change the file and update

open arch
#

Yes

random hamlet
#

Before it gets approved anyway

open arch
#

You can change anything

#

Even delete it

random hamlet
#

But I need to know what version to put

#

I may just specify the version a few numbers lower than current

#

To be sure

open arch
#

Yep

random hamlet
#

Asking just in case, what format should I use? For version

open arch
#

@weak mural when are you going to add "show all anims" button, because I want to finish my building and use it for it. I am not forcing but wondering if it is near or far future

elder glacier
#

Guys can someone send me a sample of a night frame code?

random hamlet
#

I am not on computer but I can leave a tip

#

It's just like a normal animation, but with "light":true and "light switching":true tags

#

(hope I am not wrong)

#

And everything else is just like any other animation

elder glacier
#

@random hamlet wait wait wait how about that "y" coordinate?

random hamlet
#

Ah

#

Well it's a bit tricky

#

Kulche sent a picture

#

All anims have y thing, though

elder glacier
#

@random hamlet can u pls sent that pic?

random hamlet
#

1 second

elder glacier
#

K

random hamlet
elder glacier
#

Tks

random hamlet
#

So, 0 height is at leftest point

#

And the taller it is the lower negative number goes

elder glacier
#

K i wish i could understand this

random hamlet
#

It's not that hard

#

I am not good at explaining

#

Basically 0 is at left. And the higher your picture goes, the lower number gets

#

I guess -10 y makes your anim hover 10 pixels above the center of "plate"

#

Have you made building floors using animations? @elder glacier

elder glacier
#

@random hamlet no

random hamlet
#

This is another useful thing

#

It saves plugin space a lot

#

Basically, you need to draw only one floor of your building

#

And then just stack it with code

#

It's good if you have repetitive texture

#

You need to have building base as frame, a lot of floors code as anim and top of building as anim

#

I'll write a tutorial once I figure out cords

#

Also it makes the texture easier to manage IMO, by the way

elder glacier
#

Oh ok

random hamlet
#

(this is not what you need right now probably, but I am just saying)

elder glacier
#

Hey can u help? Whats wrong?

#

@random hamlet

random hamlet
#

Lemme look

#

An you show me the full code?

elder glacier
#

@random hamlet can i send u the code in dm?

random hamlet
#

Okay

elder glacier
#

K

random hamlet
#

Oh I have a guess but I can't really see it cus it's not easy to read from there

#

Send it in dms

ebon tundra
#

How to change plugin sound , plz help

elder glacier
#

Guys I need several explainations for the new diagonal road code. Can someone help?

random hamlet
#

any chance dialog this big won't fit on mobile?

#

or it's automatically scaled?

#

@potent jolt sorry for ping again but I remember you posting about using dialog for GUI stuff

#

how do you add stuff on it?

misty python
random hamlet
#

I hacked into tree planter code

#

analysed it

#

and figured out adding stuff on dialog

#

I guess

misty python
#

fart

random hamlet
#

yes I am funy

#

laugh

#

bruh so I added button somehow

#

it doesn't have any additional stuff but it just closes the window

fallen condor
solid scarab
#

fart

open arch
#

fart

elder glacier
#

le pet ๐Ÿ‡ซ๐Ÿ‡ท๐Ÿฅ–

random hamlet
#

does anyone else have experience with GUI here?

open arch
#

not me

#

But yes

last mirage
#

Ok, so the biggest question I have, how would I move this into Theotown via my folder on Android

#

So that i can test

south garnet
# last mirage Ok, so the biggest question I have, how would I move this into Theotown via my f...

In this tutorial for TheoTown, I'm going to show you how to install forum plugins for game versions 1.9.95 and above (or Android 10 and above and 1.9.82 and above)

Also go download my fill sandbox requirements plugin ;)
https://forum.theotown.com/viewtopic.php?f=73&t=7591

Time stamps:
0:00 Intro and Explanation
0:31 The "Classic" Way
2:18 Usin...

โ–ถ Play video
last mirage
last mirage
#

Cause mine is completely different.

south garnet
#

The one that comes with Huawei/Honor hpones

last mirage
#

Ok, what is wrong now?

random hamlet
#

lol you forgot a comma i guess

#

and that's not scripting

last mirage
#

Oh well, do you know where the comma that I forgot is?

#

Nvm

#

I know

potent jolt
#

It says so right there

torpid spear
#

also you don't put booleans in apostrophes

potent jolt
#

Same for numbers

last mirage
#

Alright, I fixed it

uncut field
#

@weak mural I'm making a GUI plug-in and I was wondering how I could make a window similar to yours. I noticed that yours is always anchored to the side of the screen and doesn't pause the game. Would you mind giving me a few pointers?

potent jolt
#

If draw just the 9patch it shouldn't pause the game

torpid spear
#

it's called a panel

#

you can assign ingame or your own ninepatches to it

weak mural
random hamlet
#

how do I properly put stuff on dialogs?

#

I want to make something like this example (put different functional widgets)

#

Maybe I'll figure out the placement

#

but buttons just close it, even though they aren't assigned to anything

#

(I checked, they close it)

potent jolt
#

Create 1 vertical layout for the lines

#

Then for each line make a horizontal layout

#

And add your labels and text fields to that

random hamlet
#

I have 1 layout, alright, didn't know I need two

#

what about the button problem?

potent jolt
#

What do you mean button problem

random hamlet
#

the button closes the dialog

#

even when it had some function assigned

potent jolt
random hamlet
#

okay

#

on button or a dialog?

#

I guess button, based on docs

#

...or maybe dialog because button disappeared

#

nah that's a bad idea

potent jolt
#

On the button

#

The GUI compendium article has an example

random hamlet
#

found it

#

I forgot that I switched placement and that's why is there no button

#

finally

light moon
#

Osjidjdsiokl

random hamlet
#

it said "amog us" but I thought it was cringe and quickly replaced

fallen condor
#

mogus sus

random hamlet
#

I made a button which opens menu somewhere

#

and throws text field somewhere off the dialog (pretty cool but not planned)

#

interesting

stoic vector
open arch
#

๐Ÿค”

#

real time

potent jolt
#

maybe draw the date and time ontop of it again so its actually readable

stoic vector
open arch
#

What do you mean here jeremiah?

sour sable
#

how do i get started on plugins using lua

#

and what is the use for it anyway besides ui

stoic vector
#

you can make a game inside a game

#

you can check my minesweeper lol

potent jolt
sour sable
#

ah ok

potent jolt
#

there isnt much you cant do with it

sour sable
#

well it should be a simple switch from python to lua right

potent jolt
#

i guess

#

if you understand programming you should be fine

sour sable
#

alr then

open arch
potent jolt
#

that was made with fun

#

but lua can do it too

light plinth
#

probably slower, though

pearl cloud
#

maybe I should make my first plugin...

light moon
#

Make sure its good

pearl cloud
#

:)

potent jolt
#

Plugin requirements:

#

Good (optional)

open arch
#

good texture or good idea, select one

pearl cloud
#

good texture

#

I'm too stupid to make something that's not a residential

#

So

#

just a house

#

maybe a little cozy house

potent jolt
#

You see

#

That's why I make tools

#

Because good textures are not an option

open arch
#

you have some good textured plugins why are you talking like that

pearl cloud
#

U talk with me or with erksmit?

open arch
#

erksmit sorry sir lol

#

I havent see your textures

light plinth
open arch
#

it is not bad

random hamlet
light plinth
#

I've witnessed it with my eyes, not that impressive compared to real life

open arch
#

where are your textures

potent jolt
#

ah right the water tower

#

i do wanna improve that at some point

#

but i lost the pdn file

open arch
#

just overpaint

potent jolt
#

i like to keep shading in a diffrent layer tho

#

also my noise layers

open arch
#

bruh lol

light plinth
#

just copy paste from google maps

potent jolt
#

will report results

light plinth
#

3/10 times it'll get through

#

and 9/10 times I'll suspend it

open arch
#

12/10

#

how

light plinth
#

that's not how math works

open arch
#

yeah I should have said that my math is bad ๐Ÿ˜”

potent jolt
#

my first plugin! what do you guys think

#

i put a lot of effort into the textures

open arch
#

good

grave mica
#

Looks absolutely beautiful

potent jolt
#

diamonds to the left please

open arch
#

at least shadings are right

grave mica
#

But I will give this a 9/11

light plinth
potent jolt
#

also it costs 10 theons and makes 1m water

#

you gotta earn it yknow

light plinth
#

now that sounds like a job for OP plugin detector

#

speaking of which

#

when is the plugin coming

potent jolt
#

oh right

#

its well underway

#

and by that i mean i havent started yet

light plinth
#

what about 5* mayor dlc?

potent jolt
#

that does exist

#

but its far from finished

#

i gotta work on that again

#

i could clap that op plugin thingie out in like 2 days probably

light plinth
#

inb4 you cant

potent jolt
#

should be easyโ„ข๏ธ

weak void
potent jolt
#

had to make it clear for those in the back

open arch
#

Not a bad idea lol ๐Ÿ˜”

potent jolt
open arch
#

Lmao

potent jolt
#

really should try to fit the windows into the textures again

#

i failed last time

#

so i left them out

idle musk
potent jolt
#

I see that category = false

#

That is not a valid value

#

And the JSON should have [] on the outsides of it

potent jolt
#

is there a function i can use to leave the currently active draft

#

like draftdrawer.enter but for leaving

#

to force a user out of a tool

light plinth
#

os.exit()

potent jolt
#

excellent idea

#

basically i want it to be like a building

#

in the menu

#

and make a dialog via lua when you enter it

light plinth
potent jolt
#

do i look like i have time for that

#

cant speedrun

#

if i contact lobby

light plinth
potent jolt
#

ima try some things

light plinth
#

and fail miserably

potent jolt
#

well

#

i didnt try them because im not sure itll work

open arch
#

@elfin geyser hello, can you explain if it is hard to make a supply-demand system like in your old-timer plugin? are you using tables and functions get to interact with each other?

hybrid knot
#

Is there a script that would cause major traffic at a specific time?

#

Like

elfin geyser
random hamlet
#

๐Ÿ‘€

open arch
#

a storage system

random hamlet
#

What plugin are you talking about?

elfin geyser
#

It's nothing to do with the ingame demand system, Just a variable to store that unit then store it ingame and reload it when launched

open arch
#

Is there any open-source code about this?

#

soo you dont use tables? I am sorry kinda newbie

elfin geyser
open arch
#

hmm

elfin geyser
#

I think the best example is the tree planter tool open sourced by lobby

open arch
#

I am struggling to understand it but I guess it needs time

open arch
elfin geyser
#

The tree planter also stores data ingame and reload it again you may get the idea if you figure it out

open arch
#

oh okay thank you soo much

elfin geyser
#

It has by getting theotown storage

open arch
#

but it uses a slider to feed it right? Soo I want to make it have a speed to increase the numbers

#

like a producing building

potent jolt
#

oh nvm just read the rest

potent jolt
elfin geyser
#

I didn't have the link of tree planter tool but im pretty sure there's a comment that will guide you to understand the structure

open arch
#

my other question is have you ever used city spawn car and target reached codes?

potent jolt
#

i got some in my plugin too i can grab

#

for setting storage

elfin geyser
#

Clueless about that

potent jolt
#

yeah i havent used that either

open arch
#

I am thinking to just use car spawning and target reached function bypassing a storage system

#

also find it more interactive

elfin geyser
#

Is this for your steel mill?

potent jolt
#

it would ensure that road connections are required

open arch
potent jolt
#

but you still need the storage table to make sure the values are stored

#

for the next time the user starts

open arch
#

was going to use conveyors, rails, and trucks for it. Gotta be fun but couldn't make it work

open arch
elfin geyser
#

Well good luck you can ask me for some instances you can't understand but you can ask ian for better understanding

open arch
#

thank you

#

probably wont happen this year tho

potent jolt
#

but you still have to keep track of the timers in the storage table

#

unless you reset them

elfin geyser
#

Well i guess he wanted to make a stone dealership

light plinth
#

lol

open arch
#

stone dealership what

potent jolt
#

excellent idea

light plinth
#

flintstones plugin when?

elfin geyser
#

Nvm just like a mine industry that you can trade stones from what steel mill mines

potent jolt
#

ah

#

yeah i thought hed have rescource storage

#

and trucks would be sent out when they reach a certain level

open arch
#

just a modulable port and factory components. I dont want to make mining things now. Cant even make notifications works properly

open arch
#

I kinda forgor how to write lua but there was a code like " for 0,1000"

potent jolt
#

so that the user can quit and load without it resetting the timers or other values

hybrid knot
#

does someone have a script to where I can cause terrible traffic along the highways?

elfin geyser
#

I wish there's an easy way to do this

full topaz
#

๐Ÿ˜ต very confusing ๐Ÿ˜ต

elfin geyser
#

Not really

open arch
potent jolt
#

its a declaration of a very large table

#

personally

#

id put this in the drafts meta table

light plinth
#

It has the issue of not being expandable when trying to translate it

potent jolt
#

is it though?

#

cant you put this in another table with an entry for each language

light plinth
#

You expect to rewrite code to support it?

potent jolt
#

most definitely not

#

i aint supporting translations

#

for like 10 words

light plinth
#

Be in the case where you want

elfin geyser
#

Any suggestion about my code?

-- AIM/SHOOT FUNCTION
local function aim(x,y,f) -- f = frame
  local x1 = 0, y1 = 0
  
  for tile = 1, 30 do
    if CannonAccuracy() then
      if (f == 1) then
        x1 = x + tile * -1
        y1 = y + tile * -1
        if (checkEnemyShip(x1,y1) or checkEnemyRaiders(x1,y1)) then
          isEnemy(x1,y1)
          x1 = 0
          y1 = 0
        end
      elseif (f == 2) then
        x1 = x + tile
        y1 = y + tile * -1
        if (checkEnemyShip(x1,y1) or checkEnemyRaiders(x1,y1)) then
          isEnemy(x1,y1)
          x1 = 0
          y1 = 0
        end
      elseif (f == 3) then
        x1 = x + tile
        y1 = y + tile
        if (checkEnemyShip(x1,y1) or checkEnemyRaiders(x1,y1)) then
          isEnemy(x1,y1)
          x1 = 0
          y1 = 0
        end
      elseif (f == 4) then
        x1 = x + tile * -1
        y1 = y + tile
        if (checkEnemyShip(x1,y1) or checkEnemyRaiders(x1,y1)) then
          isEnemy(x1,y1)
          x1 = 0
          y1 = 0
        end
      end
    end
  end
end
random hamlet
#

either text or buttons

#

I accidentally downloaded second visual studio

#

great progress

#

it's on the wrong side but still great

#

how tf do i get them to display on the left side

weak mural
#

drop your script here, so we can know

random hamlet
#

some stuff like get first part were different because I was randomly changing stuff

#

erksmit said to create vertical layout and then horizontal but I could've misunderstood

#

but probably I am doing it wrong

#

so annoyed

#

can someone help?

#

how do I even place stuff on dialog

#

properly

weak mural
#

the problem is the height of the "vertical" layout. delete it or make it bigger.

random hamlet
#

ah

#

everything is still bad

weak mural
#

can you share all of your scripts?

random hamlet
#

I mean these are all the buttons

#

and the script has some secret stuff

weak mural
#

you can use getFirst/Center/LastPart() if needed and not using x/y. idk what your problems if i can't see your script.

random hamlet
#

I tried changing them but it didn't work

#

(from first part to center or last)

#

@weak mural what are you using to show window?

#

I mean what your window actually is?

potent jolt
random hamlet
#

a

potent jolt
#

So it took all the space

#

And the buttons got added after

weak mural
random hamlet
#

I thought of using it but erksmit said I can use dialog

potent jolt
#

Dialog is just a window with some premade stuff

#

I recommended it cuz it's faster

random hamlet
#

well I think making closing function and blur n pause n stuff is a bit tricky

#

or they're there

#

idk

weak mural
#

dialog is easier to use than you build new one

random hamlet
#

I just need a good place to show text and have some buttons

#

even like that

potent jolt
#

Hm

#

Let me check the documentation real quick

weak mural
#

on your script is vertical

potent jolt
#

It has no mention of width limits

#

But every gui object should have them

weak mural
#

there's no size limits, but they are follow the parent size and padding as default.

random hamlet
#

I have get first part in buttons code

#

and in text

#

when I changed layouts to this just to check

#

it did this

potent jolt
#

Yes

#

That's what layouts do

#

Is that not the intended result?

random hamlet
#

well how do I properly place stuff

#

I expected it

potent jolt
#

What do you mean

#

Isn't this what you wanted

random hamlet
#

not really

#

how do I figure out placing stuff properly

#

and how to set up layouts for this

potent jolt
#

Can you show the result you want?