Lua Discussions
Moderator: Plugin Moderators
- Bearbear76
- Former Bearbear65
- Reactions:
- Posts: 5730
- Joined: 10 Feb 2017, 14:53
- Location: L2 cache
- Plugins: Showcase Store
-
Plugin Creator
Platform
Lua Discussions
Just for discussing Lua stuff
- ElephantEthan
- Inhabitant of a Megacity
- Reactions:
- Posts: 294
- Joined: 26 Aug 2018, 14:07
- Plugins: Showcase Store
-
Platform
Re: Lua Discussions
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?
- 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 Discussions
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: 26 Aug 2018, 14:07
- Plugins: Showcase Store
-
Platform
Re: Lua Discussions
This script checks the values of month and day everyday and shows a toast if they match.KINGTUT10101 wrote: ↑31 Oct 2018, 17:30What 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?
Code: Select all
function script.nextDay()
if City.getDay() == City.getMonth()
then Debug.toast("These values match!", City.getDay(), City.getMonth())
end
end
- 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 Discussions
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: 26 Aug 2018, 14:07
- Plugins: Showcase Store
-
Platform
Re: Lua Discussions
You can do it like this:KINGTUT10101 wrote: ↑01 Nov 2018, 01:56What 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.
Code: Select all
function script.nextDay()
if City.getDay() == 24 and City.getMonth() >= 5 and City.getMonth() <= 10
then Debug.toast("Eureka!")
end
end
Code: Select all
function script.nextDay()
if City.getDay() == 24 and City.getMonth() > 5 and City.getMonth() < 10
then Debug.toast("Eureka!")
end
end
There are probably other ways to do this that I can't think of right now.
Hope this helps!
- 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 Discussions
Thanks! That helps a lot!