Lua Discussions

Plug-in related stuff can be discussed here.

Moderator: Plugin Moderators

User avatar
Bearbear76
Former Bearbear65
Reactions:
Posts: 5299
Joined: Fri Feb 10, 2017 14:53
Plugins: Show
Version: Beta

Platform

Plugin Creator

Lua Discussions

#1

Post by Bearbear76 »

Just for discussing Lua stuff :lua:
ImageJust my opinion

User avatar
THEMAX
Inhabitant of a Universe
Reactions:
Posts: 4238
Joined: Thu Sep 14, 2017 17:30
Location: Astrellia, UHAE
Plugins: Show
Version: Beta

Platform

Plugin Creator

Re: Lua Discussions

#2

Post by THEMAX »

:lua:
Emperor of Atlantean federated empire
Image
Founder state of Internationxal council
Leader of AEOY and steel pact

ElephantEthan
Inhabitant of a Megacity
Reactions:
Posts: 294
Joined: Sun Aug 26, 2018 14:07
Plugins: Show

Platform

Re: Lua Discussions

#3

Post by ElephantEthan »

Is it possible for a moving car to get a new target without despawning? Also, how would one get the x and y of the building that uses the lua script?

User avatar
KINGTUT10101
1,000,000 inhabitants
Reactions:
Posts: 2047
Joined: Thu Jul 07, 2016 22:50
Location: 'Merica
Plugins: Show
Version: Beta
Contact:

Platform

Plugin Creator

Re: Lua Discussions

#4

Post by KINGTUT10101 »

What would the code for something that checks for two specific values and requires them to both match (like month and day for example) look like? Also, is it possible to have a condition that is only true a random part of the time?

ElephantEthan
Inhabitant of a Megacity
Reactions:
Posts: 294
Joined: Sun Aug 26, 2018 14:07
Plugins: Show

Platform

Re: Lua Discussions

#5

Post by ElephantEthan »

KINGTUT10101 wrote:
Wed Oct 31, 2018 17:30
What would the code for something that checks for two specific values and requires them to both match (like month and day for example) look like?
This script checks the values of month and day everyday and shows a toast if they match.

Code: Select all

function script.nextDay()
if City.getDay() == City.getMonth()
then Debug.toast("These values match!", City.getDay(), City.getMonth())

end
end
Make sure to have two "="s. People usually put only one and the script won't work properly because of it.
Screenshot_20181031-165822.png

User avatar
KINGTUT10101
1,000,000 inhabitants
Reactions:
Posts: 2047
Joined: Thu Jul 07, 2016 22:50
Location: 'Merica
Plugins: Show
Version: Beta
Contact:

Platform

Plugin Creator

Re: Lua Discussions

#6

Post by KINGTUT10101 »

What if you wanted two something like "if x value is 24 and y value is 5-10"? Thanks for the help with the previous post tho.

ElephantEthan
Inhabitant of a Megacity
Reactions:
Posts: 294
Joined: Sun Aug 26, 2018 14:07
Plugins: Show

Platform

Re: Lua Discussions

#7

Post by ElephantEthan »

KINGTUT10101 wrote:
Thu Nov 01, 2018 1:56
What if you wanted two something like "if x value is 24 and y value is 5-10"? Thanks for the help with the previous post tho.
You can do it like this:

Code: Select all

function script.nextDay()
if City.getDay() == 24 and City.getMonth() >= 5 and City.getMonth() <= 10
then Debug.toast("Eureka!")

end
end
Result: Shows a notification if the current day is 24 and the month is bigger than 5 or equal and if it's smaller than 10 or equal (5, 6, 7, 8, 9, 10)
Screenshot_20181101-135309.png
Or

Code: Select all

function script.nextDay()
if City.getDay() == 24 and City.getMonth() > 5 and City.getMonth() < 10
then Debug.toast("Eureka!")

end
end
Result: Same as above except the month can't be 5 or 10. (6, 7, 8, 9)

There are probably other ways to do this that I can't think of right now.
Hope this helps! :)

User avatar
KINGTUT10101
1,000,000 inhabitants
Reactions:
Posts: 2047
Joined: Thu Jul 07, 2016 22:50
Location: 'Merica
Plugins: Show
Version: Beta
Contact:

Platform

Plugin Creator

Re: Lua Discussions

#8

Post by KINGTUT10101 »

Thanks! That helps a lot!

Post Reply Previous topicNext topic

Return to “Plug-In Discussion”