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: 117
Joined: 04 Apr 2020, 17:36
Location: Indonesien
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

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 607 times
Last edited by ian` on 20 Jan 2021, 03:16, edited 5 times in total.
User avatar
Hadestia
Inhabitant of a Megalopolis
Reactions:
Posts: 727
Joined: 17 Jul 2017, 16:16
Location: Philippines
Plugins: Showcase Store
Contact:

Plugin Creator

Platform

Re: Animation Dev Tool (Open Source)

#2

Post by Hadestia »

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


Btw great Job 100%
User avatar
michaelbello123
Inhabitant of a Megacity
Reactions:
Posts: 194
Joined: 25 Mar 2018, 12:56
Location: Outside the Universe
Plugins: Showcase Store
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
User avatar
michaelbello123
Inhabitant of a Megacity
Reactions:
Posts: 194
Joined: 25 Mar 2018, 12:56
Location: Outside the Universe
Plugins: Showcase Store
Version: Beta

Platform

Re: Animation Dev Tool (Open Source)

#4

Post by michaelbello123 »

Does this lua remove the current gui ingame?
User avatar
THEMAX
Inhabitant of a Universe
Reactions:
Posts: 4314
Joined: 14 Sep 2017, 17:30
Location: Astrellia, UHAE
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Animation Dev Tool (Open Source)

#5

Post by THEMAX »

This tool is a game changer for plugin creators, gg.
User avatar
Mlgisawsome02
Townsman
Reactions:
Posts: 44
Joined: 30 Oct 2018, 02:29
Location: the deepest pit of hell, helltower final stage
Plugins: Showcase Store
Version: Beta
Contact:

Plugin Creator

Platform

Re: Animation Dev Tool (Open Source)

#6

Post by Mlgisawsome02 »

just set a new standard for lua tool plugins
User avatar
ajimaul
Villager
Reactions:
Posts: 24
Joined: 27 Jan 2021, 15:28
Location: Indonesis
Plugins: Showcase Store

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
User avatar
ian`
Supporter
Reactions:
Posts: 117
Joined: 04 Apr 2020, 17:36
Location: Indonesien
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Animation Dev Tool (Open Source)

#8

Post by ian` »

ajimaul wrote: 21 Feb 2021, 09: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.
User avatar
ajimaul
Villager
Reactions:
Posts: 24
Joined: 27 Jan 2021, 15:28
Location: Indonesis
Plugins: Showcase Store

Plugin Creator

Platform

Re: Animation Dev Tool (Open Source)

#9

Post by ajimaul »

ian` wrote: 21 Feb 2021, 19:47
ajimaul wrote: 21 Feb 2021, 09: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
User avatar
WLZZ
Small-town resident
Reactions:
Posts: 39
Joined: 17 Feb 2021, 19:55
Location: China
Plugins: Showcase Store
Version: Beta

Platform

Re: Animation Dev Tool (Open Source)

#10

Post by WLZZ »

Where can I get the ID of the building?
User avatar
Lalulali
Settler
Reactions:
Posts: 5
Joined: 28 Dec 2020, 09:07

Platform

Re: Animation Dev Tool (Open Source)

#11

Post by Lalulali »

ajimaul wrote: 21 Feb 2021, 21:15
ian` wrote: 21 Feb 2021, 19:47
ajimaul wrote: 21 Feb 2021, 09: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 28 Apr 2021, 16:05, edited 1 time in total.
User avatar
ajimaul
Villager
Reactions:
Posts: 24
Joined: 27 Jan 2021, 15:28
Location: Indonesis
Plugins: Showcase Store

Plugin Creator

Platform

Re: Animation Dev Tool (Open Source)

#12

Post by ajimaul »

Lalulali wrote: 28 Apr 2021, 16:04
ajimaul wrote: 21 Feb 2021, 21:15
ian` wrote: 21 Feb 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
User avatar
Bearbear76
Former Bearbear65
Reactions:
Posts: 5730
Joined: 10 Feb 2017, 14:53
Location: L2 cache
Plugins: Showcase Store

Plugin Creator

Platform

Re: Animation Dev Tool (Open Source)

#13

Post by Bearbear76 »

That looks cool. :lol:
User avatar
Designer Anthony
Reactions:

Re: Animation Dev Tool (Open Source)

#14

Post by Designer Anthony »

How am I supposed to save space by using the animation tool for future plugins? How?
User avatar
Kamikazi
Inhabitant of a Conurbation
Reactions:
Posts: 471
Joined: 27 Jan 2018, 00:58
Location: ESPAÑA
Plugins: Showcase Store
Version: Beta
Contact:

Plugin Creator

Platform

Re: Animation Dev Tool (Open Source)

#15

Post by Kamikazi »

Designer Anthony wrote: 02 Sep 2021, 04:25 How am I supposed to save space by using the animation tool for future plugins? How?
Maybe this will help
viewtopic.php?f=42&t=12958

The trick thay it's use is that there is just a base, a roof and a part that is going to be repeated. You just add a base, then using animation, you add and repeat the parts as an animation.
User avatar
SRBAPH
Villager
Reactions:
Posts: 14
Joined: 13 Jan 2022, 05:59
Location: Cavite, Philippines
Plugins: Showcase Store

Plugin Creator

Platform

Re: Animation Dev Tool (Open Source)

#16

Post by SRBAPH »

So... Theotown also using english language of lua like roblox... Now i'm just gonna do is to make a UI
User avatar
TheFennekin
Neighborhood fox
Reactions:
Posts: 2728
Joined: 24 Aug 2017, 11:17
Location: Wandering around
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Animation Dev Tool (Open Source)

#17

Post by TheFennekin »

Thanks to Kulche I found this :D Definetely will help a lot!
User avatar
MeUsic
Villager
Reactions:
Posts: 8
Joined: 12 Mar 2022, 07:25

Re: Animation Dev Tool (Open Source)

#18

Post by MeUsic »

I found the tool in the game, but I can't understand how to use it, even in the slightest. I have rhe model and lighting layer ready, and I just want to implement the night animation in the game. Can someone please explain to me how to do it?
Post Reply Previous topicNext topic

Return to “Lua Scripting”