I don't think there are any arguments. What do you want to do?Temgamer wrote: 26 Jun 2020, 22:53 Also, is it possible to make console command require arguments? I tried TheoTown.registerCommand("testt", function(arg)) but this seems doesn't work how I expected
Lua chatbox
-
Bearbear76
- Inhabitant of a Multiverse
- Reactions:
- Posts: 5701
- Joined: 10 Feb 2017, 12:53
- Location: L2 cache
- Plugins: Showcase Store
-
Plugin Creator
Platform
Re: Lua chatbox
Just my opinion
retired
retired
-
Temgamer
- Villager
- Reactions:
- Posts: 12
- Joined: 16 May 2017, 18:26
- Location: Saint-Petersburg, Russia
- Plugins: Showcase Store
Re: Lua chatbox
I just wanted to make a command, which would set radius and zone around some building by taking radius and zone ID as parametersBearbear76 wrote: 27 Jun 2020, 04:36I don't think there are any arguments. What do you want to do?Temgamer wrote: 26 Jun 2020, 22:53 Also, is it possible to make console command require arguments? I tried TheoTown.registerCommand("testt", function(arg)) but this seems doesn't work how I expected
-
Bearbear76
- Inhabitant of a Multiverse
- Reactions:
- Posts: 5701
- Joined: 10 Feb 2017, 12:53
- Location: L2 cache
- Plugins: Showcase Store
-
Plugin Creator
Platform
Re: Lua chatbox
Tried something like that but it doesn't work. That's why I'm trying to create a terminal in TheoTown which gives you more powerful commands but for personal reasons I can't work on it for a while :/Temgamer wrote: 27 Jun 2020, 06:08I just wanted to make a command, which would set radius and zone around some building by taking radius and zone ID as parametersBearbear76 wrote: 27 Jun 2020, 04:36I don't think there are any arguments. What do you want to do?Temgamer wrote: 26 Jun 2020, 22:53 Also, is it possible to make console command require arguments? I tried TheoTown.registerCommand("testt", function(arg)) but this seems doesn't work how I expected
Just my opinion
retired
retired
-
ian`
- Metropolitan
- Reactions:
- Posts: 117
- Joined: 04 Apr 2020, 15:36
- Location: 日本
- Plugins: Showcase Store
- Version: Beta
-
Plugin Creator
Platform
Re: Lua chatbox
Try to just change the condition variables with command and call that variables in outside of register command function.I just wanted to make a command, which would set radius and zone around some building by taking radius and zone ID as parameters
Code: Select all
local c1 = 0
function script:update()
TheoTown.registerCommand(name,function(name,arg)
if c1 == 0 then
c1 = 1
Debug.toast('On')
elseif c1 == 1 then
c1 = 0
Debug.toast('Off')
end
end)
end
function script:click(x,y,level)
if c1 == 1 then
Your stuff ...
end
end-
ian`
- Metropolitan
- Reactions:
- Posts: 117
- Joined: 04 Apr 2020, 15:36
- Location: 日本
- Plugins: Showcase Store
- Version: Beta
-
Plugin Creator
Platform
Re: Lua chatbox
Why in online i can't save the data to storage and load it back when restart the games?
And what is possible to save data on the city and city visitors load that data what we save before?
-
JustAnyone
- Honorary Contributor
- Reactions:
- Posts: 3666
- Joined: 23 Jul 2017, 10:45
- Location: Easter Island
- Plugins: Showcase Store
-
Platform
Re: Lua chatbox
All scripts or fun transitions are disabled for cities in online mode unless you are the city author and have plugin manifest for your script.
-
Bearbear76
- Inhabitant of a Multiverse
- Reactions:
- Posts: 5701
- Joined: 10 Feb 2017, 12:53
- Location: L2 cache
- Plugins: Showcase Store
-
Plugin Creator
Platform
Re: Lua chatbox
Might be a better way but this is what I came up with.distian wrote: 29 Jun 2020, 11:16 is there a function to separate thousands or millions with ","? like 1,000,000
Code: Select all
local function seperate(value)
local result = ""
value = tostring(value):reverse()
for set in value:gmatch("..?.?") do
result = result..set..","
end
result = result:sub(1, -2):reverse()
return result
end
Just my opinion
retired
retired
-
Lobby
- Inhabitant of a Supercluster
- Reactions:
- Posts: 3760
- Joined: 26 Oct 2008, 10:34
- Plugins: Showcase Store
Re: Lua chatbox
Found another solution that also uses gsub here:
In other languages you'd be able to use the string format function to do that for you, but Lua is different 
Code: Select all
function comma_value(amount)
local formatted = amount
while true do
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
if (k==0) then
break
end
end
return formatted
end
print(comma_value(1234567))
-
ian`
- Metropolitan
- Reactions:
- Posts: 117
- Joined: 04 Apr 2020, 15:36
- Location: 日本
- Plugins: Showcase Store
- Version: Beta
-
Plugin Creator
Platform
Re: Lua chatbox
Thanks.
I tried it before, but didn't work. now it works. lolLobby wrote: 29 Jun 2020, 14:35 Found another solution that also uses gsub here:In other languages you'd be able to use the string format function to do that for you, but Lua is differentCode: Select all
function comma_value(amount) local formatted = amount while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') if (k==0) then break end end return formatted end print(comma_value(1234567))![]()
-
Lobby
- Inhabitant of a Supercluster
- Reactions:
- Posts: 3760
- Joined: 26 Oct 2008, 10:34
- Plugins: Showcase Store
Re: Lua chatbox
Code: Select all Reset
-- Bearbear local function seperate(value) local result = "" value = tostring(value):reverse() for set in value:gmatch("..?.?") do result = result..set.."," end result = result:sub(1, -2):reverse() return result end -- Internet function comma_value(amount) local formatted = amount while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') if (k==0) then break end end return formatted end -- Test print('The bear way: '..seperate(1234567)) print('The internet way: '..comma_value(1234567))
Lua editor
-
Bearbear76
- Inhabitant of a Multiverse
- Reactions:
- Posts: 5701
- Joined: 10 Feb 2017, 12:53
- Location: L2 cache
- Plugins: Showcase Store
-
Plugin Creator
Platform
Re: Lua chatbox
Ah I should of made it with %d.
Fixed the code to work because Lobby wants to click green buttons
Code: Select all Reset
local function seperate(value) local result = "" value = tostring(value):reverse() for set in value:gmatch("%d%d?%d?") do result = result..set.."," end result = result:sub(1, -2):reverse() return result end print(seperate(1234567890))
Lua editor
Just my opinion
retired
retired
-
ian`
- Metropolitan
- Reactions:
- Posts: 117
- Joined: 04 Apr 2020, 15:36
- Location: 日本
- Plugins: Showcase Store
- Version: Beta
-
Plugin Creator
Platform
Re: Lua chatbox
Is there road with road decoration have specific conditions? Because when i'm place road decoration on road, the script doesn't work. Even when i use Tile.isRoadDeco(x,y,level).
-
Lobby
- Inhabitant of a Supercluster
- Reactions:
- Posts: 3760
- Joined: 26 Oct 2008, 10:34
- Plugins: Showcase Store
Re: Lua chatbox
Did you use Builder.isRoadDecoBuildable to check if it is buildable in the first place? Road decorations can define requirements like flags and alignment for the road they can be placed on.
-
ian`
- Metropolitan
- Reactions:
- Posts: 117
- Joined: 04 Apr 2020, 15:36
- Location: 日本
- Plugins: Showcase Store
- Version: Beta
-
Plugin Creator
Platform
Re: Lua chatbox
Still doesn't work. I try to use script:overlay(), that's work, but the script keep updating, not update only once.
-
CommanderABab
- AB
- Reactions:
- Posts: 11270
- Joined: 07 Jun 2016, 19:12
- Plugins: Showcase Store
- Version: Beta
-
Plugin Creator
Platform
Re: Lua chatbox
Seems to work for me. Your crush gives s random answer from the array. Right?distian wrote: 01 Jul 2020, 12:33 Still doesn't work. I try to use script:overlay(), that's work, but the script keep updating, not update only once.
my avatar:
-
ian`
- Metropolitan
- Reactions:
- Posts: 117
- Joined: 04 Apr 2020, 15:36
- Location: 日本
- Plugins: Showcase Store
- Version: Beta
-
Plugin Creator
Platform
Re: Lua chatbox
not about signature. lolCommanderABab wrote: 01 Jul 2020, 16:12 Seems to work for me. Your crush gives s random answer from the array. Right?
Anyway, that is sometime give you an answer not from the array.
-
Lobby
- Inhabitant of a Supercluster
- Reactions:
- Posts: 3760
- Joined: 26 Oct 2008, 10:34
- Plugins: Showcase Store
Re: Lua chatbox
Are you sure?
Regarding your issues with road decorations, how does your exact code look like? Also, overlay is not meant to be used to build stuff, although you can do that
-
ian`
- Metropolitan
- Reactions:
- Posts: 117
- Joined: 04 Apr 2020, 15:36
- Location: 日本
- Plugins: Showcase Store
- Version: Beta
-
Plugin Creator
Platform
Re: Lua chatbox
This isn't about my script, i'm just replied to commanderABab about my signature,
I posted it on misc showcase topic. But, this one of the script : download/file.php?id=32420Regarding your issues with road decorations, how does your exact code look like? Also, overlay is not meant to be used to build stuff, although you can do that![]()