[Resolved]Help with a Lua condition

Plugin specific problems will be solved here.

Moderator: Plugin Moderators

User avatar
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

[Resolved]Help with a Lua condition

#1

Post by KINGTUT10101 »

Hello,
It's been a long time since I've messed around much with Lua code and I am having some trouble with it as a result. Could someone tell me why my code doesn't function? I believe it's supposed to send a toast when a day passes in a sandbox gamemode, but it doesn't seem to work.

Code: Select all

function script.nextDay ()
if isSandbox () == true then
Debug.toast ("test")
end
end
(On a side note, why can't we attach any file type to our posts? I was prevented from including my Lua file here.. )

User avatar
JustAnyone
Developer
Reactions:
Posts: 3480
Joined: 23 Jul 2017, 12:45
Location: Easter Island
Plugins: Showcase Store

Platform

Re: Help with a Lua condition

#2

Post by JustAnyone »

Should be forum migration issue (@Lobby pls fix)

It should be

Code: Select all

City.isSandbox()

User avatar
Kushagra140
Villager
Reactions:
Posts: 12
Joined: 06 Jun 2020, 19:22
Location: Jodhpur, India
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Help with a Lua condition

#3

Post by Kushagra140 »

Hi this is KUSHAGRA from india , I wanted someone to make plugin featuring indian buildings . I would be thankful for that. Kingtut I am a great fan of your YouTube videos. Please help!!

User avatar
ian`
Supporter
Reactions:
Posts: 117
Joined: 04 Apr 2020, 17:36
Location: Indonesien
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Help with a Lua condition

#4

Post by ian` »

Code: Select all

function script.nextDay () // script:nextDay()
if isSandbox () == true then // City.isSandbox()
Debug.toast ("test")
end
end

User avatar
Bearbear76
Former Bearbear65
Reactions:
Posts: 5730
Joined: 10 Feb 2017, 14:53
Location: L2 cache
Plugins: Showcase Store

Plugin Creator

Platform

Re: Help with a Lua condition

#5

Post by Bearbear76 »

Small Lua tip! :lua:
The following 2 statements are the same. :)

Code: Select all

if City.isSandbox() == true then 
  <...>
end

if City.isSandbox() then
  <...>
end
The opposite would be:

Code: Select all

if City.Sandbox() == false then
  <...>
end

if not City.sandbox() then
  <...>
end
This looks much cleaner so I would recommend using it unless you have to be specific
for example, if nil and false mean 2 different things.

User avatar
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: Help with a Lua condition

#6

Post by KINGTUT10101 »

Ok, thank you guys. Seems like I'm more rusty than I thought lol.

Post Reply Previous topicNext topic

Return to “Problems”