English What is Return 1 and how do I use Return 1

2 replies
Goto Page
To the start Previous 1 Next To the start
Up
UrNightmare
User
Offline Off
Hello, so I'm curious about Return 1 and don't know what it is for? I hope you guys can help me
[ String+ ] make string library more extended and advanced! | Kooshie is the best youkai
21.01.22 07:55:13 am
Up
Mami Tomoe
User
Offline Off
About the
return
keyword: https://www.lua.org/pil/4.4.html
So simply,
return 1
will return the number 1 to the function's caller.

But I'm being ignorant by simply telling you that, I know what you mean.
I simply wanted you to understand that
return 1
isn't a magical CS2D super programming spell.

In some of the CS2D hooks, a return value is accepted.
Example of a hook with a return value: cs2d lua hook hitzone
This hook specifies what it expects to receive and what it will do when receiving that value.
The values of which are documented at the bottom of the page under "returned values".
CS2D's most common return value is 1, which usually means "stop" or "cancel" whilst 0 is the opposite, "continue".
But this isn't always applicable, so read the documentation of the hook to learn what to return and when, depending on the task at hand.

On the other hand, hooks such as cs2d lua hook second will not accept any returned values, as it just wouldn't make any sense.
Why would you want to stop the second hook for example?

This should give you enough context and information to hopefully understand what returning does in CS2D hooks.
edited 1×, last 21.01.22 11:18:36 am
Look at me standing, here on my own again
21.01.22 04:19:00 pm
Up
UrNightmare
User
Offline Off
Thank you, I am curious about Return 1. Since I am new to CS2D coding.
[ String+ ] make string library more extended and advanced! | Kooshie is the best youkai
To the start Previous 1 Next To the start