#plugin-lua-and-fun

1 messages · Page 5 of 1

dusky pike
#

Thx

torpid spear
#

colors are a native json function (though european buildings plugin uses lua solely because of the implementation)

dusky pike
torpid spear
#

yes

dusky pike
#

Wow, now i want to know how to do that :0

torpid spear
#

"colors" array on your animation drafts

dusky pike
dusky pike
#

Oh yea, what is nesting?

dusky pike
#

Is it like "colors": [{r, g, b}], or is it something else?

zinc isle
#

Also this isnt really lua so we should maybe moooove the chat?

torpid spear
#

never actually used the rgba format outside of lua where it is strictly required

#

I recommend to use hex

zinc isle
#

You made me use that that one time i had to change opacity lmao, took me forever to learn that i can use hex

torpid spear
#

well hex doesn't record alpha values

dusky pike
cedar spindle
#

emmmm

potent jolt
#

thank you for your insight 🙏

faint whale
#

Is there a way to automatically close a City.showNotification without having to press the button?

And yep, I know that they close automatically after +- 4 months in game, but if there is a way to make them close earlier, much better.

potent jolt
#

you could write your own version of it

#

alternatively you can try to find out the id of the gui created by it

zinc isle
#

Ppunish 772714302284365825

rare grottoBOT
zinc isle
#

@light plinth pidroid is kinda slow

light plinth
#

Pping

rare grottoBOT
light plinth
#

Works just fine

zinc isle
light plinth
#

He wasn't catching scam links for a year now

#

As that functionality was removed

zinc isle
#

whaat

#

oh so thats automod not doing its job, good to know
but punishment stuff was kinda slow and the tag command when i tried today

stoic vector
#

The Vanilla IAP ufo works like your clouds plugin?

torpid spear
#

lol what

faint whale
stoic vector
torpid spear
#

no?

#

it's hardcoded

rich junco
stoic vector
#

POV:you’re a dictator 💀

torpid spear
#

where's the lua in that

potent jolt
#

it was me, i did that

#

i hacked your game

snow pasture
native timber
#

I was just looking through TreeTool, and found the variables hoverX, hoverY, which are sort of not set anywhere. Are these really variables that are already in the game code?

weak mural
#

isn't it in function script:draw(tx, ty, hoverX, hoverY)?

it will be local for the block on the function and in another script that function will be called with the real arguments/variables.

#
-- like script:draw
local function foo(a, b)
  print(a, b)
end

do -- another script/code you can't see
  local a = 10
  local b = 42
  foo(a, b)
end

-- print nil because a, b are not global vars.
print(a, b)```
native timber
weak mural
#

yes, a simple way just declare the vars to be a local.

-- cursor position depends on the tile.
local mouseX = -1 -- declare invalid tile posts
local mouseY = -1

function script:draw(tx, ty, hx, hy)
  if tx == hx and tx == ty then
    mouseX = tx
    mouseY = ty

    -- actually you can call a function here
    Drawing.setTile(tx, ty, 16, -32)
    Drawing.drawText("Mouse was here", 0, 0, nil, 0.5, 0.5)
  end
end```
native timber
#

how i can use in-game frames with drawImage (frame, x, y)? (like night frames ot like them)

potent jolt
#

then use the various getFrames functions

#

for night frames, you have to get it's night animation

native timber
potent jolt
#

on closer inspection

#

i dont see a way to retrieve it from a draft itself

#

unless you were to use unsupported functionality

#

but i dont support it

native timber
#

at least id

potent jolt
#

doesnt look possible to me

native timber
#

how do i call EVENT_PLACED? i cant get it

#

dont work :/

torpid spear
#

if EVENT_PLACED == Script.EVENT_PLACED then

#

(blame yourself for naming the parameter like that)

light plinth
#

also

#

script:event, not script.event

#
function script:event (x, y, level, event, source)
  if event == Script.EVENT_PLACED then
    Debug.toast("building")
  end
end
native timber
torpid spear
#

does it make any difference

#

just don't use the coordinates

light plinth
#

You can't call it

#

You receive it

native timber
light plinth
#

the function signature is wrong

#

it has to be script:event (x, y, level, event, source)

native timber
#

._.

light plinth
#

restart the game

native timber
#

still

light plinth
#

is that the entire file?

native timber
#

