#plugin-lua-and-fun

1 messages ยท Page 4 of 1

random hamlet
#

yeah its meant to be different, icons" is in a separate json file

#

I reloaded the game so its supposed to be loaded

#

only if I leave the 2nd line though

light plinth
#

iconDraft is probably nil

#

that's why it crashes

#

Where do you run it in?

#

As in, under what script event

random hamlet
#

it was out of all functions as in examples, I moved it into a function (that gets activated when you click a sidebar button) but it still doesnt work

light plinth
#

Are you sure $sim_nationstates_icons is defined

#

You could Debug.toast the iconDraft value

#

and see what it returns

random hamlet
light plinth
#

reloaded as in restarted?

random hamlet
#

yes

light plinth
#

then it should work

random hamlet
#

it doesnt toast anything

light plinth
#

slap a
"strict lua": true
in your script json object

#

this will make it immediately crash when an exception is encountered

#

rather than doing that silently

random hamlet
#

now it shows nil

light plinth
#

that means that draft is undefined at that moment in time

random hamlet
#

because I moved the toast, was dumb and put it after .getdraft which causes the exception

random hamlet
light plinth
#

I mean

#

In this instance, you are getting the draft of dynamically defined draft

random hamlet
#

I tried both one defined by string in lua file and one in json

#

btw Draft.append(iconImage) seems to cause an exception too

light plinth
#

seems?

#

if it crashes, it should be an exception

#

not seem

random hamlet
#

I didnt enable strict lua yet

light plinth
#

you should do that first

random hamlet
#

so this isnt reliable?

light plinth
#

it does not give you details on why it fails if it crashes

#

you'd have to read the log.txt in this instance

random hamlet
#

oh wait strict lua gives details?

light plinth
#

it immediately shows the error in your face rather than silently logging it in log.txt file

random hamlet
light plinth
#

According to that error, Draft.append cannot be called outside of init methods

random hamlet
#

im back

#

now it doesnt crash but icons arent visible

#

gonna continue tomorrow

zinc isle
#

trading

weak mural
#

the draft append and merge should be placed outside any script functions, e.g. init, earlyInit, lateInit, and so on. you can put under require function if you use modules or even the first line of your script.

and call Draft functions, e.g. getDraft, inside the script functions. when the scripts initialization, any plugin drafts are not loaded yet. and you will get the nil draft.

#

after the read line, the draft append and merge are just an abstract function. after the blue line, all drafts are loaded properly.

random hamlet
#

HELL YES

#

almost working

#

these icons are kinda weird

#

also maybe I should make them smaller

random hamlet
#

I dont like iron ore, its weird

#

even though I took a real picture as reference

#

also I should fix the outline in some places

#

looks better

#

@torpid spear sorry for pinging but I think you know the answer best out of people here

does the game have some "standart" icon size? (or sizes for different types of icons)

#

they seem to just vary from 20x20 to like 26x26

potent jolt
#

complex industry uses 26x26 for the icons

#

the sidebar doesnt quite fit that size though

random hamlet
#

my icons are 24x24 for now

#

I hate this so much\

#

it doesnt even show what happened in the logs

#

after I reload the game it works fine but after any change it disappears unless I reload it again

potent jolt
#

some gui errors get supressed

#

i just use strict lua for the rest

random hamlet
#

this makes me want to kill people

zinc isle
#

kill

random hamlet
#

this happens because of Draft.append(iconImage)

#

which I put outside of script functions

#

as I was supposed to

#

tried loading from json again but it doesnt work anywhere

potent jolt
#

why are you using draft append anyway

#

i have never found a valid use case for it

random hamlet
#

apparently thats what you use when you write json code inside lua

potent jolt
#

seems pretty impractical to me

torpid spear
#

yes icons should be 26x26

random hamlet
#

well it did

#

I forgot why it even broke

#

idk what am I doing

potent jolt
#

i geuss thats better than mine rn

random hamlet
#

do your icons work?

potent jolt
#

well yea

#

but my script dont

random hamlet
#

fixing a script is probably easier or at least not as frustrating as figuring out how tf do icons work

#

can you tell me how do you deal with icons?

potent jolt
#

idk what the issue is

#

works fine on my machine

#

i just load them on startup and put them in a table

#

similar to the game

#
    {
        "id": "$industri_gui_icons",
        "type": "animation",
        "frames": [
            { "bmp": "icons/industry_icon.png" },
            { "bmp": "icons/port_icon.png" },
            { "bmp": "icons/wood_industry_icon.png" },
            { "bmp": "icons/warehouse_icon.png" },
            { "bmp": "icons/import_icon.png" },
            { "bmp": "icons/export_icon.png" },
            { "bmp": "icons/industry_info.png" },
            //problem icons
            { "bmp": "icons/warehouse_full.png" },
            { "bmp": "icons/warehouse_problem_icon.png" },
            { "bmp": "icons/input_empty.png" },
            { "bmp": "icons/output_full.png" },
            { "bmp": "icons/industry_problem_icon.png" },
            //other icons
            { "bmp": "icons/resource_switch.png"}
        ],
        "meta": {
            "names": [
                "INDUSTRY",
                "PORT",
                "WOOD",
                "WAREHOUSE",
                "IMPORT",
                "EXPORT",
                "INDUSTRY_INFO",

                "WAREHOUSE_FULL",
                "NO_RESOURCE_SELECTED",
                "INPUT_EMPTY",
                "OUTPUT_FULL",
                "SUPPLY_NOT_MET",
                "SWITCH_RESOURCE"
            ]
        }
    },
#

draft looks like this

#

then i just Industri.ICONS.IMPORT

random hamlet
#

outside of all functions?

#

some script function?

#

or when city loads?

potent jolt
#

script:init for me

#

i get the draft, then put the frames in a table

#
function Industri.earlyInit()
    -- load icons
    local draft = Draft.getDraft(draftId)
    local meta = draft:getMeta()
    for index, name in pairs(meta.names) do
        Industri.ICONS[name] = draft:getFrame(index)
    end
end
#

earlyInit i suppose, but that doesnt matter

#

its a simplified version of the actual code

random hamlet
#

doesnt work

#

oh wait

#

I put another id

#

to see if it loads

#

fixed the id, still doesnt work

potent jolt
#

whats the error

#

also arent you just loading 4 frames out of a 2 frame draft

random hamlet
#

okay it works now

#

I think

potent jolt
#

now you can do fancy gui stuff to it

#

ninepatches my beloved

random hamlet
#

I havent even figured out simple gui

#

custom icons is fancy enough for me

potent jolt
#

you could put them into a listbox to start

#

easier for dynamic amounts of resource types

random hamlet
#

good idea

#

hm, what other resources should I add... (useful but not too specific)

potent jolt
#

provides easier way of boxing each resource

random hamlet
#

thought of uranium

#

and copper

potent jolt
#

rare metals?

#

for advanced things

random hamlet
#

non-ferrous metals

#

yeah

random hamlet
#

in russian they're called colored metals

#

I wont have complex industry levels of complexity but you will be able to produce some goods

#

and sell them

#

I will also add "consumer goods" which will be surplus from vanilla industry

random hamlet
potent jolt
#

maybe youre thinking of noble metals

random hamlet
#

nah, non-ferrous

#

maybe I could add both non-ferrous and rare metals

#

rare metals for most advanced stuff

potent jolt
#

if youre gonna have production buildings like complex industry oh boy

#

the complex in complex industry also refers to the codebase

random hamlet
#

it will be much simpler

#

also most of industry building will be out of the player managed city

#

it'll be just clicking a button to construct an abstract factory somewhere else

#

because the plugin is about countries

potent jolt
#

yea that simplifies things

random hamlet
#

you will be able to build factories in your city too, but it'll still be simple

#

just 1 building

random hamlet
#

Now I need to "reset" a listbox

#

to change a button when you click on it

#

idk the best way to do it so I'll just make the onclick function delete the listbox and generate it again

#

this functionality probably wont be needed in final version anyway

random hamlet
#

(right now there isnt any room to scroll down anyway)

elder glacier
random hamlet
#

my rock collection

potent jolt
#

nice

#

now its looking sharp

zinc isle
#

since when was oil a rock ๐Ÿค”

light plinth
random hamlet
#

I wanted to add diamonds but I cant come up with an use for them

#

maybe sell to your rich population for extra money

#

gonna start implementing abstract buildings

#

I thought that players will only be able to build in cities (you'll be able to found them on any tile) which are also abstract

#

but then you'll have to make cities almost everywhere

#

so I'll make it just need at least 1 city within 2 tiles

#

if I make it like 3 or 4 tiles, and make cities very expensive it'll create an interesting mechanic where you have to plan city placement to cover as much resources as you can

random hamlet
#

I wont even try making logistics

#

so resource storage will just be global (country wide)

#

and independent from buildings

#

but buildings just affect how much can you store

trim remnant
#

Unbelievable low quality plugin

random hamlet
#

nooo

#

imagine smooth integration between this and complex industry

zinc isle
#

i like the icon

random hamlet
potent jolt
#

no way

#

industrial complex

trim remnant
#

Literally making the military industrial complex

random hamlet
#

I want to have rockets and planes at least

#

Maybe land warfare but this means I have to code pathfinding

random hamlet
#

I kind of want to add bricks or concrete as resource

#

But it feels weird to have them separately

#

Maybe it's a good idea to add some combined "building material" resource representing bricks, concrete, stone, asphalt, etc.

#

Which will be used with steel to construct most buildings

random hamlet
light plinth
#

now you're looking sharp

zinc isle
#

Yeee looks amazing

#

however why are the first letters lowercase?

random hamlet
#

idk I'll fix that now

#

industry buildings in the city consume a bit of timber

#

but if there is no timber nothing will happen

#

I dont think I can make random industrial buildings get abandoned

#

more balancing, also made amount of forest on tile count

#

gonna make sawmills produce a bit less wood

#

for context this is my horrible testing city

#

of 150k people

#

I'm gonna give management buildings in my plugin an actual use

#

I will have political power unit like in hoi4

#

which will be used for some decisions

#

you will be able to get more of it by building a management building in your city

dry fox
random hamlet
#

It's not finished

#

I mean, this channel is usually used for taking about progress on unfinished plugins

dry fox
#

Oh

#

True lol

random hamlet
#

But it'll be called nationstates mod or something

zinc isle
#

wow simon implementing a whole ass system

dry fox
#

Oh ok

zinc isle
#

this is amazing

dry fox
#

Cool system tho, so i will be dowloading it when it finished

random hamlet
#

Gonna work on resources for some time

#

Then switch back to countries

random hamlet
#

new resources (except the one in the middle)

#

building materials, plastic, non-ferrous metals (old), rare earth elements, uranium

icy siren
random hamlet
#

oh right I should finish it

#

I feel lazy rn but I just need to add the cables

#

I'll do it at some point

viral ruin
random hamlet
random hamlet
#

okay

#

not bad

random hamlet
#

the great and proud country of gm_vanillastruct

#

๐Ÿซก

#

For now treasury is just the tax from your main city

#

I want to start adding random things but I have to do important features first

viral ruin
#

It is right

#

So it will be just the more detailed version of Theotown or the thematic mod?

random hamlet
#

With which you can trade or wage war

#

So it mostly spices up gameplay and adds more stuff to manage

#

I'll also come up with more mechanics affecting the city building part

#

E.g. your city will have its own resource map, and potentially it has more resources than any other region of your country

#

This isn't very realistic but it encourages developing your city and establishing camps for surveying resources

#

And gives purpose to building stuff like oil pump sites

random hamlet
potent jolt
random hamlet
torpid spear
#

complex industry

random hamlet
#

beautiful

viral ruin
random hamlet
viral ruin
# random hamlet

Meh it looks interesting. So when you want to finish this masterpiece?(i guess)

random hamlet
#

honestly no idea

#

especially since I have some other coding projects im switching between periodically

viral ruin
#

Well

#

Your mod would be one of the best things of Theotown if you'll still finish it

random hamlet
#

yeah it'll probably be the second major lua mod after aos

#

I dont know any other ones

#

well, and complex industry

#

but ci is unfinished

viral ruin
#

So good luck

random hamlet
#

finally added save&load

#

now my world doesnt get erased every time I reload the script

icy siren
random hamlet
#

nah I have this

random hamlet
#

I thought there was a script:nextWeek but turns out I was wrong

#

I guess this will do

#

nextDay for updating everything seems too fast and nextMonth is too slow

#

wait this isnt c

#

thats probably not how I only count the 7th day

#

nvm it works

random hamlet
#

settled a tile

#

I suspect that for some reasons saves can break

#

but maybe its just because of me changing the code

potent jolt
#

my solution was to just wipe the plugins city storage and then rebuild it

random hamlet
#

added crops

#

idk why I didnt think of them before

zinc isle
#

whats a weird looking crop

torpid spear
#

have you ever seen a grain

zinc isle
#

i dont think it looks like that ๐Ÿฅบ

random hamlet
#

its wheat but tortured by horribly low resolution and me not knowing how to draw it

zinc isle
#

how about kinda like this?

#

these look nice too

torpid spear
#

the artstly doesn't look very theotowny

zinc isle
#

simon can smash them together :)
hes very good

random hamlet
#

basically early gameplay is

  1. Set up a sawmill to start getting good amounts of wood
  2. Build a timber storage to store wood
  3. Build farms and grain silos, less necessary than other steps but grain is needed for rural population to grow, and more population means more taxes
  4. Build a granite quarry (needs timber)
  5. Build an iron mine (needs timber and granite)
  6. Build a coal mine (needs timber, granite and iron)
  7. Build copper mine (needs same as coal)
  8. Build steel factory (needs granite, iron and copper, consumes iron)
  9. Build construction material factory (needs granite and steel, then consumes granite, steel and copper)
#

then more advanced thingamabobs follow I guess

light plinth
#

rocket industry when

random hamlet
#

I think I'll add rockets if I get into that stage of development actually

#

(spy satellites)

#

to detect rocket launches n stuff

#

(if I get to that stage of development too)

zinc isle
#

this is advances, i love it

random hamlet
#

I should make categories for my building tab

random hamlet
random hamlet
#

but you can actually produce a tiny bit of wheat by building real farms in your city

#

how should I call the category of crop & timber related buildings

#

I guess I'll call it renewable resources for now

random hamlet
#

added steel mill, testing now

#

damn, I dont have coal on my territory... I guess its time to EXPAND

#

there is a minor inconvenience with a bug that prevents me from expanding vertically but im too lazy to fix it and reopen the city

#

thankfully I found a tiny coal deposit

#

I forgot to make copper generate and when I fix it the savegame will break ๐Ÿ’€

#

now thats a real minor inconvenience

#

at least for now the gameplay process is fast

#

but before release I'll slow it down by making everything slower and more expensive

#

since otherwise you wont have time to actually manage your city, and will finish setting up everything in your country before your main city becomes big

random hamlet
random hamlet
#

it works

#

I didnt even have to conquer a single tile for this

#

OP

#

but I will fix

viral ruin
#

Why the developers doesn't make similar stuff for the updates

torpid spear
#

probably because tt is not a rts?

random hamlet
#

I'd rather take on making rts myself, so devs can finally make the transport update

viral ruin
elder glacier
random hamlet
#

added a basic energy system

random hamlet
#

gonna make sure oil works and then work on something else

random hamlet
#

๐Ÿฆ…๐Ÿฆ…๐Ÿฆ…๐Ÿฆ…

random hamlet
#

me and my new friends

#

ignore the names they're random placeholders

zinc isle
#

American states

random hamlet
#

only most of them

zinc isle
#

Yes

random hamlet
#

ok gonna turn this into usa battle royale temporarily

zinc isle
#

Tell me which state wins

random hamlet
#

I'll just change the placeholder names, I didnt add war yet

#

but I'm gonna start implementing basic ai, so they'll at least build stuff and settle nearby tiles

zinc isle
#

Cooool

viral ruin
random hamlet
#

(had to fix a lot of bugs on the way) Now they build sawmills

#

and once they have enough timber, they build storages for it

stoic vector
#

Player is my favorite state

random hamlet
#

well technically countries expand now

#

but I have no idea why are they doing it this way

#

nvm figured it out

#

if I said how I truly feel about lua, I'd get demoted for breaking server's record of excessive swearing

elder glacier
#

real

random hamlet
#

rn they expand, build sawmills, timber storages and farms

#

wtf is new mexico up to

zinc isle
#

omg they are growing???

random hamlet
#

Yes

#

They're settling unoccupied tiles

zinc isle
#

thats so cool

random hamlet
#

on mobile this will probably be only playable with a smaller map with less countries

#

but it'll probably be absolutely playable with a map 2 or 3 times smaller

#

(in fact I think I made it too big anyway)

random hamlet
#

now countries can reach the stage of getting oil

#

worth noting that they have infinite money for now tho

zinc isle
#

looks nice

random hamlet
#

my worldgen looks surprisingly cool despite not using perlin noise

random hamlet
#

saves properly, (size of stg.nations is right), loads 0

#

thats after reloading the game

#

@potent jolt do you have experience with saving and loading tables, how to do this properly?

#

oops attached the same screenshot twice

#

storage itself seems to be working

potent jolt
random hamlet
#

okay now it works

potent jolt
#

but simple values like numbers and strings must be set directly in storage

#

better to use tables

random hamlet
#

map is a 2 dimensional array (table)

potent jolt
#

you should nest all your storage in a dedicated table

#

for your plugin

#

that way you dont accidentally have a number that doesnt get saved

random hamlet
#

local stg = getStorage()

    return Util.optStorage(TheoTown.getStorage(), script:getDraft():getId())
end```
#

function I totally didnt steal

potent jolt
#

yea basically

random hamlet
#

I use this already

potent jolt
#

pretty much how ci does it

#
-- Gets the industri storage table from gamewide storage.
---@return table storage The gamewide industri storage table.
---@nodiscard
function Industri.getStorage()
    return Util.optStorage(TheoTown.getStorage(), Industri.INDUSTRY_ID, {})
end

-- Gets the industri storage table from city storage.
---@return table storage The city industri storage table.
---@nodiscard
function Industri.getCityStorage()
    return Util.optStorage(City.getStorage(), Industri.INDUSTRY_ID, {})
end
random hamlet
#

then whats the problem in my script

#

why dont nations load normally

#

or map

#

whatever

#

my load function clears nations array and then loads it from the save

#

but for some reason nothing changes

potent jolt
#

how does it do that

#

i dont have dedicated save functions

#

i just work on references to the storage directly

#

as long as the table was retrieved from storage itll always update in storage

random hamlet
#

then local stg = getStorage()
val = stg.val

#

honestly idk how am i supposed to do this

#

and I dont know why

nations = stg.nations ```
doesnt do anything
potent jolt
#

youre assigning an empty table to nations

#

then overwriting it with a referencr to stg.nations

#

which is nil

#

youll have to initialise stg.nations first

#

so

#
stg.nations = stg.nations or {}
nations = stg.nations
random hamlet
#

doesnt change anything for some reason

#

How am i supposed to save this value?

potent jolt
#

if you edit nations after that point it will save automagically

#

you could use util.opstorage to simplify those 2 lines too

#
stg.nations = Util.opStorage(stg, 'nations', {})
#

becausr thats really all the function does

random hamlet
#

I hate lua

#

save:

stg.nations = nations```

load (called when you enter city):

local stg = getStorage()
stg.nations = stg.nations or {}
nations = stg.nations

#

after I click save, wait, and click load nothing changes (it should)

#

or when I reload the game it doesnt load anything either

#

I thought it just copies values

#

and they are independent

potent jolt
#

dedicated save function is not needed

random hamlet
#

should I do smth like nations = stg.nations somewhere in the beginning of the code or what

#

when city loads

#

and dont use save or load?

#

or just replace every mention of nations with stg.nations

#

which if tables copy references would be the same thing

random hamlet
#

I may be stupid

potent jolt
#

i got

#
function IndustriBuilding.enterCity()
    Industri.debugLog('IndustriBuilding module enterCity')
    -- get all buildings from storage
    IndustriBuilding.buildings = Collection.new(Util.optStorage(Industri.getCityStorage(), 'buildings', {}))
    for _, building in pairs(IndustriBuilding.buildings) do
        setmetatable(building, IndustriBuilding.meta)
    end
end

function IndustriBuilding.exitCity()
    IndustriBuilding.buildings = nil
end
#

and it just works

#

i just work on the buildings table

#

this is in a module, but it should work for you

#

dont mind the Collection.new, thats a wrapper class i wrote for tables

#

i dont think i even use it

random hamlet
#

I'll try figuring out save/load tomorrow

potent jolt
#

the only important part is that it just fetches a table from storage and assigns it locally

#

from there i can manipulate it however i want

#

the exitcity isnt even needed

#

the whole setmetatable thing is cuz i wanted to pretend its object oriented

#

id have to see more of the code to know what youre doing wrong

random hamlet
#

Don't want to deal with saves for now so I'll do something else

random hamlet
#

im gonna take a 3-4 day break because I have another unrelated project I promised someone I'll work on

royal pollen
#

hi, I need to code my plugin, I donโ€™t know how since Iโ€™m doing it for the first time

potent jolt
#

you can start by checking the guides on the forum

naive marsh
#

๐Ÿ˜Ž

torpid spear
#

stop spamming and use proper channels, thanks

trim remnant
#

The context is that user was spamming lmao

#

Why doe it concern you/

random hamlet
#

some sprites for nationstates plugin

zinc isle
#

Cool

weak mural
#

looks like PCB

random hamlet
#

What's PCB

weak mural
snow tapir
# random hamlet What's PCB

Do you think your plugin could have multiplayer functionalities? It would enhance the interactions between players a lot if so, and would be pretty usefull for roleplay

potent jolt
snow tapir
#

Yeah, sadly true

#

Although resource sharing is already in game

#

So it could work like that

#

There is even ways to share the money of two cities, so maybe at least resource sharing could work

random hamlet
#

Not sure I can code that in, especially for online regions

snow tapir
random hamlet
#

Pretty far

snow tapir
#

K

#

Still, it would be funny if for the npc nations names you used the names of the nations of the reddit rp community

stoic vector
#

why is this? I'm new to creating plugins, please help

zinc isle
#

Remove one or rename it

wraith garden
#

Could someone tell me how to alter a tool plugin's title in the building tool(Pic. 1) without changing its title in the toolbar(Pic. 2) programmatically in Lua?

zinc isle
#

"title":

wraith garden
#

It will also change its title in the toolbar.

zinc isle
wraith garden
#

So, how does this plugin(Terrain Tool++) implement it? It has a mutable elevation counter in the title.

zinc isle
#

who made it ian?

weak mural
#

not possible if you are not in TPC. you only can obtain the tool name with City.getToolName, but can't change it.

#

maybe lobby should add City.setToolName.

analog sentinel
zinc isle
analog sentinel
#

no i mean
nationstate plugin??

zinc isle
#

theres resources and trading between imaginery cities

#

it all really sounds cool and simon is doing an amazing job

analog sentinel
#

damn ๐Ÿ˜ฎ

#

finally

analog sentinel
zinc isle
random hamlet
#

I don't have a server for it

exotic zodiac
#

Is there some guide or documentation for creating plugins?

zinc isle
#

they are pinned there

orchid crater
#

print ('hello i will steal your food')

torpid spear
#

this isn't a channel to mess around and if you keep it up you will simply get warned

#

thanks

light plinth
#

Ppunish 480662509096009739

rare grottoBOT
random hamlet
#

I hope I'll have more free time and motivation to work on nationstates plugin in late december

#

(I haven't forgotten about it)

jaunty blade
#

would this kind of building look good in theotown?

spring veldt
#

The contours on the house in this game are strange to be honest

jaunty blade
#

i dont understand sir

spring veldt
#

This is an example of a building that you are going to introduce into the game, is the sprite ready?Because it confused me a little

jaunty blade
#

This is nothing, I just made the design. because I want to know first whether this style is suitable for the game

torpid spear
#

this isn't the appropriate channel for this

#

also no, it would not

jaunty blade
#

Ahh I'm very sorry sir, I don't know, I'm new here

native timber
#

How can I edit the GUI โ€‹โ€‹that appears when I click on a drafted building?

potent jolt
zinc isle
#

okay so

#

now it kinda works, just not the way its intended to

#

it doesnt stop after animation has ended and both animations run at the same time

median condor
#

Asking something for the Lua pro experts:

  • Would it be possible to make a plugin centered on ski resorts that relies on a system of "tickets" to provide income? Essentially, a share of your population + a number of "tourists" (who need hotels to sleep in) would generate income based on the number of ski slopes and lifts that you have.
  • Reaching a certain treshold of tourists / skiers would unlock new facilities.

I am currently trying to see if modding a ski resort mod would be possible, essentially a new "free dlc" centered around giving an additional income.

torpid spear
#

you very much could

median condor
#

Okay thanks Kulche!

torpid spear
#

I think there are even some inbuilt lua functions for adding a custom 'currency' like tickets

potent jolt
#

its very much possible but it will not be easy

#

also earncurrency and spendcurrency require privilege

#

its probably easier to just manage the currency yourself

median condor
zinc isle
#

I press and it does nothing. Very anti climatic

random hamlet
#

should I post the code of my atmosphere shader?

#

with ids changed because I think thats how people do it usually

#

maybe it could help some people with understanding glsl

#

but also maybe anyone who cares about it will just read the tutorial

zinc isle
#

all i saw was a lot of math

random hamlet
#

Yeah that's how shaders are

#

Although the atmosphere shader isn't too complicated

weak mural
zinc isle
#

I thought i wanted to make a shader, until I saw the tutorial and didnt

random hamlet
#

I guess then im the only one working with them lol

#

although I havent made any shaders in a while

#

especially complex ones

#

I wish there was a postprocessing shader

#

where I can work with the whole screen and not separate sprites

misty python
#

shader monopoly

uncut field
#

Their conversation actually got me to look into shaders for love2d

#

I think I'm going to use a fragment shader to improve rendering performance for my falling sand game

random hamlet
#

compute shaders exist

#

outside of theotown though

#

and I have no idea how to make them

#

(yeah ik 3 days passed)

true sentinel
#

Helo

torpid spear
zinc isle
#

maybe he wanted to ask a question about lua, or fun even

light plinth
#

it's ian's Brazilian alt account

zinc isle
#

unreal

elder glacier
#

Lmao

torpid spear
#

lol

weak mural
#

im prefer make japanese alt account

novel badge
#

Is it normal some fun function not work properly on IOS?

torpid spear
#

what do you mean "not work properly"

magic pier
#

Where to get this ?

novel badge
#

It cannot detect activated firework wires

#

Only on IOS

weak mural
#

this is how to fix your issue.

torpid spear
#

lol

#

that's quite the way out

icy siren
weak mural
#

isnt it there?

vestal storm
#

Are these acc hacked

trim remnant
#

yeah they are

icy siren
#

but this will be on train depot

viscid lily
#

Sorry, what does lua even mean?

zinc isle
viscid lily
deft rune
#

Can someone help me with my code?

#

Its giving errors for no reason

#

Oh wait wrong place sorry

vestal storm
#

ip stealer

vestal storm
#

Ping

vestal storm
#

I have a problem with the vanilla plugin mainfest

#

From the pickle

#

As i didint have a problem before importing it

torpid spear
#

that's not lua

#

also how are we supposed to help if you didn't even say what's wrong

vestal storm
#

Well

#

When you download the one from the pickle

#

It comes set with the stuff you need to put it into the plugin to have a mainfest

#

But

#

When i did that

#

This appears

south garnet
vestal storm
#

Should i remove the .json

#

Ima try that

torpid spear
#

yes you should

#

manifest is the extension

vestal storm
#

Thank you

zinc isle
#

Ppunish 983497746772295703

rare grottoBOT
stoic vector
#

:+

reef ocean
#

Hello, does anyone have the code that is set when a building does not have a floor?

reef ocean
#

Hi???

#

Bruh

rugged night
#

note: remove the comma when you wanna put it on the last line

reef ocean
#

Thanks

torpid spear
#

should be good, but wrong channel

reef ocean
#

A sry

native timber
#

Can i redact or create a json file, using lua?

torpid spear
#

yes

potent jolt
#

but only during initial loading of the game

#

not during runtime

maiden dome
#

What is the name of the diagonal building plugin?

potent jolt
#

this isnt the place for that

stoic vector
#

Hnn

#

Soo can we make plugin for the leftovers of a destroyed building?

#

Dont like the dirt blob we have rn

#

I want a bit of destroyed structure

#

At leasr

#

If we can make it then great!

torpid spear
#

how is this lua related

stoic vector
#

If we can code it

#

I mean is it possible to code it in?

torpid spear
#

destroyed by a disaster?

#

not that I'm aware of

stoic vector
#

Dang :(

light plinth
#

You can specify the destruction attribute with an ID

#

It will replace the destroyed building

#

the building of the specified ID must have to be 1x1 or match the size of the building thats being destroyed

torpid spear
#

I don't think that's exactly what they are looking for

#

but good to know

stoic vector
#

Ouh i know its official name now

#

Scraps

#

Yea i dont like the texture. I want to make plugins that bring the building leftover atmosphere

#

Like an actually destroyed city like in ww2

lament drift
#

Scrap as hell WHY DOES FIRE HAPPEN TO ME

#

i mentioned RESIDENCIAL COMMERCIAL AND INDUSTRY

shell pawn
#

You sure this is the right channel?

stoic vector
#

This channel we can talk about animation too right?

torpid spear
#

no

stoic vector
#

Dangit

#

Well i gave up on that with a less efficient code anyway <[

stoic vector
#

Wow so cool

fleet falcon
#

i know lua from roblox ๐Ÿ—ฟ

torpid spear
#

ok?

quiet pagoda
potent jolt
#

with all due respect that was almost 3 months ago

vestal storm
#

Aprilfools

zinc isle
#

Ppunish 1174724196807491685

rare grottoBOT
stoic vector
#

hmmm

#

how to lua

#

?

zinc isle
stoic vector
#

I gave up

#

Yea lua is hard af

potent jolt
#

theres a reason programming is a job

weak finch
stoic vector
zinc isle
#

why would you use lua when you can use json?

torpid spear
#

because fun sucks?

zinc isle
#

well if fun is the alternative, use lua DuckPray

#

fun is torturous, never using it again

stoic vector
#

Wait whats fun then?

#

Now i want one for fun!

#

How to fun

weak finch
stoic vector
#

I check a little and hell it is more understandable than lua

#

Yep im really thinking things weirdly

potent jolt
weak finch
#

What you mean with statefull?

#

Example please ๐Ÿฅบ

torpid spear
#

probably meant something like meaningful

potent jolt
stoic vector
#

Wait talking about that, what if make 100 frames for 100 taps, of a building

#

For whatever reason it could be a thing piling up like gold

#

๐Ÿค‘

torpid spear
#

was that a question

stoic vector
#

More like a tought ๐Ÿ˜”

weak finch
#

Lmfao

weak finch
lavish nexus
zinc isle
#

also it just didndt work

lavish nexus
#

Bluds traumatized

zinc isle
#

they way i wanted

weak finch
zinc isle
#

i have it as a lua file but its sitting to be released with new buildings this december ig

#

fun is deginitely not fun

#

apparently fun works faster than lua and its all json but fun ๐Ÿ˜ฉ

weak finch
#

The fun be like
Expectation Reality
Fun ๐Ÿ˜Š ๐Ÿ’€

#

You didn't fun ๐Ÿ˜Š ๐Ÿ’€

#

Hahaha ๐Ÿ˜‚๐Ÿ˜‚

native timber
#

I have a problem, I need your help. Is there any way I can tell if a building is present on the screen? I really need it.

torpid spear
#

as in in the viewport?

#

check if the building is currently rendered?

native timber
#

yes, like this

native timber
#

Still waiting :3

stoic vector
#

After some thinking...

#

Damn i have no need for fun

weak finch
#

Then you will be sad ๐Ÿ˜ข

#

Ever

uncut field
#

that's how the Theos worked if you guys even remember that plugin

uncut field
# native timber Still waiting :3

I tried to make a plugin that would give you info about a building you're looking at, but could never get it to work with the elevated terrain. So that might pose an issue to you if you try to make something like that

#

But im not sure what lua functions are available to you guys these days, so maybe that's easier to figure out now

uncut field
#

In fact, much of the fun stuff is simpler to do in lua. It just takes a little bit to figure out how to type everything if you've never programmed before

#

Lua is a very forgiving language though, so there's really no better place to learn how to code than with lua

stoic vector
#

but now when i try to learn, i realise for what i must learn these? i dont make weird mechanics

native timber
#

Can I play the sound only once/turn off (stop) the sound?

#

*custom sound

#

**custom sound, played by lua

stoic vector
#

I think we can, but i dont do that

native timber
zinc isle
#

I can only tell you it can be done, I cant tell you how, I do not know

native timber
#

Not cool

native timber
#

Due to my inexperience with programming, I would like to ask what is the most effective way to check tiles? Like how I wanted to make from #plugin-discussion how can I check all the tiles of residential zone on all map?

potent jolt
#

doing this would be very inefficient

#

why do you want to check them

#

maybe we can find a method that doesnt require doing that

native timber
#

Whether zone on sand tile

potent jolt
#

for what purpose

native timber
#

Can we access an object by its index?

#

If yes then I have an idea

#

It would be possible to enter all the residential areas on the map into a large array once, and then check each object in turn, assigning it a variable depending on its location. This way we can check all zones only once. Then all that remains is to compare the number of elements in the array.

potent jolt
#

if you cant program you cant tell me if it matters

#

your solution is incredibly slow and what if the user builds new areas

#

you can attach a script to the residential zone draft that will check for the EVENT_PLACED event

#

then check the underlying terrain

native timber
native timber
potent jolt
native timber
#

Cool, but how i saw, it requires x y

potent jolt
#

a script would look something like this ```lua
local attached = false

function script:init()
if not attached then
local name = script:getName()
local residentialDraft = Draft.getDraft('residential zone id')
script:addScript(name, residentialDraft)
attached = true
end
end

function script:event(x, y, _, event)
if event == Script.EVENT_PLACED then
-- a residential tile has been build, now we can do other things
end
end

#

do not blindly copy this, i have not tested it and ive never used addScript

native timber
#

What if the city already had zones that met the condition when the plugin was turned off?

potent jolt
#

we can run through those on entering the city

native timber
potent jolt
#

on entering the city

#

then use script:event for times that they are placed while inside the city

native timber
#

As I understand it, this script only tracks the option to build new zones. What if the zones were already in the city?

zinc isle
#

Well youre going to have to restart the game and enter the city

potent jolt
#

use script:enterCity

#

and check the tiles

#

but only then

#

this is already a bad idea, this will make entering cities pretty slow on phones

native timber
#

its necessary

#

So

#

The best way is to combine checking tiles and script.*

potent jolt
#

yes

#

but you may want to reconsider the whole thing

#

it could end up too slow to release

native timber
#

Would comparing <300 tiles really tax the CPU THAT much?

potent jolt
#

<300?

#

what about a built up giant city

#

thats going to have thousands of them

#

you can make a naive solution first reading all the tiles every time

#

and later add a system to store the tiles in city storage

#

i reccomend you just start trying things

light plinth
#

consider a city that is very big, 1024 tiles in length and 1024 in width

#

you would have to check

#

Pjsk py 1024*1024

rare grottoBOT
#

1048576

light plinth
#

tiles

uncut field
#

You might have to chunk that sort of thing with coroutines to avoid causing so much lag, but that's a pretty advanced topic tbh

#

Maybe you could attach a script to the zone for a single frame when the city loads that gets all their positions and then remove it afterward

#

But I'm not sure if that's possible in the game since I've never attached scripts either

potent jolt
#

i would do the collection process once, save it between reloads and use events to register new zoning

uncut field
#

Well the issue with that is when the user uninstalls the plugin between saves

#

Then if they reinstall it later the data will be stale

#

So you would need a way to overcome that

#

A refresh button might do, but it would be better to automate that somehow so the user doesn't have to manually refresh it

#

Or maybe you can somehow track when the map was last saved and compare it to when the data was last saved. If the plugin data is older then you can recount the tiles

potent jolt
#

thats a case where i call it good enough

#

the worst case is that sometimes, when reinstalling the plugin multiple times it will leave some tiles unchecked

#

alternatively we ignore existing tiles entirely and only check newly placed ones

#

this way a user won't be griefed by unknowingly getting his entire city's zoning replaced

weak mural
#

the time to collecting the tiles from the 512x512 map with coroutine. bear_shrug

weak mural
uncut field
#

What do you mean about running it safely?

weak mural
#

the coroutine will produce the "dead" coroutine and it will give you the infinity errors if there is a fail to clean/stop the coroutine.

#

or at least the fps will drop because of it.

uncut field
#

Ah, I see

potent jolt
#

im just not gonna get into using them

#

better not to risk any concurrency problems

native timber
#

ohohoho

#

Taxes update

weak finch
#

Hehehe

native timber
#

I forgor how to determine the draft by ID ๐Ÿ’€

#

Help pls

torpid spear
#

Draft.getDraft('id')?

native timber
#

Oh thanks

rain pumice
#

Hi to all! I'm a new member here and I need help to create a plugin for TheoTown game in lua because I don't understand this topic, can you help? Plugin description: when building, for example, a school, the happiness of the inhabitants of the education increases by 50

torpid spear
#

you can't modify happiness with lua

rain pumice
#

Pity. Are there other ways to change happiness?

torpid spear
#

provide the actual influences

rain pumice
#

Which TheoTown system features can I work with in lua? That is, those system functions that the developers themselves added when creating the game.

random hamlet
#

Would be cool if this was officially established as the main channel for talking about glsl

#

but nobody does that for now

potent jolt
#

shaders make my brain hurt

random hamlet
#

I should make a few shader plugins later

#

this community needs a bit more variety

icy siren
#

you gotta complete Warsaw Radio Mast plugin

weak finch
#

Just asking please ๐Ÿฅบ

zinc isle
#

why ask him specifically? theres a couple more people around that knows lua

weak finch
#

Because he's a pro

zinc isle
#

everyone who provides actual lua help is profiecient in it

#

like erk, ian, ja and kulche!

weak finch
#

Thank you ๐Ÿ‘

torpid spear
#

any ideas if I can append multiple lua script files to a single draft?

#

can't find anything anywhere

light plinth
#

you can

#

script: [firstFile, secondFile]

#

in the draft definition

torpid spear
#

cool

#

thanks

rain pumice
#

Is it possible to write random fires in lua? And as?

torpid spear
#

random fires?

#

that's a pretty vague description of what you're trying to accomplish

rain pumice
#

Here is a detailed description of what I want: I want some building to catch fire at a random time, it should also be random. P.S. I hope you understood what I want.

torpid spear
#

yes it is possible, but can't you just enable fires in the random disasters menu?

rain pumice
#

So only: a meteorite, a flood, a tornado, an earthquake, a nuclear weapon and a UFO and there is no accidental fire.

torpid spear
#

hm they must've removed it at some point then

#

well, depending on your implementation you'd probably just select a random building/tile every once in a while and just set it on fire

#

doesn't sound particularly difficult

rain pumice
#

Well, what will you do? But I don't know how to do it.

torpid spear
#

what will I do?

#

not much, best I can do is give you links to the resources

#

have a look around

rain pumice
#

Thank you.

trim remnant
#

I'm not really sure what to make of that

cursive crypt
zinc isle
dry violet
#

Created an elegant, easy way to create adaptive GUIbear_img

#

๐Ÿ™‚

dry violet
zinc isle
#

Cool

dry violet
#

So, where's the documentation of BiomeMaker?

torpid spear
#

it doesn't exist

#

as you can see

light plinth
#

It's not a library, but some code that is mistakenly being generated a documentation module for

empty cairn
dry violet
#

nope๏ผŒit hasn't be named

empty cairn
#

ohh

elder glacier
shell pawn
dry violet
digital kindle
#

Finally,the cliff plugin.

drifting bramble
dry violet
drifting bramble
#

This will revolutionize

naive terrace
weak finch
#

Real

drifting bramble
# dry violet

Also another question, what are those lines on the floor?

weak finch
#

Is possible to make something like the DSA moon colonization with LUA?

potent jolt
#

yes

weak finch
drifting bramble
dry violet
digital kindle
uncut field
weak finch
#

Or more in servers?

uncut field
#

I never upload my plugins here

#

Just links to my website

weak finch
#

Another question please ๐Ÿฅบ

#

You're making a city building game right?

lavish nexus
#

Kingtut seems like a familiar name

#

Oh yea hes a youtuber lol

#

Im subscribed even before i went here st the server

uncut field
#

I worked on a city building game called cytopia for a couple years as the lead artist, but the devs abandoned the project

weak finch
#

They planned to add military just asking ๐Ÿฅบ?

uncut field
uncut field
#

We never had plans for that afaik

#

Not that it matters anyway. The game isn't going to be finished

weak finch
#

Thank you so much ๐Ÿ˜Š

#

For the answers ๐Ÿ˜Š๐Ÿ‘

uncut field
#

Youre welcome!

near kelp
#

can i get the plugin pls

zinc isle
near kelp
#

oh thank you

faint whale
#

Some silly things that one does to test the GUI

zinc isle
#

This man made the snake game in theotown, this is funny

royal basin
zinc isle
faint whale
faint whale
royal basin
mild thistle
potent jolt
#

you can do a ton as long as you dont use too many draw calls

#

the real performance impact is really just how many TT calls you make

faint whale
#

Hey, this might be a dumb question, but my brain is fried today. Is there a way to resize an icon?

digital kindle
#

Sir,you might post it in the incorrect channel.

royal pollen
dry violet
#

is there any function that shows building tool of certain building Draft?

#

๐Ÿค”

digital kindle
faint whale
#

I'm leaving this lua game for TT here in case anyone wants to experiment with the GUI.

I understand that having a "Tetrix" in TheoTown might seem unusual, but it's simply code for those who want to explore the GUI, conditionals, saving functionality, etc.

Good luck!

//Clarification: The code was only tested on PC, so on the phone you might see smaller UI and larger text. The code is not fully optimized to be a plugin, but rather serves as a guide. Any further improvements will depend on each person.

faint whale
versed bear
#

Hello where can I get stairs plugin

faint whale
vestal storm
#

Def jacked acc

#

I mean hacked

faint whale
#

Is there a way to change the Setting Dialog Title? (plugins/clouds/cloud.json)

silk pecan
weak mural
faint whale
weak mural
#

no, maybe it depends on the file type, because .plugin and .mpf files have different names.

faint whale
#

Got it, it means that if its uploaded to the plugin store it would show it correctly, thx mate

random hamlet
#

is there a way to make a postprocessing shader?

#

so it's applied to the whole screen and not individual textures

faint whale
#

To continue the conversation about Shaders, there are some usage examples with setUniform (Lua) in the src, and how is it defined in the json? as type Data? Script?

faint whale
#

Some small change

unique maple
#

Need explanation to this error

#

So i could repair it myself

#

For now i'll have to delete this

#

Fun, no monthly income yay

unique maple
#

Nevermind, it requires elevated privelleges

light plinth
#

If you do not provide the code, we cannot help

stoic vector
#

@trim remnant

trim remnant
#

Pmodmenu @shrewd fable

rare grottoBOT
trim remnant
#

Thanks

potent jolt
#

unread messages

#

look inside

#

scam

stoic vector
#

Like 20$ to 50$?

light plinth
#

5 bucks is 5 bucks

faint whale
#

Hey! Is there a way to use the setBuildingIcon without the default red icon? Thx

torpid spear
#

I mean wouldn't it be easier to just use the drawing module

#

unless you want all the fancy features like icon merging

faint whale
faint whale
faint whale
# potent jolt nope

Thx, in any case it works spectacularly, I'm about to change the icon to one that looks good with that red background, since doing it with the drawing module gives me pain having to use 10 more lines of code with setTile and drawImage, to just 1 line of setBuildingIcon.

weak mural
#
Drawing.setTile(tileX, tileY, ((32 * buildingWidth) - frameWidth) / 2, -50)
Drawing.drawImage(frame)```
faint whale
# weak mural ```LUA Drawing.setTile(tileX, tileY, ((32 * buildingWidth) - frameWidth) / 2, -5...

Yes, yes, it works perfectly, the "problem" (just laziness), is that doing with that module also requires adjusting Y based on the height of the building and that's practically doing more code for the same function, but that works too.

In any case if I see that when I decide to publish it in the plugin store and it would look better with the other one, I change it, so everything stays with the vanilla icons.

#

In any case I know that Kulche will come and tell me "Skill issue"๐Ÿ˜…

#

Btw, the Cars module is quite fun, I don't understand why there are so few plugins that use it ๐Ÿ˜…

weak mural
#

you can understand because there are so few creators that use lua. maybe less than 10 or 20 persons. bear_shrug

potent jolt
#

so its not entirely less work

faint whale
faint whale
uncut field
dusky pike
#

function script.Builder.buildBuilding( draft, x, y, frame)

Would this lua code work if i put it into a plugin?

torpid spear
#

no?

#

it does nothing

faint whale
#

Wdym? I don't get it

dusky pike
#

Damn looks like i got it wrong

#

Soo how do i do it ๐Ÿค”

torpid spear
#

lua is a programming language, not a single..........

#

line

#

please read tutorials

dusky pike
#

Imma try testings first with the 1st documentation

#

Hmm

potent jolt
#

youll have to make a seperate lua file as your script

#

then use the script event functions

dusky pike
torpid spear
#

I don't think anyone's got the time or will to explain the entirety of lua scripting to you

#

did you read the tutorial and follow the steps

dusky pike
#

I read some of it

faint whale
# dusky pike I read some of it

You read all the Lua API documentation in 2 hours? You are a beast and the fastest person in the world, I have 2 months reading that and I still haven't finished everything.

torpid spear
#

and what was it exactly

#

which part did you read

dusky pike
#

Oh. I realised i am reading in the wrong direction

faint whale
dusky pike
torpid spear
#

"readinig"????

#

what were you trying to achieve, memorize all the methods??

dusky pike
torpid spear
#

lol

dusky pike
torpid spear
#

once you've figured the basics out feel free to ping if you want to learn how the road alignment script works (it's shrimple)