You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original issue was posted on the unity integration repo, and was requested to be reposted here. inkle/ink-unity-integration#209
I have two ink containers, one a regular knot, and the other a function:
=== goblin_talk ===
...
=== function has_revived ===
...
If I call upon Story.cs's method HasFunction, it evaluates both goblin_talk and has_revived as True (and therefore functions).
This seems to me as incorrect. goblin_talk is a regular knot and should evaluate to False, while has_revived is a function knot and should evaluate to True.
This can lead to accidentally attempting to evaluate a non-function knot which then results with the following exception:
I'm looking at the HasFunction defined in Story.cs. It looks like it's not exclusive to just functions, and actually returns True for values that represent regular knots (not functions).
Looking at the implementation of the method, this makes sense as it is calling upon KnotContainerWithName which in turn is just searching the contents of the main container:
public bool HasFunction (string functionName)
{
try {
return KnotContainerWithName (functionName) != null;
} catch {
return false;
}
}
...
public Runtime.Container KnotContainerWithName (string name)
{
INamedContent namedContainer;
if (mainContentContainer.namedContent.TryGetValue (name, out namedContainer))
return namedContainer as Container;
else
return null;
}
Is this an oversight?
Attempted Solutions:
Looking at the containers themselves, there doesn't really seem to be a clear way to discern if a container is a regular Knot or a Function. The only thing I can see is that if I search within the contents of the container, Functions tend to have a ControlCommand entry labeled PopFunction
This may be one way to discern, but seems hacky. Not sure if that PopFunction could appear elsewhere other than an explicit function knot.
I've posted a pull request with this solution here: #927
The text was updated successfully, but these errors were encountered:
Context:
Original issue was posted on the unity integration repo, and was requested to be reposted here.
inkle/ink-unity-integration#209
I have two ink containers, one a regular knot, and the other a function:
If I call upon
Story.cs
's methodHasFunction
, it evaluates bothgoblin_talk
andhas_revived
asTrue
(and therefore functions).This seems to me as incorrect.
goblin_talk
is a regular knot and should evaluate toFalse
, whilehas_revived
is a function knot and should evaluate toTrue
.This can lead to accidentally attempting to evaluate a non-function knot which then results with the following exception:
Problem:
I'm looking at the
HasFunction
defined inStory.cs
. It looks like it's not exclusive to just functions, and actually returns True for values that represent regular knots (not functions).Looking at the implementation of the method, this makes sense as it is calling upon
KnotContainerWithName
which in turn is just searching the contents of the main container:Is this an oversight?
Attempted Solutions:
Looking at the containers themselves, there doesn't really seem to be a clear way to discern if a container is a regular Knot or a Function. The only thing I can see is that if I search within the contents of the container, Functions tend to have a
ControlCommand
entry labeledPopFunction
This may be one way to discern, but seems hacky. Not sure if that
PopFunction
could appear elsewhere other than an explicit function knot.I've posted a pull request with this solution here:
#927
The text was updated successfully, but these errors were encountered: