#plugin-lua-and-fun

1 messages ยท Page 7 of 1

green igloo
#

I see

elfin geyser
#

I was wondering if there is an event listener that returns the city ID that was removed or reset.

light plinth
#

Ppunish 718473535089279077

rare grottoBOT
tender parcel
#

How can I detect an approaching train, everyone? For example, if I place a device tile at X and want to know if there is a train within 4 tiles around X, which function should I use? Any help would be appreciated since I couldn't find any suitable function @@

kind iron
cerulean crypt
#

Am I doing the right thing?

potent jolt
#

privilege codes are not needed anymore

#

instead use "require privileges": true

#

if you have a privileged forum account and youre logged it the privilege is applied

#

and itll work when you publish it

cerulean crypt
#

Ok noted thanks.

opaque fog
#

It is possible to make animation get played when you click on building and then building get changed after animation end
Like that as example
Low quality because I wouldn't make that as plugin, just for practicing animation

chrome cobalt
#

Anybody knows how to fix this error?

torpid spear
#

..what is the error?

#

also not lua related, use proper channels

potent jolt
#

looks like the file youre importing already exists with the same name

haughty vapor
#

@void wolf
Can you kindly check this out?

void wolf
haughty vapor
#

But it still suspicious

void wolf
#

Ah yeah that does feel suspicious

#

Thanks

#

Removed to be safe

haughty vapor
void wolf
#

Hes going at it i see

light plinth
#

You may discuss about plugin fun and Lua scripting here.

random hamlet
#

((epic))

open arch
#

keep it clean guys, dont pollute the name of coding (or something like?)

random hamlet
#

how do I get user name?

open arch
#

and so I crashed vsc without saving the lua

potent jolt
#

wanna see my scripts

random hamlet
#

I saw it somewhere

#

and can't find it

open arch
#

my all works gone

potent jolt
open arch
#

it is working but cant get it on windowed

random hamlet
#

It was my first experience with lua today

#

I have quite a lot of time to learn it

gentle canopy
#

I use Visual Studio for Json....

random hamlet
#

maybe I'll make cool plugins with lua code someday

gentle canopy
#

Im interested in the GUI part of the TT Lua documentation

open arch
#

I am soo sad, my pc is that bad once I open gif search in discord web it crashes something

random hamlet
#

there is no point of making gui if you can't make use for it

gentle canopy
#

Wait, you cant edit TT GUI, right?

solid scarab
#

oh well , new channel

open arch
#

I am fine! woah it has an auto save?

#

didnt know that

gentle canopy
#

vsc?

open arch
#

yes

gentle canopy
random hamlet
#

how do I make something like f"text{var}more text" but in lua?

#

I mean

#

some text and variable in it

torpid spear
#

basically double full stops

random hamlet
#

found it

#

string.format('text %s more text', var)

#

oh

#

and this too

#

is making disasters possible with lua?

#

so I can code my own

#

what where

#

forgot a comma

#

maybe an error with calculations

#

@torpid spearmaybe you know... does it count the total playtime from account?

torpid spear
#

does what count

random hamlet
#

playtime

#

TheoTown.getPlayTime()

torpid spear
#

it's session playtime probably

random hamlet
#

I also had wrong number btw

open arch
#

thankfully erksmit exists

#

and kulche

#

and lua in TT

light plinth
#

It returns playtime from settings file

#

probably all your recorded playtime

random hamlet
#

shows 83 with correct formula (seconds/3600, am I right?)

#

steams shows 132 hours

light plinth
#

no idea

#

but formula is alright

random hamlet
#

does it count time spent in menu or somewhere else but not in city?

open arch
#

I learnt how to do math in lua now

#

I am soo happi

#

I am like archimedes when he found water's ability of lifting things

random hamlet
#

what math did you learn to do?

#

btw do you have any experience in coding except lua?

open arch
#

nope

#

math like what I wanted to do

#

I learnt those only but it is enough

random hamlet
#

I mean how complex is that math

open arch
#

like <= , == stuff and some other things

random hamlet
#

ah

#

is it that hard?

open arch
#

it is easy, I am just bad at math

open arch
#

gotta try the 8th lua script that, isnt gonna work

random hamlet
#

what are you trying to do now?

open arch
#

I was trying city spawncar and car reached event but couldnt do it soo I am gonna try something easier. Which counts buildings and gives income with some calculations

random hamlet
#

@open archwhat do you think, is this worth uploading as a small plugin?

#

with changed caption probably

open arch
#

I dont know man

#

BUT IT WORKED

random hamlet
#

๐ŸŽ‰

open arch
#

finally something I made without someone changing my codes, it worked

#

soo many thanks to kulche and erksmit

#

this is a start

random hamlet
# random hamlet

This is kinda low effort and if gets disapproved, I'll get two disapprovals in a row because of this :(

#

hope I won't get annihilated because of that

open arch
#

I am going to make a stupid youtube video for this first step

#

ugh there is only one simple issue, and thats it gives income even tho you dont have export

random hamlet
#

is there a way to check if is road near building connected to the edge of the map?

open arch
#

and once you remove the older factory it still gives the income of it.. atleast it shows a life sempthom

#

it is sure my lua code is going to be longer and more complicated

random hamlet
#

what the fu

#

um....

#

is there any way to make cords relative to screen dimensions?

#

like, If i make the window smaller, text stays in the same place and I can't see it

potent jolt
#

youd have to get the screen size occasionally

#

id just get them in script:init

#

as 90% of poeple play on mobile anyways

random hamlet
#

couldn't find

potent jolt
#

have you tried getting the root gui element?

#

thatll most likely be a canvas of the entire screen

random hamlet
#

I didn't but I will

uncut field
#

The problem with grabbing the resolution once is that the plug-in will not display correctly if the window is resized on PC (or if the player puts the game in dual-screen mode on mobile)

#

I would do something like
width, height = Drawing.getSize()

#

I think that works

#

Then you can use width and height to make custom UI stuff stay relative with the edges of the screen

random hamlet
#

Well yeah, that's what I was thinking

#

I just didn't know how to grab width and height

#

Actually, I think grabbing resolution once will be enough

#

There is not much players on pc, and I don't think most of them will start swinging their window and check if a plugin by some random Simon works with that

potent jolt
#

thats why you should first check if youre on pc

#

and if on pc, get it per frame

#

pc has enough performance that its not aproblem

random hamlet
#

Just curious, is taking width and height that performance heavy for phone?

#

And I think recording these parameters once is enough

potent jolt
#

its probably not taht bad

#

but best to have as little overhead as possible

uncut field
#

Like I said though, it is possible for mobile users to change resolution through the split screen feature many phones have nowadays, so that's something to consider

open arch
#

I need a little bit help guys

#

I had two problems and now I fixed the one of them. Easiest one

#

Other problem is something I didnt get, here is the concept: lua counts the factories and gives the amount of income with a calculation. It was all great and working but and then I removed one of the factories and it started to overlap the new and the old income at the same time
I guess it has to reset city.count but it just overlaps it. How do I fix this?

#

I can give the code example from DMs if you are interested to help me

open arch
stoic vector
# uncut field I would do something like width, height = Drawing.getSize()

GUI.getRoot():getWidth() and GUI.getRoot():getHeight() are the same as Drawing.getSize() but according to gui scaling settings
If you don't believe me, try this code:

local width, height
GUI:getRoot():addCanvas {
	onInit = function(self)
		local paddingLeft, paddingTop, paddingRight, paddingBottom = GUI.getRoot():getPadding() --in case of notches
		width = self:getWidth() + paddingLeft + paddingRight
		height = self:getHeight() + paddingTop + paddingBottom
		self:delete()
	end
}```
open arch
#

woa

#

in future I might want to use gui thingies but in very far future

uncut field
#

How can I detect when the city is in winter mode? I know there is a fun value for the winter mode setting (auto, on, off), but I don't know what to do if its set to auto

open arch
#

@potent jolt I cant send DMs, discord is broken soo
((amount_cokebatterychimney / amount_cokebattery) * 200) Imagine this number turning into income, what would happen if cokebatterychimney is 3 and cokebattery is 2

#

oh my

#

my math is soo bad

#

sorry

#

but what would happen if the numbers are like this? 457,5754..

#

maybe like chimney is 5 and battery is 3 soo 5/3*200 is 10000/3

potent jolt
#

Big number

open arch
#

wdym

potent jolt
#

Well if chimney is 5 and battery 3

#

Thattll give you about 1.66

#

*200

open arch
#

soo it turns those strange numbers to nearest ones

potent jolt
#

What do you mean

#

Fractions?

open arch
#

yea

potent jolt
#

They become something like 1.333333333

#

Accurate enough

#

When theons can only be rounded as full numbers

open arch
stoic vector
potent jolt
uncut field
#

I know how to read the setting

#

But if its set to auto, I don't know when its winter

potent jolt
#

You gotta use the date but idk which ones

uncut field
#

That's annoying, and expected

potent jolt
#

I do wish there was an easier way to bind an event to a variable change

#

Instead of just checking if it's changed every frame

#

Maybe I could make a library for that

uncut field
#

ikr

#

I was thinking about that issue yesterday

potent jolt
#

Shouldn't be too hard to make a function for it

#

That observes a variable and calls a callback when it changes

open arch
#

do you guys think if I use overlay for income once every in game year, or would it be annoying?

potent jolt
#

It wouldn't inform the user that the income came from your buildings though

#

Instead probably would be better to use a dialog of a yearly report

open arch
#

oh oh oh right there is city notifications, I might use it!

potent jolt
#

That would be best

open arch
#

and I might make a factory manager man saying that

potent jolt
#

Doesn't get in the way

#

The poeple all have their own draft IDs

#

Pretty sure they're available in the JSON article

uncut field
#

There is a way to add a custom income category to the Financials screen

open arch
#

yep I did it

#

and I might also make a notification once someone puts more factories than chimneys soo the factory has stoped due technical issues

stoic vector
open arch
#

this is the one I used

#

I should think about balancing

#

since it gives income

#

I am gonna use math for spendmoney, soo it is going to be strange to play with

open arch
#

amount_export > 0 and amount_blastfurnace > 0 and amount_blastfurnacechimney > 0 and (amount_blastfurnace <= amount_blastfurnacechimney) and amount_cokebattery > 0 and amount_cokebatterychimney > 0 and (amount_cokebattery <= amount_cokebatterychimney) and (amount_blastfurnace <= amount_cokebattery) then

#

this is looking soo dumb

#

I made this soo confusing that I dont even know the best combination

#

if you have the minumum requirements you just earn 330 monthly

open arch
#

there is also gas silo for blastfurnace that can add some income to it but gotta do it hard to achieve

open arch
#

I am done with this, it was hard to balance. I hope I did it good. It is too complicated to get the best combinations. I might make a gui that does calculations and shows "estimated income" of the current factory

#

I might even add explosions if there is a false combination without fixing it in a year

open arch
#

city.countBuildings(), it works when I decrase the amount of buildings (like 2 to 1) but once I remove all buildings it doesnt change the number to 0

random hamlet
#

what does it return?

#

is there a thing that checks if are some buildings in city?

open arch
#

I can't see it inside the code but when in game it looks like it holds the latest numbers

open arch
random hamlet
#

try some debug stuff

open arch
#

hmm

random hamlet
#

like debug.toast with count when it updates

#

or idk

open arch
#

yeah there should be something

#

you are right, count is working but somehow, spends is still going on

#

one last test and I will buy seeds for the chickens

random hamlet
#

does it return 0 but still spends?

open arch
#

found it, it was about a bool. Probably using it in wrong way

#

bool works like how it supposed to but doesnt run and close the functions

#

thank you dude for the help

random hamlet
#

figured out screen width and height stuff

#

okay this is not what I should've used

#

need subtraction i guess

#

it sucks

#

I made the x a static number and the y relative to screen size

#

got the cords

#

PERFECT

#

time to test on phone

random hamlet
#

I have no idea what basic thing should I make with lua to learn it

potent jolt
#

This is as a starting project as any

#

I started with the text placing tool

#

Maybe went in a bit too hard

misty python
#

cinematic camera tool is cool though

potent jolt
#

That took a while to get working

#

Had to take the 1st version of it down cuz it literally didn't work on mobile

misty python
#

how about we just

#

remove mobile

potent jolt
#

Good idea

#

No longer are we bound by performance limitations

gentle canopy
#

And touch screen UI

random hamlet
#

@potent joltdo you know why playtime counter doesn't work on mobile?

potent jolt
#

idk

random hamlet
#

sad momento

#

idk what should I make next

#

right now I am not in a mood to do sworldgen or normal plugins

potent jolt
#

world gen is complex

random hamlet
#

Actually my sworldgen is almost finished, I just need to make that customization thing

#

The point is

#

That I'll need to switch every number in formulas by a number

#

And some more stuff

#

It's easy but needs some time

#

Also I'll need to use a lot of global keywords which is not good

open arch
#

where do you guys put your notifications in? script:daily or monthly

#

do I need tables for notifications?

potent jolt
#

putting it daily is a terrible idea

open arch
#

oh sorry I meant script:nextDay

potent jolt
#

even then

#

thats way too often

open arch
#

hmm okay I guess I will do monthly

random hamlet
#

Wdym tables for notifications

open arch
#

I though they were strange things to use but they are kinda like json, I got it

random hamlet
#

I don't understand what is that

#

Also arrays

#

I understand about arrays in python

#

Or something

#

But how can they be used in TT

#

Especially if they get erased after game is closed I guess

#

Ask I understand, arrays in TT are just arrays to

#

And you can add/remove stuff

open arch
#

I am not sure if I wrote this true but icon and text are contents of table probably

#

inside {}

random hamlet
#

O good

#

Is this just notification pop up?

#

I guess it is

open arch
#

yep

random hamlet
#

By the way

#

I like the idea of your plugin and it just looks epic already

#

I hope I'll be able to create something like this if I learn lua

#

Very nice

open arch
#

thanks, I have soo many ideas in my mind. This is just going to be start

#

I actually had a better idea other than counting buildings but for now this will stay

random hamlet
#

I have some ideas of stuff I can make with lua but actually I know almost nothing

open arch
#

I have 10 building textures and 5 truck textures left, possibly the thing that is going to take soo much time. Considering making industrial buildings harder

random hamlet
#

Sad

#

Are there any tutorials on how to make disaster?

open arch
#

this is the manager for now

open arch
random hamlet
#

Like so you can activate it with a button and select cords and all

random hamlet
light plinth
#

sick textures

random hamlet
#

I think disasters is just destroying buildings on certain cords near activation cords, with some fancy animations

#

But I have no idea how to activate it using fancy button and how to make cords selection

#

Hm I got some nice idea, wonder if will it work

#

That feeling when you're randomly checking api, and see some function which feels very epic and useful even though you don't have an idea of how can you use it

open arch
#

lol

random hamlet
#

Is there a function to destroy a building?

#

So it leaves that dirt or something

open arch
#

yes

open arch
random hamlet
#

I mean

#

One second

#

Destroy a building so it disappears but leaves this terrain on it's territory

#

So you can use this for disasters

open arch
#

you can use build

#

and use that dirt's draft

#

but you know what, you can make disasters with fun codes too

#

I dont know which one is harder tho

random hamlet
#

Huh

#

How

#

Is there any way I can view disaster codes

#

Plugins/vanilla

open arch
#

this is a disaster plugin by kingtut, shouldnt be lua

random hamlet
#

Okay

open arch
random hamlet
#

His download link doesn't work for me on mobile

#

Ah ok

open arch
#

you can open it and check the json

random hamlet
#

Thanks

uncut field
#

I havent made any tutorials about custom disasters because there isn't a clear-cut way to create them

#

You need to have underlying knowledge of either lua or fun to make them work

#

Fun is okay for simple disasters, like the slime, but lua is recommended

random hamlet
#

K, thanks

#

I'll make some less complicated stuff before anyways

#

Just don't know what ones

#

Maybe I'll get an idea soon

uncut field
#

You are right about most disasters being fancy animations though

#

Tornado, meteor, flood, nuke, etc all fit this description

#

If you think about it, most of these disasters just replace nearby tiles with rubble

#

You just have to find a cool way to do that

#

Maybe a black hole that expands outwards and shrinks back down would be neat

open arch
#

I break the code I made, it acts strange now

potent jolt
#

lots of potential with those for sure

random hamlet
#

I have a pretty cool idea for a plugin I might make with lua, may start tomorrow

#

But I may be overrating my knowledge

#

Let's see how it goes

open arch
#

this is smallest steel factory income

#

I forgot to add building monthly spends soo with that, monthly income changes from 820 to 300 theons for it

#

I hope this is balanced

#

the buildings and factories prices are near millions and you wont get refund if you remove them

light plinth
#

dw wbyk iid

light plinth
#

might be

open arch
#

management office is 1, good to go is true and total_steelfactory is 1470

#

notification isnt poping up, that how it is intended but it is not spending the money now

light plinth
#

those warnings

open arch
#

I think I am using not good_to_go wrong

stoic vector
#
Drawing.drawImage(1, 0, 0)```
potent jolt
light plinth
#

