Page 1 of 1

Particles.lua???

Posted: Fri Sep 20, 2019 1:29 am
by Hammerless Penguin
Does anybody know how to get it? That one lua code that gives you rain,snow ect. I've searched everywhere and had no luck finding it. Is it a built in feature in smbx2?

Re: Particles.lua???

Posted: Fri Sep 20, 2019 2:00 am
by Emral
Yes it is. You can simply load it with local particles = require("particles")

data/scripts/particles has some standard particle systems you can load, too.

Re: Particles.lua???

Posted: Fri Sep 20, 2019 2:21 am
by Hammerless Penguin
Enjl wrote:
Fri Sep 20, 2019 2:00 am
Yes it is. You can simply load it with local particles = require("particles")

data/scripts/particles has some standard particle systems you can load, too.
Is this how you are supposed do it?

Image

Re: Particles.lua???

Posted: Fri Sep 20, 2019 2:23 am
by Emral
No.
https://wohlsoft.ru/pgewiki/Particles.lua
Skip the "installation" section.

Re: Particles.lua???

Posted: Fri Sep 20, 2019 2:27 am
by Hammerless Penguin
Enjl wrote:
Fri Sep 20, 2019 2:23 am
No.
https://wohlsoft.ru/pgewiki/Particles.lua
Skip the "installation" section.
I finally got it to work now thanks.

Added in 6 minutes 47 seconds:
Enjl wrote:
Fri Sep 20, 2019 2:23 am
No.
https://wohlsoft.ru/pgewiki/Particles.lua
Skip the "installation" section.
One more question,Is there any more effects other than rain? The website only told how to do the flame and the rain one. Is there anymore like sandstorms,smoke,snow or fog.

Re: Particles.lua???

Posted: Fri Sep 20, 2019 9:05 am
by Hoeloe
Here's a list of all the particle effects that are built into the engine.

Image

You can also make your own using a custom .ini file in your level folder.

Re: Particles.lua???

Posted: Fri Sep 20, 2019 9:48 am
by Emral
Enjl wrote:
Fri Sep 20, 2019 2:00 am
data/scripts/particles has some standard particle systems you can load, too.
That's where you can find what Hoeloe just posted.

Re: Particles.lua???

Posted: Tue Oct 01, 2019 3:11 am
by Hammerless Penguin
One more extra question. What if i wanted it to rain in only one section instead of the entire level? How do I do it?

Re: Particles.lua???

Posted: Tue Oct 01, 2019 5:16 am
by Emral
Only run the draw call after a check for player.section

Re: Particles.lua???

Posted: Mon Oct 28, 2019 12:25 pm
by DrMekar
Enjl wrote:
Tue Oct 01, 2019 5:16 am
Only run the draw call after a check for player.section
I don't fully understand how that's meant. Doing it like this only leads to Error Message and
I can't find anythink about it in the Wiki article.

Image

Image

Re: Particles.lua???

Posted: Mon Oct 28, 2019 12:45 pm
by Emral
That's not how if statements work. You're trying to call a function. I'll give you the if statement but I also urge to check out the official lua documentation and learn the fundamentals of the language.
if player.section == 0 then
--do stuff
end

Re: Particles.lua???

Posted: Mon Oct 28, 2019 1:13 pm
by DrMekar
Enjl wrote:
Mon Oct 28, 2019 12:45 pm
That's not how if statements work. You're trying to call a function. I'll give you the if statement but I also urge to check out the official lua documentation and learn the fundamentals of the language.
if player.section == 0 then
--do stuff
end
Thanks, but it's still not working. It says there should be a 'then' near the ',', everytime, not
mattering if I write == 0,1 or == 0

Re: Particles.lua???

Posted: Mon Oct 28, 2019 1:49 pm
by Emral
DrMekar wrote:
Mon Oct 28, 2019 1:13 pm
Enjl wrote:
Mon Oct 28, 2019 12:45 pm
That's not how if statements work. You're trying to call a function. I'll give you the if statement but I also urge to check out the official lua documentation and learn the fundamentals of the language.
if player.section == 0 then
--do stuff
end
Thanks, but it's still not working. It says there should be a 'then' near the ',', everytime, not
mattering if I write == 0,1 or == 0
https://www.lua.org/pil/4.3.1.html
Once you understand this my previous post should make more sense. Then again. Dunno where you put a comma.

Re: Particles.lua???

Posted: Mon Oct 28, 2019 2:01 pm
by DrMekar
Enjl wrote:
Mon Oct 28, 2019 1:49 pm
DrMekar wrote:
Mon Oct 28, 2019 1:13 pm
Enjl wrote:
Mon Oct 28, 2019 12:45 pm
That's not how if statements work. You're trying to call a function. I'll give you the if statement but I also urge to check out the official lua documentation and learn the fundamentals of the language.
if player.section == 0 then
--do stuff
end
Thanks, but it's still not working. It says there should be a 'then' near the ',', everytime, not
mattering if I write == 0,1 or == 0
https://www.lua.org/pil/4.3.1.html
Once you understand this my previous post should make more sense. Then again. Dunno where you put a comma.
I will defenitly take a look at this though the level it's used in needs to be done until Halloween.

Image

Here's the full code. I don't know what is meant with the comma either or where lua sees one. (The 0,1 is of course a Comma, though
I don't know how to write it else).

only writing 0 leads to a diffrent message telling me to add 'end'

Re: Particles.lua???

Posted: Mon Oct 28, 2019 2:03 pm
by Emral
every scope in lua needs to be closed. the end in my post was to close the if statement.
as for the comma, if you don't know logical operators like "and" and "or" and need to get the level done quick, i suggest just making two if statements - one checking for section 0, the other for section 1, cause the code you wrote is utter nonsense.
You also need to eventually uncomment the actual draw call.

Re: Particles.lua???

Posted: Mon Oct 28, 2019 2:28 pm
by DrMekar
Enjl wrote:
Mon Oct 28, 2019 2:03 pm
every scope in lua needs to be closed. the end in my post was to close the if statement.
as for the comma, if you don't know logical operators like "and" and "or" and need to get the level done quick, i suggest just making two if statements - one checking for section 0, the other for section 1, cause the code you wrote is utter nonsense.
You also need to eventually uncomment the actual draw call.

Code: Select all

function onCameraUpdate()
    if player.section == 0 then
    effect:Draw();
end

if player.section == 1 then
   effect:Draw();
end
It still says there needs to be a 'end' somewhere, but I just really don't know
where.

Re: Particles.lua???

Posted: Tue Oct 29, 2019 7:47 am
by Hoeloe
Every time you write "function", "then", or "do", you need to have a corresponding "end" to close it off. Currently you have two "then"s, and one "function", but only two "end"s.

Re: Particles.lua???

Posted: Tue Oct 29, 2019 2:42 pm
by DrMekar
Hoeloe wrote:
Tue Oct 29, 2019 7:47 am
Every time you write "function", "then", or "do", you need to have a corresponding "end" to close it off. Currently you have two "then"s, and one "function", but only two "end"s.
Of course. It works now, thanks alot ;)