Forum

> > CS2D > Scripts > What is Return 1 and how do I use Return 1
Forums overviewCS2D overview Scripts overviewLog in to reply

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

2 replies
To the start Previous 1 Next To the start

old Re: What is Return 1 and how do I use Return 1

Mami Tomoe
User Off Offline

Quote
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
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview