Animation Dev Tool (Open Source)

The Lua scripting language allows you to give your plugin more advanced features.

Moderator: Plugin Moderators

User avatar
ian`
Supporter
Reactions:
Posts: 104
Joined: Sat Apr 04, 2020 17:36
Location: Indonesien
Plugins: Show
Version: Beta

Platform

Plugin Creator

Animation Dev Tool (Open Source)

#1

Post by ian` »

Free - You may use the contents of this plugin however you like without giving credit.
 ! Message from: ian`
Since this plugin is open source, please do not commercialize or claim this plugin as yourself without any attempt to create a new one. This source of plugins is only for those of you who learn about lua and create masterpieces with it.

All results of light definitions or animations in json array format from this plugin is free, you can use without adding any credit to me.

Please note, this plugin requires at least version 1.9.37.
Please download the latest version of this plugin from the plugin store.  ;) 
screenshot.PNG
This plugin can help to create massive light definitions and other animations. Also this plugin is open source, so it can be helpful to provide some examples of usage of lua especially for this game. :teach

Dummy.lua :lua:

Code: Select all    Reset

-- prevent the draft loaded if the TheoTown version is not supported -- only for plugins that published outside plugin store if Runtime.getVersionCode() >= 1937 then -- create a dummy drafts -- the drafts will be added while init for i=1, 8 do Draft.append([[ [ { "id": "$dummy]]..i..[[", "type": "award", "title": "Dummy size ]]..i..[[ x ]]..i..[[", "category": "$dummyfolder00", "width": ]]..i..[[, "height": ]]..i..[[, "frames": [{"bmp": "dummy_frames.png"}], "script": "main.lua", "draw ground": true, "max count": 1, "build time": 0 } ] ]] ) end end -- dialog to select hidden draft -- the draft only can be selected with this tool local function showDraftDialog() local dialog = GUI.createDialog{ w = 256, h = 256, title = 'Select Building Size' } local listBox = dialog.content:addListBox{} for i=1, 8 do local layout = listBox:addLayout{h=26,spacing=1} local label = layout:getFirstPart():addLabel{ w = -26, text = Draft.getDraft('$dummy'..i):getTitle() } local button = layout:getLastPart():addButton{ w = 0, icon = Icon.BUILD, onClick = function() City.createDraftDrawer('$dummy'..i).select() dialog.close() end } end end -- function to close the build mode and show the dialog -- another function to prevent the dialog show -- when the draft has been built function script:event(x,y,level,event) if event == Script.EVENT_TOOL_ENTER then GUI.get'cmdCloseTool':click() -- prevent the funtion to be called and show an error message if Runtime.getVersionCode() >= 1937 then local draft = Array() for i=1, 8 do draft:add(City.countBuildings(Draft.getDraft('$dummy'..i))) end if draft:contains(1) then Debug.toast('Please remove the last building first') else showDraftDialog() end else Debug.toast('TheoTown version is not supported') end end end
Interactive Lua editor
Run
main.lua :lua:

Code: Select all    Reset

local activeLayer = 1 local buildingId = 'buildingId' local layer = Array{Array{1,'animationId',1,1,1,1,0,0,0,1}} -- Array with contents local temp = {} -- Empty table local toDisplay = {} -- Empty table local toFile = Array() -- Empty array -- create a table to store animation id from user local function userAnimationId() return Util.optStorage(TheoTown.getStorage(), 'userAnimationId') end -- functions to facilitate access to get and set values in nested arrays -- recommended for values that is stored on child table of table local function getDirection(index) local index = index or activeLayer return layer[index][1] end local function setDirection(newState) layer[activeLayer][1] = newState end local function getAnimationId(index) local index = index or activeLayer return layer[index][2] end local function setAnimationId(newState) layer[activeLayer][2] = newState end local function getAbsX(index) local index = index or activeLayer return layer[index][3] end local function setAbsX(newState) layer[activeLayer][3] = newState end local function getAbsY(index) local index = index or activeLayer return layer[index][4] end local function setAbsY(newState) layer[activeLayer][4] = newState end local function getColumn(index) local index = index or activeLayer return layer[index][5] end local function setColumn(newState) layer[activeLayer][5] = newState end local function getRow(index) local index = index or activeLayer return layer[index][6] end local function setRow(newState) layer[activeLayer][6] = newState end local function getDiffX(index) local index = index or activeLayer return layer[index][7] end local function setDiffX(newState) layer[activeLayer][7] = newState end local function getDiffY(index) local index = index or activeLayer return layer[index][8] end local function setDiffY(newState) layer[activeLayer][8] = newState end local function getOffsetY(index) local index = index or activeLayer return layer[index][9] end local function setOffsetY(newState) layer[activeLayer][9] = newState end local function getProbability(index) local index = index or activeLayer return layer[index][10] end local function setProbability(newState) layer[activeLayer][10] = newState end
Interactive Lua editor
Run
for the full version of main.lua code, you can download this plugin on zip format at bellow or visit github.

main.json :json

Code: Select all    Reset

[ { "id": "$dummyfolder00", "type": "category", "frames": [null], "hidden": "true" }, { "id": "$dummy_generator_00", "title": "Animation Dev. Tool", "text": "Attach a night lights or animation to your plugin easily.", "author": "ian`", "type": "tool", "script": "dummy.lua" } ]
JSON checker
Check
The path of file results from this plugin is in '/TheoTown/plugins/Animation Dev Tool/filename.txt' and also you can use clipboard and paste the code on your plugin code. However, clipboard has size limitations, so may causes an errors
animation_dev_tool.zip
Edited : - Fix bug for version < 1.9.42
(7.78 KiB) Downloaded 131 times
Last edited by ian` on Wed Jan 20, 2021 3:16, edited 5 times in total.
:bc

User avatar
rjroldan1
Inhabitant of a Megalopolis
Reactions:
Posts: 653
Joined: Mon Jul 17, 2017 16:16
Location: Philippines
Plugins: Show
Contact:

Platform

Plugin Creator

Re: Animation Dev Tool (Open Source)

#2

Post by rjroldan1 »

Ughh i want to create text box that can only input is integer like that :(


Btw great Job 100%

.╔═╗─────────────╔╗────────
║╬║─╔╗╔╦╗╔═╗╔╗─╔╝║╔═╗─╔═╦╗
║╗╣─╠╣║╔╝║╬║║╚╗║╬║║╬╚╗║║║║
╚╩╝╔╝║╚╝─╚═╝╚═╝╚═╝╚══╝╚╩═╝
───╚═╝────────────────────
T.P.C.
Theotown Philippine Corporation
Plugin creator Doesn't had Cities

User avatar
michaelbello123
Inhabitant of a Megacity
Reactions:
Posts: 194
Joined: Sun Mar 25, 2018 12:56
Location: Outside the Universe
Plugins: Show
Version: Beta

Platform

Re: Animation Dev Tool (Open Source)

#3

Post by michaelbello123 »

I'm slightly learning lua
I know some lua
Like io write, print, etc
And this will be a lot of help for me
Thank you for sharing
MEMES??? :bt :D

User avatar
michaelbello123
Inhabitant of a Megacity
Reactions:
Posts: 194
Joined: Sun Mar 25, 2018 12:56
Location: Outside the Universe
Plugins: Show
Version: Beta

Platform

Re: Animation Dev Tool (Open Source)

#4

Post by michaelbello123 »

Does this lua remove the current gui ingame?
MEMES??? :bt :D

User avatar
THEMAX
Inhabitant of a Universe
Reactions:
Posts: 4284
Joined: Thu Sep 14, 2017 17:30
Location: Astrellia, UHAE
Plugins: Show
Version: Beta

Platform

Plugin Creator

Re: Animation Dev Tool (Open Source)

#5

Post by THEMAX »

This tool is a game changer for plugin creators, gg.
Emperor of Atlantean federated empire
Image
Founder state of Internationxal council
Leader of AEOY and steel pact

User avatar
Mlgisawsome02
Townsman
Reactions:
Posts: 44
Joined: Tue Oct 30, 2018 2:29
Location: the deepest pit of hell, helltower final stage
Plugins: Show
Version: Beta
Contact:

Platform

Plugin Creator

Re: Animation Dev Tool (Open Source)

#6

Post by Mlgisawsome02 »

just set a new standard for lua tool plugins
My quest is to make quality plugins for the cheapest possible, I don't see why something that cost me 0 dollars to make should cost someone else's diamonds :android :json

User avatar
ajimaul
Villager
Reactions:
Posts: 23
Joined: Wed Jan 27, 2021 15:28
Location: Indonesis
Plugins: Show

Plugin Creator

Platform

Re: Animation Dev Tool (Open Source)

#7

Post by ajimaul »

Can you add more id of the lamp in next update sir ??
More lamp color and size...
Ohh in game lamp id 4x4l2 error can't found after i apply to in the building :bd :bd
:android :calc :json newbie

User avatar
ian`
Supporter
Reactions:
Posts: 104
Joined: Sat Apr 04, 2020 17:36
Location: Indonesien
Plugins: Show
Version: Beta

Platform

Plugin Creator

Re: Animation Dev Tool (Open Source)

#8

Post by ian` »

ajimaul wrote:
Sun Feb 21, 2021 9:49
Can you add more id of the lamp in next update sir ??
More lamp color and size...
Ohh in-game lamp id 4x4l2 error can't found after i apply to in the building :bd :bd
actually, all the light id's those i added are already in the game by default, who want to use it only need the id without need another frame. You can add your own lights or animations.

for 4x4l2 there was no problem when i tried it, try to delete the layer and select the light again.
:bc

User avatar
ajimaul
Villager
Reactions:
Posts: 23
Joined: Wed Jan 27, 2021 15:28
Location: Indonesis
Plugins: Show

Plugin Creator

Platform

Re: Animation Dev Tool (Open Source)

#9

Post by ajimaul »

ian` wrote:
Sun Feb 21, 2021 19:47
ajimaul wrote:
Sun Feb 21, 2021 9:49
Can you add more id of the lamp in next update sir ??
More lamp color and size...
Ohh in-game lamp id 4x4l2 error can't found after i apply to in the building :bd :bd
actually, all the light id's those i added are already in the game by default, who want to use it only need the id without need another frame. You can add your own lights or animations.

for 4x4l2 there was no problem when i tried it, try to delete the layer and select the light again.

How do I add my lamp id, i try to add id but cant display anything lol :mrgreen: Sorry for many questions sir. I am a newbie :teach
:android :calc :json newbie

WLZZ
Settler
Reactions:
Posts: 4
Joined: Wed Feb 17, 2021 19:55

Re: Animation Dev Tool (Open Source)

#10

Post by WLZZ »

Where can I get the ID of the building?

Lalulali
Settler
Reactions:
Posts: 4
Joined: Mon Dec 28, 2020 9:07

Platform

Re: Animation Dev Tool (Open Source)

#11

Post by Lalulali »

ajimaul wrote:
Sun Feb 21, 2021 21:15
ian` wrote:
Sun Feb 21, 2021 19:47
ajimaul wrote:
Sun Feb 21, 2021 9:49
Can you add more id of the lamp in next update sir ??
More lamp color and size...
Ohh in-game lamp id 4x4l2 error can't found after i apply to in the building :bd :bd
actually, all the light id's those i added are already in the game by default, who want to use it only need the id without need another frame. You can add your own lights or animations.

for 4x4l2 there was no problem when i tried it, try to delete the layer and select the light again.

How do I add my lamp id, i try to add id but cant display anything lol :mrgreen: Sorry for many questions sir. I am a newbie :teach
if you want to use your own night animation frame you need to make your json looks llike this

Code: Select all    Reset

[ { "id":"light003", "type":"animation", "frames":[{"bmp": "light 3.png"}], "override": true, "light": true, "light switching": true }, { "id":"light004", "type":"animation", "frames":[{"bmp": "light 4.png"}], "override": true, "light": true, "light switching": true }, { "id": "$HuMed1", "type": "residential", "author": "lalulali", "width": 1, "height": 1, "frames": [{"bmp": "HuMed 1.png"}], "animation": [{"id":"light003", "x": 21, "y": -5}, {"id":"light004", "x": 18, "y": -11}], "animation night light probability": 1.0, "smoke": [{"id": "$smoke07", "x":10, "y":-19}], "level": 2, "people": 5, "title": "Human Residence", "text": "Human Residence Type 5 For Medium People", "price": 20, "bulldoze price": 35, "build time": 8 } ]
JSON checker
Check
the first 2 definition is for my night animation and the last is your main json, dont forget to provide the frame within your folder, for "x" and "y" value you could use animation dev tools plugin to find it and then copy paste the value into your plugin. i'm not 100% sure that your "x" and "y" value will put on the right place you want so you need to check it manually
Last edited by Lalulali on Wed Apr 28, 2021 16:05, edited 1 time in total.

User avatar
ajimaul
Villager
Reactions:
Posts: 23
Joined: Wed Jan 27, 2021 15:28
Location: Indonesis
Plugins: Show

Plugin Creator

Platform

Re: Animation Dev Tool (Open Source)

#12

Post by ajimaul »

Lalulali wrote:
Wed Apr 28, 2021 16:04
ajimaul wrote:
Sun Feb 21, 2021 21:15
ian` wrote:
Sun Feb 21, 2021 19:47


actually, all the light id's those i added are already in the game by default, who want to use it only need the id without need another frame. You can add your own lights or animations.

for 4x4l2 there was no problem when i tried it, try to delete the layer and select the light again.

How do I add my lamp id, i try to add id but cant display anything lol :mrgreen: Sorry for many questions sir. I am a newbie :teach
if you want to use your own night animation frame you need to make your json looks llike this

Code: Select all    Reset

[ { "id":"light003", "type":"animation", "frames":[{"bmp": "light 3.png"}], "override": true, "light": true, "light switching": true }, { "id":"light004", "type":"animation", "frames":[{"bmp": "light 4.png"}], "override": true, "light": true, "light switching": true }, { "id": "$HuMed1", "type": "residential", "author": "lalulali", "width": 1, "height": 1, "frames": [{"bmp": "HuMed 1.png"}], "animation": [{"id":"light003", "x": 21, "y": -5}, {"id":"light004", "x": 18, "y": -11}], "animation night light probability": 1.0, "smoke": [{"id": "$smoke07", "x":10, "y":-19}], "level": 2, "people": 5, "title": "Human Residence", "text": "Human Residence Type 5 For Medium People", "price": 20, "bulldoze price": 35, "build time": 8 } ]
JSON checker
Check
the first 2 definition is for my night animation and the last is your main json, dont forget to provide the frame within your folder, for "x" and "y" value you could use animation dev tools plugin to find it and then copy paste the value into your plugin. i'm not 100% sure that your "x" and "y" value will put on the right place you want so you need to check it manually
I Have done sir
Screenshot_20210327-212213941.jpg
:android :calc :json newbie

User avatar
Bearbear76
Former Bearbear65
Reactions:
Posts: 5423
Joined: Fri Feb 10, 2017 14:53
Plugins: Show
Version: Beta

Platform

Plugin Creator

Re: Animation Dev Tool (Open Source)

#13

Post by Bearbear76 »

That looks cool. :lol:
Just my opinion
I'm probably recompiling my kernel... :o

Post Reply Previous topicNext topic

Return to “Lua Scripting”