fine

#

don't worry, will break your knees if it do

potent jolt
#

{} means a table

#

And in lua putting {} after a function is the same as doing function ({})

#

It's a convenience thing

open arch
#

thank you, looks like I am going to look into tables

#

๐Ÿ˜Ž

#

my guy

#

it works, it does reduce the monthly spendings to quarter and removes the income and also show the dude if there is a combination fail

#

appearently there is a blast furnace that needs atleast 1 chimney

#

in future might make the dude say the exact problem about the factory

uncut field
#

This reminds me of when I first started working on the prison expansion

potent jolt
#

That res

open arch
#

this is be similar to prison expansion but way simplier in coding

#

I mean I dont know much about coding yet

open arch
#

Can I have requirements for upgrades? or do we still need fun codes or lua for that

random hamlet
#

Maybe yes

#

Idk

#

Try putting requirement code in update code

open arch
#

5 years ago, I hope they added it now

median condor
#

I might end up creating a ski resort pack after all

#

With lua to get ski resort income and stuff

random hamlet
#

how do I play a sound without defines cords?

#

so it'll be "everywhere"

open arch
#

like music in game?

random hamlet
#

nvm

#

found it

potent jolt
#

use Theotown.playsound

random hamlet
#

yeah, there is two sound playing functions

#

I was looking at the wrong one

open arch
#

which one has x and y?

potent jolt
#

city.playsound

#

as it plays the sound on a tile

open arch
#

hmm

#

like party house o.o

potent jolt
#

yes

random hamlet
#

how do I create a sound draft?

open arch
potent jolt
#

well it has some old legacy code in there thats not understandable

#

and also the code to make the rgb window

random hamlet
#

how do I make a sound draft aa

potent jolt
#

gimme 1 sec

open arch
potent jolt
#
    {
    "id":"bluepickle.plugin.meme.song",
    "type":"sound",
    "file":"file.mp3",
    "volume":1.0
    },
random hamlet
#

thanks

potent jolt
open arch
#

niceee

potent jolt
#
--[[

  Update 1.9.06 should implement City.playSound function which would allow for location based sound.
  In addition, it would solve the issues with leaveCity() and leaveStage() events.

]]
#

as stated at the start of its lua

open arch
#

I can now put the same sound of the factory 500m near me. I just have to record it at the roof (also at night cus otherwise there are annoying birds)

#

jk birds are way better than factory sounds

potent jolt
#

id just steal borrow some sounds from online

#

*without copyright infringement

#

theres probably plenty of factory sound effects out there

random hamlet
#

I remember that you can play sounds from several buildings but it's pain to make

potent jolt
#

possible if you keep track of their locations

#

but yes a pain

open arch
#

the first sound thing I made is impos tower, it doesnt use lua but really bad

#

you can spam click it and sound will overlap

#

what is this

misty python
#

color

open arch
#

I thought we cant use color for buildings but animations

random hamlet
#

can someone show me the syntax?

#

Maybe I am doing something wrong

open arch
#

hold on

#

oh okay

random hamlet
#

(it doesn't work so it's more than a maybe)

open arch
#

you might try to use getdraft in script init

#

and put a veriable for it

random hamlet
#

ahh

#

okay

potent jolt
random hamlet
#

it's for testing

potent jolt
#

That will start playing the sound every frame

random hamlet
#

a

potent jolt
#

It will not work

#

You have to call it once

open arch
#

use cityenter

#

if it is just for testing I guess

potent jolt
#

Then you get a table back where with which you can control it's position and stop/play it

random hamlet
#

how do I wait until disaster happens or something

open arch
#

there should be script event

potent jolt
#

There is

open arch
#

i am not sure if it contains those

#

oh

potent jolt
#

Not sure if that works for custom disasters

random hamlet
#

I mean any disaster

open arch
#

I think he is trying to use it for in game disasters

random hamlet
#

vanilla at least

potent jolt
#

Wait nvm

#

I got confused

open arch
#

there was a plugin tornado siren by mg but it is kinda broken, another siren would be nice

#

mg probably used fun**

random hamlet
#

where pickle

open arch
#

lua should be better

potent jolt
#

There is no disaster event

#

But you can check if one is ongoing

misty python
#

plot twist: a pickle is just green slime in disguise

random hamlet
#

now I should learn to use events

potent jolt
#

Pickle is a DSA thing

open arch
#

i tried them to make a sand spider, I failed a lot but it was my first tries in lua

potent jolt
#

Blame ja for having a bad api

random hamlet
#

how do I make an event lmao((

potent jolt
#

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

misty python
#

blame it all on JA

potent jolt
#

Don't think you can

#

No custom events here

random hamlet
#

what

open arch
#

I guess he meant how he uses it

random hamlet
#

ah

#

I got an idea maybe

#

I mean

#

init and update are events too?

open arch
#

nope

random hamlet
#

ah

#

how do I use events then

open arch
#

init works since the start of the game and update works 60fps once you are in a city

potent jolt
#

Well

open arch
#

oh

potent jolt
#

Technically they're event functions

open arch
#

there isnt events for disasters?

potent jolt
#

They just don't fall under script:event

open arch
#

oh okay

potent jolt
#

There is not

random hamlet
#

how do I make an event function

potent jolt
#

But you could check for a disaster daily

random hamlet
#

so it does something when disaster fire happens as example

potent jolt
#

Check for it daily

random hamlet
#

how

potent jolt
#

Then raise the function you want

#

City getdisaster

#

Then compare it with DISASTER_FIRE

#

To check if it's going on

random hamlet
#

I don't really understand.. every day it checks for a disasters and if it's fire it calls function which does something?

potent jolt
#

Yes

random hamlet
#

okay

open arch
#

wow

potent jolt
#

Using daily cuz every frame is way too often

random hamlet
#

I will try

open arch
#

@random hamlet I want to suggest this, make the sound come from the siren pole. It would be nicer. But I guess you are just testing things now

random hamlet
#

yes

#

I may try making sound play only if at least 1 siren is in city

#

I also had an idea of making different sounds for different disasters like in cities:skylines but It may be too hard

#

idk I'll see

open arch
#

also different siren poles / sources for different disasters also different sounds. Like nuclear disaster is https://www.youtube.com/watch?v=K_vZk1f353I

70-plus emergency sirens around the Artificial Island nuclear generating complex were tested on Tuesday. The sirens -- 34 in New Jersey and 37 in Delaware -- located within the 10-mile radius of the three reactors operated by PSEG Nuclear will sound for three minutes.
They are part of the alert system that would inform those living near the Arti...

โ–ถ Play video
random hamlet
#

yeah and this too ofc

open arch
random hamlet
#

ah you mean different poles to react to different disasters

open arch
#

yeah

random hamlet
#

I'll think

open arch
#

also you can do this, make a code that checks if any nuclear power plant is on fire and then if it is yes some sound like this plays

random hamlet
#

https://www.youtube.com/watch?v=xhWUUblpDZA I thought something like this by default

SFX

Copyright owner: [Merlin] Symphonic Distribution, Unbound Beasts
Use of content: The Northeast Russian Blues (ะจั€ะฐะผั‹ ัะดะตั€ะฝะพะน ะฒะพะนะฝั‹) Venator

โœ”Subscribe
โœ”Like
โœ”Coment

Source : www.youtube.com
If you noticed in any of the material that infringes copyright, please report it

โ–ถ Play video
#

sounds epic tho

open arch
#

this is exact same sound like ra2 nuclear silo lol

random hamlet
#

actually I have a fart sound effect for testing now lol

random hamlet
#

I need to find something that isn't copyrighted I guess

#

idk if is this one?

open arch
random hamlet
#

btw what does getDisaster() return when there is fire?

open arch
#

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

#

oh

random hamlet
#

DISASTER_FIRE ?

open arch
#

it returns yea

#

that

#

probably

#

Returns the name of the curretly active disaster or nil if no disaster is is active right now.

#

I guess you need something like this
if DISASTER_FIRE == true then ...

potent jolt
#

Yes

#

Wait no

open arch
#

yay

#

:c

potent jolt
#

If DISASTER_FIRE == disaster

open arch
#

oh

potent jolt
#

Where disaster is the disaster city getdisaster returned

open arch
#

that kinda strange

potent jolt
#

So if DISASTER_FIRE == City.getDisaster() then

#

How's that strange

open arch
#

oh oh oh yeah , I see now

random hamlet
#

will something like this work?

potent jolt
#

You're checking if it's returned a matching value

#

Ye

open arch
#

yeah probably

potent jolt
#

Wait no

#

No qoutes

random hamlet
#

no quotes?

open arch
#

' this?

potent jolt
#

Use City.DISASTER_FIRE

random hamlet
#

aaaa

#

okay

open arch
#

oo

potent jolt
#

The value is just a constant number

#

It just represents disaster fire

random hamlet
#

wait yes im dumb

#

the string would be constant

#

oh wait nvm

open arch
#

confused ungaa bunga

random hamlet
#

I got it wrong when trying to explain what did i get wrong

potent jolt
#

City getdisaster doesn't return a string

#

It returns a number

#

If it's a fire disaster it will match the number of City.DISASTER_FIRE

open arch
#

o thats good

random hamlet
#

okay

#

now where should I put it\

#

because if it's nextday

#

it will still call repeatedly

open arch
#

make a local function maybe?

#

wait no

potent jolt
#

Nextday is spare enough that it's acceptable

#

But you have to make sure it only gets run once

#

Or it will be called every day the disaster is ongoing

open arch
#

it would overlap if there are two nukes

potent jolt
#

just have a bool to keep track of if youre running the sound

#

if yes, dont do it again

#

then when getdisaster is nil, stop playing the sound and set it to false

random hamlet
#

will this work or no?

potent jolt
#

yes

potent jolt
#

although you should probably use local dis

#

instead of making it global

open arch
#

for the function siren right?

potent jolt
#

unless siren needs the variable it should be local

random hamlet
#

okay

open arch
#

I cant hear images

random hamlet
#

it doesn't play sound for now

potent jolt
#

so the toast did not get calle

#

try toasting dis

random hamlet
#

I guess

#

k

potent jolt
#

and also city.disaster_fire to check if they match

random hamlet
#

maybe that's because it's debug and not Debug?

open arch
#

yeah

#

try it with caps at the first letter

random hamlet
#

it worked

#

time to enable fart

potent jolt
#

ah yes

#

ofc

open arch
#

constant fard.mp3 plays

misty python
#

lmao

random hamlet
#

I should record this

open arch
#

btw what happened to your modular buildings pack and light fences

random hamlet
#

a very quick break for lua

#

bc I was not in a mood to draw

#

I'll continue very soon

open arch
#

I can relate

random hamlet
#

:)

open arch
#

cursed

misty python
#

lmao

potent jolt
#

lmao

#

next youd just check if the sound is already playing or not

open arch
#

sound matching of fire and fard

open arch
#

no

#

make a siren head disaster

random hamlet
#

lo

#

May 15th, 2014. Went to St. Paul, Nebraska to record their Thunderbolt 1003. My dad works with a guy from the fire department there and said they test the fire signal on the 15th of the month, so I had to go see.

NOTE: It is NOT mounted solely on a tall standpipe nor does it even have a standpipe. The air from the blower passes through the pole...

โ–ถ Play video
open arch
#

I think use normal tornado siren and at april fools change it with siren head one

random hamlet
#

I may make it random 1 to 25 or something

#

or to 75

open arch
#

o yeah

misty python
open arch
random hamlet
#

I hope I won't get disapproved for that lol

potent jolt
#

i dont even know what this means

random hamlet
#

does the code wait until sound stops?

#

or it starts playing sound and continues?

#

@open archdo you know?

potent jolt
#

it starts playing and continues to run

potent jolt
#

otherwise the game would freeze

random hamlet
#

how do I make it run until the sound ends so it can switch the variable to false

#

i want to indicate if sound plays or not

open arch
#

make it end after 5 seconds of disaster

#

with a bool

random hamlet
#

I may make the sound 1 theoday long

#

lol

#

why not

potent jolt
#

you can set a sound as looping

random hamlet
#

I want to know if sound plays or no

open arch
#

he doesnt needs to tho

random hamlet
#

So I may start it once

#

and it won't repeat

open arch
#

start it once and also add something to stop it

random hamlet
#

how do I stop noise though

open arch
#

sound?

random hamlet
#

I may make it stop when disaster is off

#

yes

potent jolt
#

playsound returns a table

#

you can use .stop() on it to stop the sound

open arch
#

like erksmit said use bool

#

for disasters

random hamlet
#

k

open arch
#

if not dis then City.stop() ...

#

idk

random hamlet
#

something like this

open arch
#

yeah

random hamlet
#

should I use .stop() like sound draft.stop() ?

open arch
#

and from what erksmit teach me use if not is_disaster_active then

random hamlet
#

oh

#

I can have this?

#

I just can't find some functions sometimes

#

where is it

open arch
#

what?

random hamlet
#

wait

#

i am dumb

open arch
#

I dont know how .stop works

random hamlet
#

I'll try something now

open arch
#

I gtg now have to water the plants

random hamlet
#

k

#

I messed something up with bools

#

nvm, fixed

#

time to try with actual siren

#

I should have a siren sound effect somewhere on my pc

#

can't find it tho

potent jolt
#

wait wheres the sound

random hamlet
#

yup found it

#

exactly what I need

#

just perfect

#

(don't mind me having random air raid siren files on my computer)

potent jolt
#

oh thats a wma

#

hang on

#

i got this

random hamlet
potent jolt
random hamlet
#

found this on pc

#

o

#

epic

light plinth
#

glad I made a scripting channel

potent jolt
#

will use for my next plugin

potent jolt
light plinth
#

yes

potent jolt
#

ofc

light plinth
#

working on a cool thing

#

Might see it at the end of the summer

potent jolt
#

hmm

random hamlet
#

siren works

#

I hope this is not too much bools

#

oh it makes sound when you leave the city, I'll fix that

#

maybe it does too much for every day

potent jolt
#

maybe because all of your variables arent local

random hamlet
#

ah

#

this will help?

#

I thought of making them local later

potent jolt
#

also it can be simplified

light plinth
#

yandev code with bugs

random hamlet
#

I think this should work for all disasters, but I can simplify it even more

#

it worked with tornado

#

doesn't stop the sound though

random hamlet
#

and remove the variable

potent jolt
#

can you paste the bit here so i can change it

random hamlet
#

one second I'll try this myself

#

@potent joltcan you tell me how do I stop sound? what should I put in .stop()?

#

variable with sound draft?

potent jolt
#

yes

#

do soung = city.playsound

random hamlet
#

okay, thanks

potent jolt
#

then you can do sound.stop()

#

on the same variable

random hamlet
#

@potent jolt can you give me an example of how should it look if my sound draft var is called s?

#

i tried it

#

didn't work

potent jolt
#

just do s.stop() to stop the sound

random hamlet
#

didn't work

#

maybe I am doing something wrong

#

the condition calls once but doesn't stop sound

#

I even tried putting this into a separate function, didn't work

#

had to sacrifice the ladder for a test :(

#

it stopped randomly before 5-10 secs the tornado disaster ended though

#

doesn't stop with meteorite too

#

@potent joltthis thing doesn't work for me

#

I messed something up again

#

the function doesn't activate probably even though it's nil

potent jolt
#

put a debug toast there to make sure it gets run

random hamlet
#

It was there and I think it actually did, lemme do it again

#

it gets called

#

but sometimes randomly, because of the condition I think

#

@potent joltit gets called but doesn't work

#

I can't understand why doesn't it work

potent jolt
#

are you sure s is the same variable

#

or if its a sound object at all

random hamlet
#

also this function is supposed to be called if these is no disasters but siren is on

#

but it doesn't

#

aaaand the function still isn't called as I can see

light plinth
#

you're passing the draft there, not the playSound function object

random hamlet
#

how do I pass playsound

light plinth
#

sound = TheoTown.playSound(...)

random hamlet
#

okay, let me try

#

it worked

#

thanks

#

works just perfectly

#

NO NO NO UFO WHAT ARE YOU DOING

#

I made a separate "outro" sound

#

so when siren ends it plays a fade out sounds

#

it stutters a bit now

light moon
random hamlet
#

but I recorded a video

random hamlet
light moon
#

Maybe

#

Its been alive to long*

random hamlet
#

kinda sus ngl ๐Ÿ˜ซ

#

@potent joltso how do I optimise it?

#

I remember you saying about local variable

#

but will it work if it's used in 2 functions?

open arch
random hamlet
#

it's defined to false on startup (not sure it's necessary), used to check in some daily conditions and it's important in stop siren function

potent jolt
#

you can define the variable outside the function

#

and stilll have it local

#

just put local varName

#

at the top of your file

random hamlet
#

so I can make it local without changing code?

potent jolt
#

yes

random hamlet
#

I have this

#

will it work or It should be outside all functions?

#

yup I changed it to local there and it works I guess

#

ngl that siren over disasters is kind of epic

#

it works with pickle disaster omg

#

imma record

#

it's epic but man that stuttering

potent jolt
#

you dont need a plugin to change disaster music though

random hamlet
#

I don't need a plugin to what...

open arch
random hamlet
#

I dunno, the air raid siren over a huge pickle is hilarious

#

go ahead, take a ride

#

wait I can't do that in lua

light plinth
#

This isn't python

#

You have to write actual code

random hamlet
#

why is "in" thing not an actual code

light plinth
#

That's a python only thing, as far as I'm aware

random hamlet
#

sad

#

it would be an easy way to blacklist some disasters

#

I shot a meteorite and the game suddenly played openTTD soundtrack

#

I forgot that i added it, thought it doesn't work

#

It means I just openTTD'ed myself

potent jolt
#

youd have to make a table, iterate through the table and compare each of its elements

#

it would take a lot of space

#

and be slow

#

lua is very barebones

random hamlet
#

idk I just blacklisted fire by condition

#

(because who would start air raid siren across the entire town when a building starts burning)

light plinth
random hamlet
#

hm yes an achievement

light plinth
#

Why not just use the City.playSound then?

random hamlet
#

That's what I use lmao

light plinth
potent jolt
#

also

#

is it really faster than python if youre running it on java

light plinth
potent jolt
#

well

#

i doubt that python will be faster if its also running on java

#

also

#

perhaps

light plinth
#

Well

#

They are both slow if we compare them to Java

#

And Java is slower than C

potent jolt
#

ofc

#

but its fast enough

light plinth
#

Factor in the overhead and you got extreme speed

potent jolt
#

java api when

#

lets call them java scripts

light plinth
potent jolt
#

tru

#

theres really no need

#

i dont have a very good device but i have no noticable impact with my scripts

light plinth
#

android api changes every year and keeps privacy and IO changes which you need to spend time to patch to support newer versions

#

Android development is a huge pain

potent jolt
light plinth
#

Not even full Java 8 experience

potent jolt
#

i see only 1 solution here

#

drop 90% of the playerbase and go pc only

#

nintendo switch release when

light plinth
#

or drop the 2% of the playerbase and go Java

potent jolt
#

ah yes

random hamlet
#

Lol I showed video of my siren to my friend

#

and then remembered he lives in Israel

open arch
#

._.

potent jolt
#

lua is fast until you do this

random hamlet
#

If I link my script to a building, sounds will overlap when there is a lot of them, right?

potent jolt
#

yes

#

you could limit the maximum amount of the building

burnt fox
#

How tall could you make a building?

random hamlet
#

nah limit is not what I want to make

burnt fox
#

What?

#

I'm only asking cause I'm curious

potent jolt
#

in 1 frame

#

as tall as texture size

#

with animations

#

as tall as youd like

#

although it will stop rendering when it goes offscreen

#

theoretically

burnt fox
#

hmm.........

potent jolt
#

you could use lua drawing to make sure it always gets drawn

burnt fox
#

If I wasn't on a chromebook, I think I would start breaking the game at this point in time

#

or at least try to

random hamlet
#

you can change building height as I remember

#

and add a ton of floors with animations

potent jolt
#

yes but that will stop drawing the building when the base goes out of frame

#

using lua you could bruteforce it

#

so it always gets drawn

random hamlet
#

what

#

I mean

potent jolt
#

maybe sprinkle in some optimization to only draw the visible part

random hamlet
#

if you scroll up, building height prevents that?

potent jolt
#

only the base counts towards that

#

as the rest is animation

random hamlet
#

you can change building height

potent jolt
#

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

#

im not trying it out

random hamlet
#

I did

#

I mean you should know it

#

but you can put it in json

#

I fixed my animated skyscrapers disappearing like that

open arch
#

you can use animations to make the tallest possible thing too but there might be texture glitches

#

idea: space elevator

light plinth
#

there is a limit

random hamlet
#

I actually wanted to do that for cyberpunk plugin

open arch
#

ok then you need lua anyways

random hamlet
#

@potent jolthey can you give tips with optimising the script, if you're not busy or something?

#

I can send code to dms if needed

#

I made some variables local as possible

#

I think it lags the most because of this but idk what should I do with it

potent jolt
#

can you paste it here so i dont have to type it over

random hamlet
#

idk maybe dms? I don't really want to paste my code in public channel tbh

potent jolt
#

sure

#

im not typing that over

random hamlet
#

I can't add you

#

wait i can

#

just me being stupid, sorry

#

I sent a request

random hamlet
#

bruh lua random is kinda broken I guess

#

without the additional tricks

light plinth
#

lua random?

random hamlet
#

I can do this

#

and it works

#

but it's not TT

#

also, I used math. thing in another code and It may be the cause it didn't work on mobile

#

(I suspect)

light plinth
#

the amount of method calls

random hamlet
#

๐Ÿคทโ€โ™‚๏ธ yeah not mine code

#

probably should avoid it

#

but... so there is no a good way to get random number?

#

this should be an important thing

light plinth
#

I don't know what that does

#

But it's likely it just sets the seed to same value

random hamlet
#

yes

light plinth
#

And then, the random becomes the same value every time

random hamlet
#

idk

#

without it, the random returned the same thing

#

now it returns different numbers, at least every launch

#

I would like to make an easter egg which would be activated with certain probability

#

but I'll need random

light plinth
#

Just do

#

math.randomseed(Runtime.getTime())
math.random(1, 5000)

random hamlet
#

this will work on mobile?

potent jolt
#

why wouldnt it

random hamlet
#

idk

#

just in case

misty python
#

man, lua looks complicated and people say it's simple

random hamlet
#

I mean

#

Depends on what are you going to make

#

And on who wrote the code you're seeing

random hamlet
misty python
#

ye

#

i've wrote some vbs and batch programs

#

(html and json as well but i mean, you just assign tags and stuff)

random hamlet
#

It's actually not that complicated for real

#

Well, mostly

#

Except if it's some super complicated code

#

Or it's spaghetti (by me)

misty python
light plinth
#

Can I recommend a book?

misty python
random hamlet
#

@misty python lol I just started with doing some print() and If conditions

#

And testing if will stuff from python work

#

I made a siren thing after 2-3 days of doing first ever thing in lua

misty python
#

i want to make something like this. pretty complicated for a first lua project, but i mean, where's the fun in starting small, haha

random hamlet
#

I mean

#

This one looks very complicated

potent jolt
#

like they deserve

random hamlet
#

I know doing small things may not be fun

#

But dude

#

You said you don't have much experience in coding and lua

potent jolt
#

go big or go home

#

but honestly

potent jolt
#

once you figure out how to do 1 chain the rest is easy

potent jolt
light plinth
#

although you're not entirely wrong

#

System crashing IS garbage collection on its own

potent jolt
#

not like theres much to gerbage collect in my plugins

#

most of it is always kept

misty python
light plinth
random hamlet
#

This project is sooo big

#

Ah ok

potent jolt
random hamlet
#

I thought you meant literally first project

light plinth
potent jolt
#

ok

light plinth
#

If didn't catch my meaning

potent jolt
#

so the garbage collector should have no issue collecting them

#

i am memory safe wrong

misty python
random hamlet
#

Also, if you don't know basics in lua, I recommend you making something standalone as I did

potent jolt
#

anyways