wiki.sine.space | sinespace

Difference between revisions of "Scripting/SInventory"

From wiki.sine.space
Jump to: navigation, search
(Replaced content with "This page has moved to: https://docs.sine.space/v/scripting/client-scripting/player/sinventory")
 
Line 1: Line 1:
The SInventory class allows you to access a users inventory
+
This page has moved to: https://docs.sine.space/v/scripting/client-scripting/player/sinventory
 
+
==Members==
+
{{ScriptFunction|void|Authorize|();|Requests access to inventory functions, must be called prior to attempting to access inventory. As soon as the player has accepted the request, the Authorized attribute will be 'true'.|5=
+
<pre> Space.Inventory.Authorize()</pre>}}
+
 
+
{{ScriptFunction|void|Authorize|(Action onAuthorized, Action onRejected);|Requests access to inventory functions, must be called prior to attempting to access inventory. This is different from the above Authorize() as in this one takes event handlers which allows you to immediately take action based on the result.|5=
+
<pre>--this script shows you how to use this function to take authorization and immediately
+
--take action based on the result all in a single prompt (a click in this case)
+
 
+
function ifno()
+
  Space.Log("not authorized")
+
  end
+
 
+
function ifyes()
+
Space.Log("authorized")
+
--your next steps go here
+
  end
+
function click()
+
 
+
  Space.Inventory.Authorize(ifyes,ifno)
+
 
+
end
+
 
+
 
+
Space.Host.ExecutingObject.AddClickable()
+
Space.Host.ExecutingObject.Clickable.OnClick(click) </pre>}}
+
 
+
{{ScriptFunction|void|RequestRefresh|();|Forces a check for external changes to the users inventory, can only be called once every 60 seconds|5=
+
<pre>Space.Inventory.RequestRefresh()</pre>}}
+
 
+
{{ScriptFunction|void|AddToHotbar|(int index, int itemID);|Adds the first found instance of itemID to the players hotbar entry at slot 'index'.|5=
+
<pre>Space.Inventory.AddToHotbar(2, 23423523)</pre>}}
+
 
+
{{ScriptFunction|void|RemoveFromHotbar|(int index);|Remove item at slot index from Hotbar|5=
+
<pre>Space.Inventory.RemoveFromHotbar(2)</pre>}}
+
 
+
 
+
==Properties==
+
{{ScriptFunction|SInventoryItem|Items[]|{ get; }|Returns the array of the users current inventory items|5=
+
<pre>invItems = Space.Inventory.Items</pre>}}
+
{{ScriptFunction|bool|Authorized|{ get; }|Returns true if player has accepted access authorization request to his inventory|5=
+
<pre>isAuthorized = Space.Inventory.Authorized</pre>}}
+
 
+
{{Scripting Navbox}}
+

Latest revision as of 07:08, 19 September 2022

This page has moved to: https://docs.sine.space/v/scripting/client-scripting/player/sinventory