-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HasFunction method evaluates regular knots as True #209
Comments
Hi! Can you please post this on the main Ink repo? This one is mostly just
a Unity wrapper for it. I agree that this wants improving though, it’s
gotten me in the past too. Ta!
…On Tue, Dec 31, 2024 at 21:50 Shervin Mortazavi ***@***.***> wrote:
Context:
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 functions.
Problem:
I'm looking at the HasFunction defined in Story.cs. It looks like its 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 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.
—
Reply to this email directly, view it on GitHub
<#209>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJR3UEJYFSY7HYJOFBWW5T2IMGRBAVCNFSM6AAAAABUN6GKX2VHI2DSMVQWIX3LMV43ASLTON2WKOZSG43DINRZGE3DEOA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Yes please! I’ll merge it in if Joe accepts the commit on the ink repo. Ta!
…On Thu, Jan 2, 2025 at 22:24 Json Bool ***@***.***> wrote:
@tomkail <https://github.com/tomkail> Certainly, happy to repost this
issue on there as well.
Would you like me to replicate this pull request on the main repo as well?
#210 <#210>
I assume the fix would want to be on both repos?
—
Reply to this email directly, view it on GitHub
<#209 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJR3UC2JXPBU27T4OMLDXD2IW4B5AVCNFSM6AAAAABUN6GKX2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNRYGQ2TKOBWGE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Thanks @tomkail. I've reposted here: Issue: inkle/ink#928 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Context:
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:
#210
The text was updated successfully, but these errors were encountered: