Forum

> > CS2D > Scripts > What is Return 1 and how do I use Return 1
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

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

2 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

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

Mami Tomoe
User Off Offline

Zitieren
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.
1× editiert, zuletzt 21.01.22 11:18:36
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht