Hi,
I'm a UnityScript user, and I almost get this external function binding mechanism working on my engine but some minor variable delivery problem, this is how I do it:
//test.ink
LIST things = none, badge, notebook, pink_jacket, dusty_box, store_footage, cube, sphere
VAR items = (none)
EXTERNAL check_item (thing)
=== function check_item (thing) ===
{
- items ? thing:
~ return true
- else:
~ return false
}
//IFStory.js
mInkStory.BindExternalFunctionGeneral("check_item", function (args: Object[]) {
return IFManager.CheckItem(args);
});
//IFManager.js
static function CheckItem(args: Object[]) {
print("checking item id:->"+args[0]);
if (IFBag.FindItemById(args[0] as String)) {
return true;
} else {
return false;
}
}
With doing this, I was hoping that the CheckItem function could check the inventory of the player and returns that if a certain item is collected. However, when I use args[0] as String, it get empty string. I suppose the arg[0] in this case is InkList class? I wanna know how could I get the name string of this item(e.g. if I call check_item(badge), then I wanna check if badge is collected by the user in the game, so my CheckItem need to know that the item with id "badge" is what it should be looking for).
Hi,
I'm a UnityScript user, and I almost get this external function binding mechanism working on my engine but some minor variable delivery problem, this is how I do it:
//test.ink
LIST things = none, badge, notebook, pink_jacket, dusty_box, store_footage, cube, sphere
VAR items = (none)
EXTERNAL check_item (thing)
=== function check_item (thing) ===
{
- items ? thing:
~ return true
- else:
~ return false
}
//IFStory.js
mInkStory.BindExternalFunctionGeneral("check_item", function (args: Object[]) {
return IFManager.CheckItem(args);
});
//IFManager.js
static function CheckItem(args: Object[]) {
print("checking item id:->"+args[0]);
if (IFBag.FindItemById(args[0] as String)) {
return true;
} else {
return false;
}
}
With doing this, I was hoping that the CheckItem function could check the inventory of the player and returns that if a certain item is collected. However, when I use args[0] as String, it get empty string. I suppose the arg[0] in this case is InkList class? I wanna know how could I get the name string of this item(e.g. if I call check_item(badge), then I wanna check if badge is collected by the user in the game, so my CheckItem need to know that the item with id "badge" is what it should be looking for).