A better way to organize and reuse code is with module functions, a unique type of code that stores a set of functions and variables designed to meet a shared purpose, like managing player money or enemies. Code within module functions can be used by other code.
Before I leave, I want people to complete this guide for themselves and switch it to community-made guides since these are very useful when making long code and it MIGHT have different interpretations. Besides, I want to see the new generation attempt to solve a problem. These are basically functions you can call in each function where the parameters are transferred and changed according to your needs. On that note, see ya!
So, @Billybanana here, after a couple hours of work I made my first breakthrough on this project,
When you place a trigger as you probably know you can make it trigger When receiving on a channel. So, what I did is p placed 2 triggers down and made one just say this,
Then in the other trigger I made code for a System where it opens a popup asking if you want to rematch
Then you can re-use the channel to activate that function at any time. Like if you want to check if someone has a higher score than the other when they enter an arena in a Rpg or if you want to check a “Level” system to make sure they are of high enough level.
So, for now, that’s what I have, and I will be working on this until the community comes up with a way to make an actually useful function instead of mine.
@VALUEX:
A function can look like this in block code(in theory):
--creating the function
function add(num1, num2)
return num1 + num2
end
--calling the function
local x = add(5, 5) --returns the value 10
print(x) --printing to the console
Something like that in theory at least, of course it will be much much more complicated than that. I think we should use properties as they are global and their changes are kept. Functions can be updated through /a/ counter(s). In order to do this we need to save the data like PCP’s. We could also (instead of PCP’s) use text manipulation. We can extract certain data from a point in the string and use it in our function.
The way I did it was a bit simpler from all of that. I took into consideration that a calculator is a function in a way. I created a small addition function using 2 properties, 2 counters, and 4 triggers.
Here is the setup:
All that happens is that the two triggers with wires, when stepped on, increment the counter, that changes the value of the properties, then the middle trigger has all the block code essential to the function.
You can now have a function, how?? Well, like this you can broadcast on a channel from another trigger that will then trigger this main trigger and do exactly the same things!
More ideas:
OOP, or objects.