Skip to content

Commit

Permalink
deploy: c9a6ffa
Browse files Browse the repository at this point in the history
  • Loading branch information
makspll committed Jan 20, 2025
1 parent 164ec4a commit 9d26206
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 18 deletions.
24 changes: 16 additions & 8 deletions Summary/controlling-script-bindings.html
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,22 @@ <h2 id="registering-script-functions"><a class="header" href="#registering-scrip
<pre><code class="language-lua">hello_world("hi from lua!")
</code></pre>
<h2 id="context-arguments"><a class="header" href="#context-arguments">Context Arguments</a></h2>
<p>Each script function call always receives 2 context arguments, namely:</p>
<ul>
<li><code>CallerContext</code></li>
<li><code>WorldCallbackAccess</code></li>
</ul>
<p>The first one is configured by the caller, and contains requests from the caller to your function, such as "I am calling you from a 1-indexed array system, please convert the index first", This argument is only relevant if you're targeting multiple languages.</p>
<p>The second argument gives you access to the world from your function.</p>
<p>You can opt-in to receive these arguments by adding them to your closure arguments in the above order (either both or just one)</p>
<p>Each script function call always receives an additional context argument: <code>FunctionCallContext</code>.
You can opt-in to receive this argument in your own function definitions by adding it as the first argument.</p>
<p>The context contains requests from the caller to your function, such as "I am calling you from a 1-indexed array system, please convert the index first", This argument is only relevant if you're targeting multiple languages.</p>
<p>It also allows you to retrieve the world via <code>FunctionCallContext::world()</code>.</p>
<p>You can use this as follows:</p>
<pre><code class="language-rust ignore"> NamespaceBuilder::&lt;ReflectReference&gt;::new(&amp;mut world)
.register(
"hello_world",
|ctx: FunctionCallContext, s: String| {
let world = ctx.world()?;
let should_use_0_indexing = ctx.convert_to_0_indexed;
println!(should_use_0_indexing);
println!(s)
Ok(())
},
);</code></pre>
<h2 id="generic-arguments"><a class="header" href="#generic-arguments">Generic Arguments</a></h2>
<p>Sometimes you might want to be generic over the type of argument you're accepting, you can do so by accepting <code>ScriptValue</code> arguments like so:</p>
<pre><code class="language-rust ignore"> NamespaceBuilder::&lt;ReflectReference&gt;::new(&amp;mut world)
Expand Down
24 changes: 16 additions & 8 deletions print.html
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,22 @@ <h2 id="registering-script-functions"><a class="header" href="#registering-scrip
<pre><code class="language-lua">hello_world("hi from lua!")
</code></pre>
<h2 id="context-arguments"><a class="header" href="#context-arguments">Context Arguments</a></h2>
<p>Each script function call always receives 2 context arguments, namely:</p>
<ul>
<li><code>CallerContext</code></li>
<li><code>WorldCallbackAccess</code></li>
</ul>
<p>The first one is configured by the caller, and contains requests from the caller to your function, such as "I am calling you from a 1-indexed array system, please convert the index first", This argument is only relevant if you're targeting multiple languages.</p>
<p>The second argument gives you access to the world from your function.</p>
<p>You can opt-in to receive these arguments by adding them to your closure arguments in the above order (either both or just one)</p>
<p>Each script function call always receives an additional context argument: <code>FunctionCallContext</code>.
You can opt-in to receive this argument in your own function definitions by adding it as the first argument.</p>
<p>The context contains requests from the caller to your function, such as "I am calling you from a 1-indexed array system, please convert the index first", This argument is only relevant if you're targeting multiple languages.</p>
<p>It also allows you to retrieve the world via <code>FunctionCallContext::world()</code>.</p>
<p>You can use this as follows:</p>
<pre><code class="language-rust ignore"> NamespaceBuilder::&lt;ReflectReference&gt;::new(&amp;mut world)
.register(
"hello_world",
|ctx: FunctionCallContext, s: String| {
let world = ctx.world()?;
let should_use_0_indexing = ctx.convert_to_0_indexed;
println!(should_use_0_indexing);
println!(s)
Ok(())
},
);</code></pre>
<h2 id="generic-arguments"><a class="header" href="#generic-arguments">Generic Arguments</a></h2>
<p>Sometimes you might want to be generic over the type of argument you're accepting, you can do so by accepting <code>ScriptValue</code> arguments like so:</p>
<pre><code class="language-rust ignore"> NamespaceBuilder::&lt;ReflectReference&gt;::new(&amp;mut world)
Expand Down
2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion searchindex.json

Large diffs are not rendered by default.

0 comments on commit 9d26206

Please sign in to comment.