Module Functions (Universal Functions)

Aw man, literally everyone who knows about actual coding already left… Who am I supposed to ask for an explanation now?

I guess this… is just a function? I mean it just looks like a normal python function to me. I don’t know like anythin about coding though.

Imma work on this in the morning, I have about 5 years of python and 2 of swift and dart under my wing. It would be fun to work on this in gimkit

1 Like

Bump

This is basically my first guide.

You don’t need to bump topics with this recent activity.

1 Like

Okay! Noted for next time. Sorry

What’s it called?

Functions

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.
image
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.

1 Like

I don’t see it, could you link it?

Just noticed that the main topic was edited…with this…kinda…

NOOOOO!!! Where was this mind when I made my first guide?! jk.

Here:

That’s cool, what can use it for in a game?

It was an example of a possible way of creating functions.

getrithekd

I personally feel like your guide was much harder to understand than the way it was explained here. I barely understood the concept in that guide. No offense of course, just I maybe have a smaller brain to comprehending that.

Thanks that helps, but I don’t think this is the same thing as @getrithekd 's guide because you still cant use it as a complex line of code like we are trying to make, still I understand why you could say that

Yeah… It was my first guide. So basically you use if statements to see if the function has been done.

1 Like

You can also make “module properties” by setting a property to a value if property 2 is something, which would allow you to make ~10 module properties with 1 property. (concatenation)

ex:
if property 2 = 1:
set property to 1
if property 2 = 2:
set property to 2
if property 2 = 3:
set property to 3

Nice guide, @kyro! Good to see you up and running again (if you don’t leave, that is)!

1 Like