Page 1 of 1

Animation Dev Tool (Open Source)

Posted: 21 Oct 2020, 09:08
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 642 times

Re: Animation Dev Tool (Open Source)

Posted: 21 Oct 2020, 11:29
by Hadestia
Ughh i want to create text box that can only input is integer like that :(


Btw great Job 100%

Re: Animation Dev Tool (Open Source)

Posted: 21 Oct 2020, 13:51
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

Re: Animation Dev Tool (Open Source)

Posted: 21 Oct 2020, 13:54
by michaelbello123
Does this lua remove the current gui ingame?

Re: Animation Dev Tool (Open Source)

Posted: 22 Oct 2020, 16:00
by THEMAX
This tool is a game changer for plugin creators, gg.

Re: Animation Dev Tool (Open Source)

Posted: 22 Oct 2020, 16:07
by Mlgisawsome02
just set a new standard for lua tool plugins

Re: Animation Dev Tool (Open Source)

Posted: 21 Feb 2021, 09:49
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

Re: Animation Dev Tool (Open Source)

Posted: 21 Feb 2021, 19:47
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.

Re: Animation Dev Tool (Open Source)

Posted: 21 Feb 2021, 21:15
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

Re: Animation Dev Tool (Open Source)

Posted: 18 Apr 2021, 12:36
by WLZZ
Where can I get the ID of the building?

Re: Animation Dev Tool (Open Source)

Posted: 28 Apr 2021, 16:04
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

Re: Animation Dev Tool (Open Source)

Posted: 29 Apr 2021, 18:42
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

Re: Animation Dev Tool (Open Source)

Posted: 30 Apr 2021, 07:16
by Bearbear76
That looks cool. :lol:

Re: Animation Dev Tool (Open Source)

Posted: 02 Sep 2021, 04:25
by Designer Anthony
How am I supposed to save space by using the animation tool for future plugins? How?

Re: Animation Dev Tool (Open Source)

Posted: 02 Sep 2021, 12:13
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.

Re: Animation Dev Tool (Open Source)

Posted: 05 Feb 2022, 04:34
by SRBAPH
So... Theotown also using english language of lua like roblox... Now i'm just gonna do is to make a UI

Re: Animation Dev Tool (Open Source)

Posted: 02 Mar 2022, 01:30
by TheFennekin
Thanks to Kulche I found this :D Definetely will help a lot!

Re: Animation Dev Tool (Open Source)

Posted: 16 Oct 2023, 17:12
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?