Lua chatbox
Moderator: Plugin Moderators
- KINGTUT10101
- 1,000,000 inhabitants
- Reactions:
- Posts: 2220
- Joined: 07 Jul 2016, 22:50
- Location: 'Merica
- Plugins: Showcase Store
- Version: Beta
- Contact:
-
Plugin Creator
Platform
Re: Lua chatbox
https://sites.google.com/view/retrocity ... authuser=0
YouTube channel:
https://youtube.com/c/kingtut-101
- Uncle Koala
- Metropolitan
- Reactions:
- Posts: 142
- Joined: 05 Apr 2020, 14:53
- Location: Pitcairn Islands
- Plugins: Showcase Store
- Version: Beta
- Contact:
-
Plugin Creator
Platform
Re: Lua chatbox
I wonder why does Builder.buildGround remove trees? Would be cooler if it didn't but then we wouldn't have this GIF
Code: Select all
if Car.GoingToCrashIntoEachOther()
then Car.DontCrash
end
- ian`
- Supporter
- Reactions:
- Posts: 117
- Joined: 04 Apr 2020, 17:36
- Location: Indonesien
- Plugins: Showcase Store
- Version: Beta
-
Plugin Creator
Platform
Re: Lua chatbox
For now, you can try like this:Uncle Koala wrote: ↑17 Aug 2020, 00:03Spent quite some time trying to get this to work
sand.gif
I wonder why does Builder.buildGround remove trees? Would be cooler if it didn't but then we wouldn't have this GIF
Code: Select all Reset
local tree local treeFrame function script:earlyTap(x,y) if Tile.isTree(x,y) then -- condition if any trees in position tree = Tile.getTreeDraft(x,y) -- get tree draft treeFrame = Tile.getTreeFrame(x,y) -- get tree frame Builder.buildGround('$asphalt00',x,y) Builder.buildTree(tree,x,y,treeFrame) -- build tree after build ground else -- condition if no tree in position Builder.buildGround('$asphalt00',x,y) end return false end
- Uncle Koala
- Metropolitan
- Reactions:
- Posts: 142
- Joined: 05 Apr 2020, 14:53
- Location: Pitcairn Islands
- Plugins: Showcase Store
- Version: Beta
- Contact:
-
Plugin Creator
Platform
Re: Lua chatbox
Code: Select all
if Car.GoingToCrashIntoEachOther()
then Car.DontCrash
end
- Uncle Koala
- Metropolitan
- Reactions:
- Posts: 142
- Joined: 05 Apr 2020, 14:53
- Location: Pitcairn Islands
- Plugins: Showcase Store
- Version: Beta
- Contact:
-
Plugin Creator
Platform
Re: Lua chatbox
Code: Select all
local draft = $ktt_koala01
City.getBuilding(1, draft)
Code: Select all
if Car.GoingToCrashIntoEachOther()
then Car.DontCrash
end
- ian`
- Supporter
- Reactions:
- Posts: 117
- Joined: 04 Apr 2020, 17:36
- Location: Indonesien
- Plugins: Showcase Store
- Version: Beta
-
Plugin Creator
Platform
Re: Lua chatbox
Code: Select all Reset
local x, y = City.getBuilding(1, draft) local x,y,scale = City.getView() local draft, number = City.getRank()
- Uncle Koala
- Metropolitan
- Reactions:
- Posts: 142
- Joined: 05 Apr 2020, 14:53
- Location: Pitcairn Islands
- Plugins: Showcase Store
- Version: Beta
- Contact:
-
Plugin Creator
Platform
Re: Lua chatbox
Code: Select all
if Car.GoingToCrashIntoEachOther()
then Car.DontCrash
end
- Uncle Koala
- Metropolitan
- Reactions:
- Posts: 142
- Joined: 05 Apr 2020, 14:53
- Location: Pitcairn Islands
- Plugins: Showcase Store
- Version: Beta
- Contact:
-
Plugin Creator
Platform
Re: Lua chatbox
Building a park works...
Code: Select all Reset
function script:nextDay() draft = Draft.getDraft("$park01") Debug.toast("Building", draft) if Builder.isBuildingBuildable(draft, 0, 0) then Debug.toast("Buildable!" ) else Debug.toast("Nope!" ) end Builder.buildBuilding(draft, 0, 0, 0) end
Code: Select all Reset
function script:nextDay() draft = Draft.getDraft("$res01") Debug.toast("Building", draft) if Builder.isBuildingBuildable(draft, 0, 0) then Debug.toast("Buildable!" ) else Debug.toast("Nope!" ) end Builder.buildBuilding(draft, 0, 0, 0) end
Code: Select all
if Car.GoingToCrashIntoEachOther()
then Car.DontCrash
end
- CommanderABab
- AB
- Reactions:
- Posts: 11109
- Joined: 07 Jun 2016, 21:12
- Plugins: Showcase Store
- Version: Beta
-
Plugin Creator
Platform
- Uncle Koala
- Metropolitan
- Reactions:
- Posts: 142
- Joined: 05 Apr 2020, 14:53
- Location: Pitcairn Islands
- Plugins: Showcase Store
- Version: Beta
- Contact:
-
Plugin Creator
Platform
Re: Lua chatbox
Code: Select all
if Car.GoingToCrashIntoEachOther()
then Car.DontCrash
end
- CommanderABab
- AB
- Reactions:
- Posts: 11109
- Joined: 07 Jun 2016, 21:12
- Plugins: Showcase Store
- Version: Beta
-
Plugin Creator
Platform
Re: Lua chatbox
Is it next to a road?
my avatar:
- Uncle Koala
- Metropolitan
- Reactions:
- Posts: 142
- Joined: 05 Apr 2020, 14:53
- Location: Pitcairn Islands
- Plugins: Showcase Store
- Version: Beta
- Contact:
-
Plugin Creator
Platform
Re: Lua chatbox
Suggestion to devs: please add something like Tile.setUntouchable(x, y)
Code: Select all
if Car.GoingToCrashIntoEachOther()
then Car.DontCrash
end
- MarioBitMap
- Villager
- Reactions:
- Posts: 16
- Joined: 31 Jul 2020, 22:54
- Location: Spain
- Plugins: Showcase Store
- Version: Beta
-
Plugin Creator
Platform
Re: Lua chatbox
When playing, I can Access to the menu I've created, but when pressing the button it doesn't shows the next menu.
Code: Select all Reset
local function showMenu(dialog) local parent = GUI.get'$menuparent' local d = '$townhall01' local x = City.countBuildings(d) GUI.createMenu{ source = parent, actions = { {icon = Icon.BUILD, text = 'Town Halls:' , onClick = function() Debug.toast(x) end}, } } end local function showDialog() local dialog dialog = GUI.createDialog{ icon = script:getDraft():getPreviewFrame(), title = 'Test 1', text = 'Will this work? lol', width = 250, height = 120, actions = { { id = '$menuparent', icon = Icon.BUILD, text = equis, onClick = function() showMenu(dialog) end, autoClose = false }, } } closeDialog = dialog.close end function script:init() if closeDialog then closeDialog() closeDialog = nil showDialog() end end function script:event(_, _, _, event) if event == Script.EVENT_TOOL_ENTER then GUI.get('cmdCloseTool'):click() showDialog() end end
Code: Select all Reset
[ { "id":"MarioBitMap", "category":"Plugin_Creator", "skills":[{"skill":"Pixel_Artist"},{"skill":"Learning_C++_&_TTJson/Lua"}] } ]
- Lobby
- Developer
- Reactions:
- Posts: 3705
- Joined: 26 Oct 2008, 12:34
- Plugins: Showcase Store
- Version: Beta
-
Platform
Re: Lua chatbox
Code: Select all
local d = '$townhall01'
local x = City.countBuildings(d)
Code: Select all
local d = Draft.getDraft('$townhall01')
local x = City.countBuildings(d)
=^._.^= ∫
- MarioBitMap
- Villager
- Reactions:
- Posts: 16
- Joined: 31 Jul 2020, 22:54
- Location: Spain
- Plugins: Showcase Store
- Version: Beta
-
Plugin Creator
Platform
Re: Lua chatbox
Just testing the implementation of a new resource as a variable through
Code: Select all Reset
[ { "id":"MarioBitMap", "category":"Plugin_Creator", "skills":[{"skill":"Pixel_Artist"},{"skill":"Learning_C++_&_TTJson/Lua"}] } ]
- MarioBitMap
- Villager
- Reactions:
- Posts: 16
- Joined: 31 Jul 2020, 22:54
- Location: Spain
- Plugins: Showcase Store
- Version: Beta
-
Plugin Creator
Platform
Re: Lua chatbox
... icon = Icon.EXAMPLE, ...
or are Icon.EXAMPLE a type of harcoded resource that can't be added by users?
Thanks in advance!
Code: Select all Reset
[ { "id":"MarioBitMap", "category":"Plugin_Creator", "skills":[{"skill":"Pixel_Artist"},{"skill":"Learning_C++_&_TTJson/Lua"}] } ]
- ian`
- Supporter
- Reactions:
- Posts: 117
- Joined: 04 Apr 2020, 17:36
- Location: Indonesien
- Plugins: Showcase Store
- Version: Beta
-
Plugin Creator
Platform
Re: Lua chatbox
If you want to add your icons, you still have to write the Json code to making a draft for the image.
Code: Select all Reset
[ { "id":"iconId", "type":"animation", "frames":[{"bmp":"icon.png", "w":24, "h":24}] } ]
Code: Select all Reset
-- you also can make the Json code from lua and call it with Draft.append local iconImage = [[ [ { "id":"iconId", "type":"animation", "frames":[{"bmp":"icon.png", "w":24, "h":24}] } ] ]] Draft.append(iconImage) local yourIcon = Draft.getDraft('iconId'):getFrame(1) -- Or you can make it to be a table local icon = {} icon.FIRST_ICON = Draft.getDraft('iconId'):getFrame(1) icon.SECOND_ICON = Draft.getDraft('iconId'):getFrame(1) icon.ANOTHER_ICON = Draft.getDraft('iconId'):getFrame(1) -- To use GUI.createDialog{ icon = icon.FIRST_ICON }
- MarioBitMap
- Villager
- Reactions:
- Posts: 16
- Joined: 31 Jul 2020, 22:54
- Location: Spain
- Plugins: Showcase Store
- Version: Beta
-
Plugin Creator
Platform
Re: Lua chatbox
Thanks for the help and spending your time into this, hope you have a great day/night!
Code: Select all Reset
[ { "id":"MarioBitMap", "category":"Plugin_Creator", "skills":[{"skill":"Pixel_Artist"},{"skill":"Learning_C++_&_TTJson/Lua"}] } ]
- MarioBitMap
- Villager
- Reactions:
- Posts: 16
- Joined: 31 Jul 2020, 22:54
- Location: Spain
- Plugins: Showcase Store
- Version: Beta
-
Plugin Creator
Platform
Re: Lua chatbox
Draft .append(iconImage)
However, the forum's lua tester doesn't agree with the error given at the game with loading the lua file.
Looks like the game doesn't recognizes Draft functions.
When cut- pasting the code into a local function the error disappears, but the game isn't able to show the icon or open the menu it is linked to.
Code: Select all Reset
[ { "id":"MarioBitMap", "category":"Plugin_Creator", "skills":[{"skill":"Pixel_Artist"},{"skill":"Learning_C++_&_TTJson/Lua"}] } ]
- ian`
- Supporter
- Reactions:
- Posts: 117
- Joined: 04 Apr 2020, 17:36
- Location: Indonesien
- Plugins: Showcase Store
- Version: Beta
-
Plugin Creator
Platform
Re: Lua chatbox
Code: Select all Reset
Draft.append(woodIconJson) -- variable name aren't string, don't use quotation marks.