Hey there,
I'm using:
Twine 2.1
SugarCube 2.14
I'm trying to call a widget inside my JS function to print out actions that would apply to transferable game items (basically moving an item from one container to the other). This would solve a problem to which I find no work around at the moment in sugarcube and it would allow me to stream line moving items from containers to other containers and between NPC characters and the player (later on I would want to turn my containers into objects with their own names, inventory, size, etc.).
Widget code that I'm trying to call from "InventoryManagmentWidgets" passage ("widget" tag has been defined in this passage).
Now, what I get is something like this:
Is there any way to call widgets defined in a passage and calling it somehow with arguments?
Thank you for your help in advance!
I'm using:
Twine 2.1
SugarCube 2.14
I'm trying to call a widget inside my JS function to print out actions that would apply to transferable game items (basically moving an item from one container to the other). This would solve a problem to which I find no work around at the moment in sugarcube and it would allow me to stream line moving items from containers to other containers and between NPC characters and the player (later on I would want to turn my containers into objects with their own names, inventory, size, etc.).
var $list = $(document.createDocumentFragment()); $list.append('<<transferContainerItemToPlayer' +' $' + container_name + '\"' + item.id + '\"' + ">>").append('<br>');
Widget code that I'm trying to call from "InventoryManagmentWidgets" passage ("widget" tag has been defined in this passage).
$args[0] - source inventory $args[1] - item ID (item.id) %/ <<widget "transferContainerItemToPlayer">>\ <<set $passItem to getItemById($args[1])>> <<if Array.isArray($args[0])>>\ <<if isItem($passItem) is true>>\ <<linkreplace "Take $passItem.name from container">>\ @@color:green;you take $passItem.name from the container!@@\ <<transferItem $args[0] $player.inventory $passItem>>\ <</linkreplace>>\ <<else>> @@color:red;transferContainerItemToPlayer: 2nd argument does not describe an existing item's Id, therefore it cannot be taken from this container!@@ <</if>>\ <<else>>\ @@color:red;transferContainerItemToPlayer: the first argument is not a container!@@ <</if>>\ <</widget>>\
Now, what I get is something like this:
<>When I tried escaping the '<' character and '>' character respectively I ended up with the same results.
Is there any way to call widgets defined in a passage and calling it somehow with arguments?
Thank you for your help in advance!