function script:event (x, y, level, event, source)
      if event == Script.EVENT_PLACED then
        Debug.toast("building")
      end
    end```
light plinth
#

you are calling the getBuilding function during the script load

#

it wont work

native timber
#

init?

light plinth
#

put it under the function

native timber
#

still

#

if im put it in script:init

light plinth
#

show the entire code

native timber
torpid spear
#

init is game start

#

you can't use the tile module if there are no tiles to begin with

native timber
#

enterCity?

torpid spear
#

what is even the point of that function?

light plinth
#
  • init is called during game boot up, Tile library will not be accessible at that point in time
  • you are assigning the result of the entire tile.getBuild... to a global building variable, set it to a local one instead
  • if there's no building at the tile 1x1, the getDraft call will fail
light plinth
#

also luawrapper loses certain error reporting capabilities

weak mural
#

btw, the topics nav is gone. lol

light plinth
#

Cool

native timber
#

i dont need that draft for now, so then i can just put it in function itself

#

even at this variant, i dont see any signs of EVENT_PLACED work

torpid spear
#

did you actually attach it to a building

light plinth
#

It's emitted for the script owner draft

native timber
#

if source == building then
or
source = building?

torpid spear
#

???????????

native timber
#

how i should attach draft to this thing

#

to source, i think

torpid spear
#

in your json

#

"script"

#

you want to attach it to the building that you want to use that script

native timber
light plinth
#

No

#

Source is only for smart car events

#

otherwise, it's nil

torpid spear
#

please read your docs

#

why are you faster

light plinth
#

because I know how it works

#

it's holding up with stitches and hopes

torpid spear
#

as with all things in this game

native timber
#

so why its dont work then?

#

oh nevermind

#

its working

#

only for building in json, so it supposed to

#

god, this is such a nice thing

potent jolt
#

well you do need to attach your script to the draft

#

it wont run for every placement

native timber
#

...i need help.

potent jolt
#

yea

native timber
# potent jolt yea

i want to get every coordinate spot between two places, but idk how to
(i dont want to use just a bunch of ifs)

potent jolt
#

sounds like a regular old loop would do the tricp

#

do you know where to end

native timber
#

starter coords wrote to an array by placing building

native timber
# potent jolt sounds like a regular old loop would do the tricp

did this variant. Broken(

function script:event (x, y, level, event, source)
      if event == Script.EVENT_PLACED then
            local draft = Tile.getBuildingDraft (x, y)
            local xCords = Array()
            local yCords = Array()
            if a[4] == nil then
                  a:add(x)
                  a:add(y)
      else
            a:removeAt(1)
            a:removeAt(1)
            a:add(x)
            a:add(y)
      end
      if x>=a[1] then
            for i = 1, math.abs(x-a[1]) do
                  x=x-1
                  xCords:add(x)
            end
      else
            for i = 1, math.abs(a[1]-x) do
            a[1]=a[1]-1
            xCords:add(a[1])
            end
      end
      if y>=a[2] then
            for i = 1, math.abs(y-a[2]) do
                  y=y-1
                  yCords:add(y)
            end
      else
            for i = 1, math.abs(a[2]-y) do
                  a[2]=a[2]-1
                  yCords:add(a[2])
            end
      end
      if #xCords>#yCords then
            for i = 1, #xCords - #yCords do
                  yCords:add(yCords[#yCords])
            end
      elseif #xCords<#yCords then
            for i = 1, #yCords - #xCords do
                  xCords:add(xCords[#xCords])
            end
      end
      for i = 1, #xCords do
            Builder.buildBuilding(draft, xCords[i], yCords[i])
      end
      Debug.toast(tostring(a))
end
end```
#

is there any issues?

light plinth
#

well first of all

potent jolt
light plinth
#

nvm

#

my first recommendation would be

#

to indent it properly

potent jolt
#

mine would be to flip the if and return first

#

saves an indent

#

and i think you might be able to use this function

native timber
#

this thing uses rectangle, so i need a line

potent jolt
#

what kind of line

#

you should be able to use for loops to simplify this

#

this looks more complex than it has to be

native timber
# potent jolt what kind of line

we have two points, I want to try to get a line with a right angle between them.
Basically, I can rewrite the code to first define a point perpendicular to both of the original points and work from that point

native timber
potent jolt
#

yes

#

but the way youre using arrays seems unnecesary

#

mostly the a array

native timber
#

isnt array is a single possible way for it?

potent jolt
#

lets see

#

you can definitely use a local or something

#

so if i understand this correctly

#

like

#

what exactly is it doing

#

i mean

#

whats the end goal

#

other than building a building some distance away from the original

native timber
#

I'll figure out what to do with the coordinates I get

#

oh and yes

#

in future i should add function that cleans an array on building destroy

#

a array*

#

uhm

#

oh crap, how i see, i cant test coords on this building, because function calls multiple times

native timber
#

i did this.

#

yessir!

native timber
potent jolt
#

it could still be simpler

native timber
#

Id fully rewrote it

potent jolt
#

well

#

if it works it works

#

for now

native timber
potent jolt
#

i mean, if you ever need to change it again and forgot how it worked

native timber
#

hm

#

why script dont work without LuaWrapper

#

uuuuh

#

its working, but not for script event

#

wait what

#

oh i found the problem

potent jolt
#

¯_(ツ)_/¯

native timber
#

How to prevent the standard tile information from appearing when using script:click?

potent jolt
#

(its in the description)

native timber
#

thanks

#

but theres another problem

#

I need to use drawing after clicking on a building, however drawing requires script:update, which introduces the function into a loop. What can I do about this?

potent jolt
#

and use it's ondraw function

native timber
#

and

#

how to create full-size cansav

#

canvas

potent jolt
#

what are you trying to show

native timber
#

error by script:update

#

goody ah code for now, but i didnt even tried to make it normal

#

cords - array containing coordinates of all buildings of the given draft on the map

#

i should make it cloud-based in the future.

potent jolt
#

that wont work

#

script:update only works outside other functions

#

and it will be called every time

native timber
#

so

#

its works

#

but very strange

#

like bug-loop

#

uhm

#

in that way

#

what can I replace it with?

native timber
potent jolt
#

i still dont know what you want to achieve

native timber
#

I moved the function from event EVENT_PLACED to click, I want to when click on a building an image will appear above all buildings in the same draft to notify you of their location. The drawing is what is causing me problems.

potent jolt
#

make a bool that gets flipped when you tap the building

#

then check if its true in script:draw

native timber
#

Before I get started, I really need to know how I can display -1 level of building height with a script?

torpid spear
#

use Draft:getBuildHeight if that's what you mean

native timber
#

Like

#

Make player see tunnels

torpid spear
#

what....

#

display tunnels? you can't do that

#

as far as I'm aware

native timber
#

._.

potent jolt
#

it could be possible but youre going to have to do some digging

#

not like literally

#

you can use draftDrawers to enter tool drafts (this is undocumented)

#

if you can get the tool for showing tunnels and enter it it could work

#

but it requires research i havent done

native timber
#

uhm

#

It’s worth admitting that I still won’t be able to realize what I wanted due to some limitations

#

So

#

Out of curiosity, do I have the ability to change json-files using lua?

potent jolt
#

you can generate drafts on startup but you cannot change existing ones

native timber
#

Like price etc

potent jolt
#

no

light plinth
#

depends

native timber
trim remnant
#

Why ping him for that?

scenic wigeon
#

I think he has an idea of that someone?

potent jolt
#

hm

#

for something like that it probably isnt really possible

#

if you do create a fullscreen canvas there would not really be a way to get the building's drawing locations

#

that would work

#

but it might not inside the canvas

#

youre probably better off using something like script:draw or script:drawCity

#

i dont know if getting the drawing pivot will work in that function

#

youd have to test

#

right so you can get the root gui object with GUI.GetRoot

#

then youll be able to get it's width and height

#

and create a canvas of that size in it

potent jolt
#

rip the homie

native timber
native timber
#

whats select()? i cant find normal answer

potent jolt
#

dunno, never used it

native timber
#

huh

#

why this thing returns error

#

but this works

#

wth

#

what wrong with this one

#

the only one who dont work

potent jolt
#

probably only works in drawing context

#

like drawCity or draw script functions

native timber
#

i think i can use it for create canvas

potent jolt
#

getDrawXY is probably just a shorthand of a few drawing functions

native timber
#

my brain not braining today

#

uuuh

#

i dont see anything

potent jolt
#

i geuss its not on the top level of the gui then

#

also

#

why not just use script:overlay

#

or script:drawcity

native timber
potent jolt
#

then drawCity

native timber
#

oh hell

#

its over gui and i cant make it transparent

#

i cant click through it

potent jolt
#

yse the settouchthrough function in it

#

also yea

#

it will be over gui

#

thats what it do

#

if you want under gui you have to use drawcity

native timber
potent jolt
#

no

#

now youre creating a canvas every single frame

#

you can just draw directly

native timber
#

i absolutely cant understand how GUI scripting works

potent jolt
#

you can draw directly but it wont be gui

native timber
#

wdym draw directly?

potent jolt
#

just use the Drawing library

#

instead of gui

native timber
#

i cant

#

because script:event goes to loop

potent jolt
#

sounds like you need to rewrite it

native timber
#

and i dont see any other way to draw it

#

for executes too fast

potent jolt
#

because drawing in script:update isnt allowed

#

you must do your drawing for each frame in draw or drawcity

#

these functions run once per frame

#

if you dont always need to draw in the function, just return early

native timber
#

how do i

#

stop the drawing

#

i dont see return's work

#

still draws

potent jolt
#

return ends the function

#

nothing after it will be executed

#

so just put an if at the start

#

and return if you dont want to draw

native timber
#

can i get player's FPS?

#

for proper exetcution

potent jolt
#

with a bit of work, yes

#

but why would you need it

native timber
#

How doesDrawing.setScale() work? Why it isnt increase scale at all?

potent jolt
#

works for me

#

what number are you passing in

native timber
#

but it still 0.25 by some reason

#

how do you use it?

native timber
#

setScale() dont work with setTile() for some reason

#

can i fix that?

potent jolt
#

maybe if you try setting it after settile

#

idk

#

this hasnt really been an issue for me

native timber
#

wait

#

i found

#

how i can manage layer of drawing

#

ok nvm I've simulated the effect of a layer

#

...or not

potent jolt
#

which event function are you using

#

either way the drawings will always appear in the ordere you drew them

#

so drawn last is on top

native timber
#

thanks

native timber
#

it used to work with LuaWrapper, but when i deleted it, script:drawCity() not executing. What the problem?

potent jolt
#

because thats not where its supposed to be

#

youre only allowed to do it like this

#
function script:event()
  ....
end

function script:drawCity()
   ....
end
#

how your code worked in the first place is a mystery to me

native timber
#

hm

#

is there ways i can replace this structure?

native timber
#

ok i did it

stoic aurora
#

How can rotation awareness be created using the cityRotation feature with Fun? Could you share an example code?

light plinth
#

What do you mean by creation of rotation awareness?

torpid spear
#

why on earth would you need lua for rotation aware stuff

stoic aurora
torpid spear
#

decal? like ground?

stoic aurora
#

Yes

#

Level 1 ground

torpid spear
#

sounds like pain

stoic aurora
#

So it's not possible?

torpid spear
#

I don't really see the point

light plinth
#

Ground drafts are very simple objects, they don't even support animations

#

One idea might be to set a different frame when city rotation gets changed

stoic vector
#

This is right?

#

function script:init()
jet = Draft.getDraft("$")
mis = Draft.getDraft("$")
sound = Draft.getDraft("$")
explosion = Draft.getDraft("$")
end

function script:event (x, y, level, event, source)
if event == Script.EVENT_PLACED then
local i = 0
local c = 0
end

function script:drawCity()
if i < 150 then

Drawing.setTile(x,y-75+i*2)
Drawing.drawImage(jet:getFrame(City.getRotation()+1), 0, -120)
Drawing.setTile(x,y-150+i)
Drawing.drawImage(mis:getFrame(City.getRotation()+1), 0, -77+i/2)
i=i+1

if c <= 70 then

Drawing.setTile(x, y, -23, -32, 5, 5)
Drawing.drawImage(explosion:getFrame(1))
Builder.remove(1,1)
Builder.remove(-1,-1)
City.playSound (sound, x, y, 10)
c=c+1
end

potent jolt
#

right for what

torpid spear
#

theotown server members trying to ask comprehensible questions moment

stoic vector
#

function script:init()
jet = Draft.getDraft("$jet00")
mis = Draft.getDraft("$missle_nuc00")
end

function script:event (x, y, level, event, source)
if event == Script.EVENT_PLACED then
local i = 0

function script:drawCity()
if i < 150 then

Drawing.setTile(x,y-75+i*2)
Drawing.drawImage(jet, 0, -120)

Drawing.setTile(x,y-150+i)
Drawing.drawImage(mis, 0, -75+i/2)
i=i+1
elseif i == 150 then

City.issueDisaster(City.DISASTER_NUKE, x, y, 15, false)
else
return
end
end

stoic vector
potent jolt
#

okay?? looks fine to me

#

or did you want to recreate it

stoic vector
potent jolt
#

no

#

also, your code would not work

#

it will be more complex

stoic vector
#

This symbols means something in LUA?

#

#

==

torpid spear
#

you know you have google

#

double dash is a comment

native timber
#

@stoic vector bro you know, if i dont answer you in DMs, its not mean i wont give you answer at all

light plinth
torpid spear
#

chapter 7 reference

native timber
#

How can i hide/delete button when it pressed? i tried this thing, but it dont work

      local button = root:addButton{
            icon = Icon.CANCEL,
            text = 'Test',
            width = 100,
            height = 100,
            frameDefault = NinePatch.BLUE_BUTTON,
            frameDown = NinePatch.BLUE_BUTTON_PRESSED,
            onClick = function()
                  button:setVisible(false)
                  button:setTouchThrough(true)
            end
          }```
#

oh

#

i deleted local, and it worked

native timber
#

Is it possible to turn on/off shader by Lua?

potent jolt
#

you can modify the settings but you really shouldn't

#

alternatively you can set parameters the shader can read

stoic vector
#

Why the code is getting crazy

#

function script:init()
local jet = Draft.getDraft("$jet00")
local mis = Draft.getDraft("$missle_nuc00")
end

function script:draw(tilex, tiley)
local time = City.getTime()
Drawing.setTile(tilex, tiley, 0, -75)
Drawing.drawImage(jet:getFrame (1))
end

function script:draw(tilex, tiley)
local time = City.getTime()
Drawing.setTile(tilex, tiley, 0, -75)
Drawing.drawImage(mis:getFrame (1))
end

#

I want just to put a frame in the coordinate

native timber
#

only one

stoic vector
#

😉

#

function script:init()
local jet = Draft.getDraft("$jet00")
local mis = Draft.getDraft("$missle_nuc00")
end

function script:draw(tilex, tiley)
local time = City.getTime()
Drawing.setTile(tilex, tiley, 0, -75)
Drawing.drawImage(jet:getFrame (1))

Drawing.setTile(tilex, tiley, 0, -75)
Drawing.drawImage(mis:getFrame (1))
end

#

Hahaha 😂

#

Every time gets more speed until my device explode 💥

#

Maybe this code makes that message get more speed 😂

native timber
#

@stoic vector

#

not script:draw(tilex, tiley)

stoic vector
#

Keep doing the same thing and even faster 😂

potent jolt
#

and assign the values inside it

#

jet and mis are not accessible in the other method right now

potent jolt
#

and the 3rd argument will be discarded automatically

#

its a lua feature

native timber
#

oh i forgot

#

...and didnt noticed local inside a function

#

@stoic vector remove local from script:init

stoic vector
#

In all the functions

native timber
#

or you think its made only for joke

stoic vector
#

I mean the others attributes I will not use

native timber
#

you can

potent jolt
#

but yea

#

by all means

#

define script:draw()

#

if you only need the 3rd you can do function(_, _, var)

stoic vector
#

Better I keep it 😅

stoic vector
#

Still nothing 😢

#

function script:init()
jet = Draft.getDraft("$jet00")
mis = Draft.getDraft("$missle_nuc00")
end

function script:draw(x,y,level)
local time = City.getTime()
Drawing.setTile(tilex, tiley, 0, -75)
Drawing.drawImage(jet:getFrame (1))

Drawing.setTile(tilex, tiley, 0, -75)
Drawing.drawImage(mis:getFrame (1))
end

#

The code will get revenge against me

potent jolt
#

not required

potent jolt
#

also

#

you renamed tilex and tiley, but not when you use them

native timber
#

Is there any way to add a delay before part of code execution?

potent jolt
#

yep, use runtime.postpone

native timber
#

maybe i should replace it

potent jolt
#

if you want time based animations

#

youll need to get the runtime every draw or updafe

#

then get the difference between the current time and the last updates time

native timber
potent jolt
#

yep

#

not possible

#

in the direct way

#

youll need to work with delta time

#

blocking the foreach means the game will not update

#

so you cannot wait in the function

native timber
potent jolt
#

nope

#

youll have to think differently

#

youll have to check the time every run of update

#

and if enough time has passed

#

handle the next tile

native timber
#

oh my god

#

maybe i can bind it to script:drawCity or script:update, to make them work like a timer?

native timber
#

ok i cant

#

i have small problem about drawing

#

when you leave the city, game does photo of the map, with current overlay

#

and it looks strange

safe verge
# native timber

I dont know if thats what i'm about to say but that problem sometimes happens to me on regions. One part of the region that i put on night stay in night and the rest is on day

stoic vector
#

Where can I see all the functions?

#

Like function script:drawCity()

potent jolt
#

theyre in the script module

#

duh

potent jolt
#

its not avoidable

native timber
#

If the game does this photo before closing the city, theres might be way to disable drawing at this moment

#

If no...

#

Then there's nothing to be done :/

potent jolt
#

there is not

stoic vector
stoic vector
#

Even this 12 lines doesn’t work

#

function script:init()
local jet = Draft.getDraft("$jet")
local mis = Draft.getDraft("$mis")
end

function script:draw()
Drawing.setTile(x,y-75)
Drawing.drawImage(jet)

Drawing.setTile(x,y-150)
Drawing.drawImage(mis)
end

#

They keep spamming the text “error in line?”

#

Even more hard ☺️

native timber
#

Bro can you finally read lua basics

stoic vector
#

Third day learning lua 😉

stoic vector
native timber
stoic vector
native timber
#

Text

#

Code

#

Not file

stoic vector
#

function script:init()
jet = Draft.getDraft("$jet")
mis = Draft.getDraft("$mis")
end

function script:draw()
Drawing.setTile(x,y-75)
Drawing.drawImage(jet)

Drawing.setTile(x,y-150)
Drawing.drawImage(mis)
end

native timber
#

x and y isnt defined, how i get

#

Replace script:draw() with script:draw(x, y)

stoic vector
#

The beginning 😈

stoic vector
native timber
#

what.

stoic vector
#

I mean
Instead of course
script draw

#

Script event

native timber
#

where

stoic vector
#

function script:event (x, y, level, event, source)
if event == Script.EVENT_PLACED then
local i = 0

native timber
#

because optimisation

#

oh wait

#

its not update

stoic vector
#

So you mechanism works like
You set a far tile when the plane appears and working with the clock reach the main tile?

native timber
#

what

stoic vector
#

Drawing.setTile(x,y-150+i)

native timber
#

im getting x and y of tile by script:event, then i start counter and drawing things, focusing on x and y

stoic vector
native timber
#

you're not gonna believe this

#

x and y mean

#

x and y

#

😲

stoic vector
#

😂

stoic vector
#

function script:init()
jet = Draft.getDraft("$jet")
mis = Draft.getDraft("$mis")
end

function script:event(x,y,level,event,source)
if event == Script.EVENT_PLACED then
local i = 0
end

function script:drawCity(x,y,level)
if i <= 150 then
Drawing.setTile(x,y-75+i*2)
Drawing.drawImage(jet:getFrame(City.getRotation()+1),0,-120)

Drawing.setTile(x,y-150+i)
Drawing.drawImage(mis:getFrame(City.getRotation()+1),0,-77+i/2)
i=i+1
elseif i >= 150 then

City.issueDisaster(City.DISASTER_NUKE,x,y,15,false)
end
end
end

#

💀

#

Why I have to close functions if I write if then or else?

native timber
#

Bro

#

can you finally read lua syntax

#

please.

stoic vector
native timber
#

find it yourself

#

theres hundreds of articles

potent jolt
#

to be fair, the official lua documentation is hot garbage

safe verge
stoic vector
#

What’s this means

#

function script:init()
jet = Draft.getDraft("$jet")
mis = Draft.getDraft("$mis")
end

function script:event (x,y,level, event,source)
if event == Script.EVENT_PLACED then
i = 0
end
end

function script:drawCity(x,y,level)
if i < 150 then
i=i+1

Drawing.setTile(1,y-75+i*2)
Drawing.drawImage(jet:getFrame(City.getRotation()+1),0,-120)

Drawing.setTile(1,y-150+i)
Drawing.drawImage(mis:getFrame(City.getRotation()+1),0,-77+i/2)
end
end

elseif i >= 150 then
i=i+1
City.issueDisaster(City.DISASTER_NUKE,x,y,15,false)
end
end

lucid egret
#

h m m

native timber
#

sigh

#
jet = Draft.getDraft("$jet")
mis = Draft.getDraft("$mis")
end

function script:event (x,y,level, event,source)
if event == Script.EVENT_PLACED then
i = 0
end
end

function script:drawCity(x,y,level)
if i < 150 then
i=i+1

Drawing.setTile(1,y-75+i*2)
Drawing.drawImage(jet:getFrame(City.getRotation()+1),0,-120)

Drawing.setTile(1,y-150+i)
Drawing.drawImage(mis:getFrame(City.getRotation()+1),0,-77+i/2)

elseif i == 150 then
i=i+1
City.issueDisaster(City.DISASTER_NUKE,x,y,15,false)
end
end```
potent jolt
#

your syntax is completely wrong

#

try finding a proper ide that supports lua

#

also you should put a local jet, mis at the top of the file

native timber
stoic vector
native timber
#

._.

stoic vector
native timber
#

Click and see.

stoic vector
stoic vector
native timber
#

Fixer? What?

#

Compliler

stoic vector
native timber
#

Ita a freaking compiler

stoic vector
#

You put your code and show the bugs and fix

#

Try it

#

🥹🥹

#

We are useless like always

#

IA always kick our ….

#

😂

#

The AI revenge against me

#

She nuke my city 💀

native timber
#

...

#

thats because you shouldnt use this thing with API, i think.

stoic vector
#

function script:init()
jet = Draft.getDraft("$jet")
mis = Draft.getDraft("$mis")
end

function script:event (x,y,level, event,source)
if event == Script.EVENT_PLACED then
i = 0
end
end

function script:drawCity(x,y,level)
if i < 150 then
i=i+1

Drawing.setTile(1,y-75+i*2)
Drawing.drawImage(jet:getFrame(City.getRotation()+1),0,-120)

Drawing.setTile(1,y-150+i)
Drawing.drawImage(mis:getFrame(City.getRotation()+1),0,-77+i/2)

elseif i == 150 then
i=i +1
City.issueDisaster(City.DISASTER_NUKE,x,y,15,false)
end
end

potent jolt
#

my brother in christ

#

youre issueing the nuke disaster every frame

#

do you even read the code

torpid spear
#

some people just shouldn't code lol

potent jolt
#

the aircraft appears, your math is just completely fwrong

stoic vector
torpid spear
#

probably not nuke the city hundreds of times per second

potent jolt
#

youre gonna have to start at the basics man

#

this cant just be fixed with 1 or 2 lines

#

the code is simply completely wrong

native timber
#

i asked him for learn basics for like 4 times

#

he just dont want or understand i cant get

torpid spear
#

can we remove this person from the channel lol

native timber
#

Forge, how about finally start use this

torpid spear
#

and indents....

native timber
#

Wait

#

whats wrong with channel desc

#

isnt Fun is a Json thing

torpid spear
#

it is

zinc isle
#

like 4 people uses fun

#

niche

torpid spear
#

but people keep using this channel for your regular json mishups

zinc isle
#

catering to the few people who wants to use them

#

everyone says fun is worse than lua

torpid spear
#

because it is

native timber
#

only person who uses fun who i know is 『 Ƶ 』

#

and even him decided to learn Lua ._.

zinc isle
#

i tried to use fun once, but no one knew how to excecute it

native timber
#

fun sounds like scripting for lazy people

#

lazy in fact they dont want to learn programming

zinc isle
#

fun is apparently faster than lua

native timber
torpid spear
#

it might be

#

but it's just bad and can't do shid

native timber
#

we have

function script:update()
for i = 1, c do
c = c+1
end
end
zinc isle
#

i mean it could but not much

native timber
torpid spear
#

lol what do you think that code snippet is supposed to do

native timber
torpid spear
#

yup that seems like exactly what it will do

zinc isle
#

what is i

torpid spear
#

please leave

native timber
#

😭

zinc isle
native timber
zinc isle
#

oh so basically the variable

native timber
#

variable that denotes the number of times the loop will be executed and at what increments

potent jolt
potent jolt
#

```lua

native timber
#

oh

potent jolt
#

works with most languages and json

native timber
#
local wow
potent jolt
#

obviously doesnt get syntax errors

#

just highlights keywords

native timber
#

still cool

feral ermine
#

Guys did you have any idea where to start lua programming

zinc isle
#

lua api, although it would be helpful to read the lua forums as well

zinc isle
cinder jolt
#

Lua language is easy to understand

stable ore
snow arrow
#

hello

#

i created this moon frame using Drawing.setTile() and Drawing.drawImage()

#

Is there any way to make it obscured by the buildings in front of it?

#

I tried the functions in the lua api but it doesn't seem to work.

light plinth
#

draw it on the northernmost tile

snow arrow
zinc isle
#

glowing cheese ball

#

i liked the moon in the first one

snow arrow
zinc isle
#

nice for a sun yea

stable ore
#

Size plugin block? ?×?

snow arrow
stable ore
stable ore
snow arrow
stable ore
potent jolt
#

unfortunately i know of a way to get it behind the building

#

(without major limitations)

snow arrow
#

thank you very much 😄

potent jolt
#

sorry i misspelled

#

i meant to say i dont

#

technically, you can put a building on the topmost corner of the city and use it's draw function

#

but it wont render if that square is out of view

#

and of course the tile will be occupied

snow arrow
potent jolt
#

nothing asking lobby cant fix

#

maybe it could be justified as a way of drawing things on the background

snow arrow
#

thank you

#

I will try to research in that direction.

cunning crow
#

Help me i have error

zinc isle
#

what is the error

zinc isle
#

can you please stop reply pinging him

#

no dont delete that

idle oar
#

i dont get the title for this section

#

what is lua

torpid spear
#

google it, read the room

#

it ain't that hard to figure out

#

it's a language

potent jolt
# idle oar what is lua

lua is a programming language that can be used for plugins, fun is a logic system built into the draft system of the game

zinc isle
#

logic system, no one seems lo like logics then

dusty estuary
#

lua is showing up everywhere these past few weeks

icy plover
#

Lua is very simple and easy to use, it was also used on roblox studio and minetest

bitter delta
#

and it's compatiable with C!

potent jolt
#

or java!

native timber
#

is it possible to use I/O library in script? Im trying to work with it, but script keep giving me an error

light plinth
#

theotown specifically removes the standard IO library

native timber
#

._.

native timber
#

even if i require it

#

How can i work with files then?

light plinth
#

You can't

native timber
#

:/

#

Thats not cool i should say

torpid spear
#

why would you ever need to manipulate files

native timber
#

i cant fing this opportunity in API, so i guess its not possible with API

#

so i tried to I/O

#

so theres no way to do it i think??

light plinth
#

Not one that is supported through the Lua API

native timber
#

So its possible or not?

random hamlet
native timber
#

imagine this

random hamlet
#

If they implemented it it would be reasonable to block directories outside of theotown

#

But still it'd be dangerous

native timber
#

ahem

#

io.open can work without directory

#

so idk why its blocked

light plinth
#

We didn't feel like sandboxing dangerous IO library functions so we removed the entire library altogether

native timber
light plinth
native timber
#

or atleast ability to copy city's file

light plinth
#

The Lua API does not provide a way to do so.

native timber
light plinth
#

The better question is why is that needed

native timber
#

there was a BiomeMaker module in API, but it was empty

#

city copying ability can replace that

#

not at all, but can

light plinth
#

advanced generator?

native timber
#

or for what BiomeMaker was created

#

...and then deleted...

light plinth
#

BiomeMaker was a tool made by Hadestia that showed up as a Lua library

native timber
light plinth
#

That's what I mean by empty category

#

this is the biome maker tool in question

native timber
#

Okay thats not what i though

native timber
#

So whats about city's copying? Idk, seems like really cool feature

native timber
zinc isle
native timber
#

i didnt saw any thing thta allow you to create new region

#

city too

zinc isle
#

his works like that

native timber
#

like what

zinc isle
#

you use some buttons he added to create a new region

native timber
#

aaaaand

zinc isle
#

oh hmm

light plinth
#

Again, I don't see a use case for copying maps when game already provides such functionality through the UI

native timber
#

Using that, i can, for example, create a city with flat grass land and then use it as template, which will be copied, loaded though City.load or TheoTown.loadCity, rebuilded with, for example, some ground and buildings

#

here you come with newly automatically generated city

#

for what i want use it to? Maybe even automatical procedural generation

#

which sounds very cool

#

some starbound stuff but in theotown

light plinth
#

eh

trim remnant
#

@cedar panther please keep images here on topic

craggy lance
#

How to make a Very Large city

native timber
digital kindle
# craggy lance How to make a Very Large city

Incorrect place to ask that,but you can use the in game console to make a larger city or region. But remember, don't make one that's too large for your device which may cause the game to crash.

light plinth
#

:(

native timber
limber elbow
limber elbow
#

Nuh uh

dusky pike
late summit
#

Why my code json cannot read fun atribute

#

So i want give a sound, nah but didnt works

potent jolt
#

whats your code look like

potent jolt
#

looks like ja has it under control

potent jolt
#

@south garnet

#

doesnt look like lua code to me

#

alternatively, @zinc isle

zinc isle
#

Ppunish 874001522520887326

rare grottoBOT
zinc isle
#

Thanks erk

#

do i need to manually delete these now

potent jolt
#

slap a ppurge 874001522520887326

#

pidroid will delete their messages when you ban them

zinc isle
trim remnant
trim remnant
#

You see, in my advanced age, I simply forgot.

open burrow
#

What are these things?

zinc isle
#

or the pumpkin

#

im not sure which

open burrow
#

How to remove please

zinc isle
#

i think it was a plugin by kingtut?

#

i have 0 idea what the actual plugin is

summer grove
#

I want to ask where is the age of sail file? I want to download it

crimson barn
#

friendly reminder this is not the channel to ask for plugins

zinc isle
stoic vector
# open burrow

I think it's called like invisible tress or something but it has really bad reviews

#

I remember I had it like 2 years most annoying them ever they would take up space and I couldn't delete them

zinc isle
#

lol

potent jolt
native timber
#

@trim remnant

frigid sparrow
#

aight

#

gimme asec

native timber
zinc isle
native timber
zinc isle
native timber
#

oh

#

ok then

zinc isle
#

It's actually less

heavy pond
#

guess which pluginS

zinc isle
#

None

elder sail
#

Should i learn how to code my mom is a programmer

#

And so i can make cool plugins

zinc isle
#

you can use lua

#

and json

zinc isle
elder sail
#

Ok

stoic vector
stoic vector
elder sail
#

Ok

stoic vector
#

Can’t wait

digital kindle
#

Hey,just quick question. How can i make this work,as i just want user to open a YouTube video on how to use it.

function script:finishInformationDialog(x, y, _, dialog)
  dialog.controls:getLastPart():addButton{
    icon = Icon.TREE,
    text = 'Select trees (X)',
    width = 0,        -- Adjust button size to content
    onClick = function(self)
      System.openUrl("https://example.com") -- Replace with the desired URL
    end
  }
end
light plinth
#

First of all

#

System is not a library

#

Secondly, it's probably from Runtime library and requires privileged access

digital kindle
#

So use Runtime instead of System ?

native timber
native timber
#

How can i get a value from player's clipboard?

light plinth
#

pretty sure you cannot

native timber
# light plinth pretty sure you cannot

Then can i at least ask you to add a Runtime.setClipboard() to the LUA API's page? It's weird that you have to go into the code of DevTools to find this

normal trout
#

What the fork is dis plugin, i didnt Loaded it Jist appeard randomly on my game

zinc isle
normal trout
#

There we go

#

The build

stoic vector
#

I’m curious 🧐

torpid spear
#

my brother in christ there already is a picture

stoic vector
#

Lol I noticed now 😂😂

light plinth
#

Pmodmenu 821968668777906228

rare grottoBOT
zinc isle
#

Nice catch :>

potent jolt
#

setup pidroid to auto ban anyone that messages here

stoic vector
#

@zinc isle

#

they just love this channel

dusky pike
native timber
#

@zinc isle

icy siren
#

@zinc isle

zinc isle
#

Ppunish 1056613323031969923

rare grottoBOT
native timber
#

nawwwh my steam gift

zinc isle
#

the 2 pings informed of its urgency lol

torpid spear
#

can we auto ban anyone who posts here

trim remnant
#

We do lmao

#

There's just an infinite number of ways that people can make those links

#

The vast majority of them get caught but you can't stop them all

green umbra
#

Ahh I see
Using many tricks to fool the system

native timber
#

Ban the word steam lmao

trim remnant
#

Well see this game is sold on steam so that would hurt us xD

trim remnant
lavish nexus
#

Removing this cuz folks can see the link lol and i dont want anyone fall for them phishing links 🫠
Unless its an example but eh better to remove it to avoid risks

elder sail
#

Can someone teach me lua

native timber
#

no

green umbra
potent jolt
#

i can answer questions but i cant give you a live walkthrough

native timber
next relic
#

Yes

potent jolt
native timber
desert elbow
#

Spanich

stiff lion
desert elbow
stiff lion
#

not here

desert elbow
#

Ok

light plinth
#

Pmodmenu 674720861940350983

rare grottoBOT
empty cairn
#

quick question about plugin making. For the diagonal asphalt plugin, could i take a png from the data within the game files? (i forget what it's called, but ive been here before, it has all the frames for plugins and such stored) and code it up into a json but give it winter frames? ik the original plugin doesnt have them, and it looks kinda funky, i wanna do this but i just wanna know if it would work lol

potent jolt
#

you wont be able to change the road in the game directly but you can copy it

empty cairn
#

ohh kk, thx !

zinc isle
#

i cant remember, but that too much water guy did it

#

no wait ross did it

#

he replaced the default water with some ugly water

#

so you cannn

potent jolt
zinc isle
#

might be able to

empty cairn
#

i found this template for making a road plugin, i just wanna know if it's the correct format to follow lol

potent jolt
#

you can also find the game's json for the road on the forum

gleaming basalt
#

Yo bro,how i can find the link to download Plugin Age of sail?

stiff lion
#

you cant download it

gleaming basalt
potent jolt
#

age of sail cant be downloaded right now

potent jolt
#

@zinc isle

zinc isle
#

Ppunish 663702178921185280

rare grottoBOT
zinc isle
potent jolt
#

;)

spring tree
#

@potent jolt

potent jolt
#

whats up

spring tree
spring tree
trim remnant
#

@spring tree I'd really appreciate it if A) You stayed on topic. B) Didn't ping random members just to chat in this channel. C) Didn't back to ping someone lmao

spring tree
rare tinsel
#

🤦‍♂️

stoic vector
torpid spear
#

how do I open a custom dialog when clicking a vanilla game building?

light plinth
#

there's a script:finishInformationDialog, alternatively, there's script:click where you would setup everything on your own

torpid spear
#

and how would i actually use it? do I have to attach a separate lua script to said building using inherit?

light plinth
#

that is called for the script owning draft

torpid spear
#

can I somehow use it if my script is defined as a json "script" type

#

my lua is crusty

light plinth
#

you want it to work on any building?

torpid spear
#

on a building of specified id

light plinth
#

you could attach it to a specific draft

torpid spear
#

ok I have actually 0 idea how to use this

#

could send you the script if you feel like it

light plinth
#

The following code attaches current script to all roads so that every road receives the script:event call.

local wireDraft
local wireId = '$underground_wire00'

function script:lateInit()
  wireDraft = Draft.getDraft(wireId)
  local roadDrafts = Draft.getDrafts():filter(function(d) return d:getType() == 'road' end)
  for i, draft in ipairs(roadDrafts) do
    if draft:getId() ~= '$dsa_moon_road00' then
      script:addScript('legrater', draft):initCopy()
    end
  end
end

-- initialize wireDraft for a specific road draft
function script:initCopy()
  wireDraft = Draft.getDraft(wireId)
end

function script:event(x, y, level, event)
  -- If road is removed, remove pipes too
  if event == Script.EVENT_REMOVE then
    if Tile and Tile.getWireDraft(x, y, -1) then
      if Builder then
        Builder.removeWire(x, y, -1)
      end
    end
    return true
  end

  -- If road is placed, place pipes too
  if Script.EVENT_FINISHED then
    if Builder and wireDraft:isUnlocked() then
      Builder.buildWire(wireDraft, x, y)
    end
    return true
  end
end
torpid spear
#

quickie dsa snippet

#

classic

light plinth
#

Nah

#

It's from wires under roads

torpid spear
#

interesting

#

i will try it out

#

seems to work so far, thanks

#

it appears that I can't directly add variables into gui dialog text using regular lua string concatenation

#

any way out?

#

ok I'm actually an idiot, I shouldn't be allowed to write lua in lines longer than 20 characters

torpid spear
#

I missed a single . character, vsc didn't panic and I couldn't figure out what went wrong

torpid spear
#

the joys of theotown lua

light plinth
#

will make sure the next entry in the series requires strongly typed cross compiled c code

torpid spear
#

theotown 2 confirmed

potent jolt
#

shouldve used my lua type annotations for theotown api

dusky stream
#

im trying to make a decoration with transparent ground around it and it turns into water? im trying to use the draw ground statement but im not sure where to put it in the code. any tips?

stoic vector
#

imagine writing a whole code just to it don't work

dusky stream
#

when i do thats when it has the water effect

#

ill see if i can get a screen grab

stoic vector
dusky stream
#

where do i put it ?

[
{
"id": "$emberecho.decoration.2025-01-20-19:24",
"title": "Park Bench",
"author": "emberecho",
"meta": {
"pca": {
"version": "4.4.1"
}
},
"frames": [
{
"bmp": "Photo 2.png"
}
],
"width": 1,
"height": 1,
"type": "decoration"
"draw ground":true
}
]

stoic vector
dusky stream
#

oh ok. i see its under optional attributes

#

sweet that worked. permission to make fun of my bench now 🙂

potent jolt
#

its too large frankly

#

the citizens are only 3 pixels tall

livid wraith
dusky stream
#

true, that building is super mini its a 1x1 but is obviously a full building but even by the trees scale. im working on another version now ty

native timber
#

offtopic alert

#

achtung

opal bobcat
#

wrong channeru

stoic vector
#

wrong channel

#

call police

carmine plover
#

Oh i see😅

torpid spear
#

is it possible to set demand to specific value rather than adjusting offsets with fun variables?

#

for example I want to set commercial demand to 0 for some time and then unlock it

light plinth
#

No

torpid spear
#

shrill

torpid spear
#

is there a lua script function that just fires whenever a building is placed?

light plinth
#

there's a building listener to getting added

#

there might also be an script:event enum for that as well

torpid spear
#

there's addBuildingListener, but why can't I remove a listener?

native timber
torpid spear
#

...what

potent jolt
#

think he means

#

keep a table of buildings that should be tracked

#

then check if the building's listener needs to actually be ran

#

and ignore the ones that are "removed"

light plinth
torpid spear
#

can you please document functions????????????

light plinth
#

eventually

torpid spear
#

I will eventually kick you in the solar plexus

stiff lion
#

lol

potent jolt
#

what does removeBuildingListener's call signature even look like

safe verge
#

you can't make an animation only appear in the day? hmm

torpid spear
#

I'm pretty sure you can just have the daytime animation active at all time and a nighttime animation that would cover the daytime animation at night

#

which is a pretty roundabout solution, but well

#

(please use correct channels next time)

safe verge
#

oh, sure

wraith ember
#

@trim remnant

trim remnant
#

Pmodmenu @carmine token

rare grottoBOT
trim remnant
#

Thank ya

wraith ember
#

always

potent jolt
#

riveting scripting content

#

at this point we can auto ban anyone typing in this channel

stiff lion
#

again you

exotic junco
torpid spear
#

does Tile.setBuildingAnimationFrame work on roads too?

potent jolt
#

someone overdid a purge

dusky pike