HasFunction method evaluates regular knots as True
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 25/100
Direzione di ricerca
Inizia in Story.cs con HasFunction e KnotContainerWithName, quindi esamina l’approccio proposto nella pull request #927. Verifica che un nodo normale come goblin_talk non venga segnalato come funzione, mentre has_revived sì, e che il tentativo di valutare una funzione non produca più l’eccezione segnalata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Context:
Original issue was posted on the unity integration repo, and was requested to be reposted here.
https://github.com/inkle/ink-unity-integration/issues/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:
Exception: Expected external function evaluation to be complete. Stack trace: === THREAD 1/1 (current) ===
[TUNNEL]
Ink.Runtime.StoryState.CompleteFunctionEvaluationFromGame () (at Assets/Ink/InkLibs/InkRuntime/StoryState.cs:1265)
Ink.Runtime.Story.EvaluateFunction (System.String functionName, System.String& textOutput, System.Object[] arguments) (at Assets/Ink/InkLibs/InkRuntime/Story.cs:1868)
Ink.Runtime.Story.EvaluateFunction (System.String functionName, System.Object[] arguments) (at Assets/Ink/InkLibs/InkRuntime/Story.cs:1822)
Core.StoryManager.EvaluateFunction (System.String function, System.Object[] arguments) (at Assets/Scripts/Nosfuratu/Managers/StoryManager.cs:404)
Problem:
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:
https://github.com/inkle/ink/pull/927
- Lingua principale
- C#
- Stelle
- 5k
- Fork
- 550
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di inkle/ink
-
inklecate stack overflow - Knot and variable with same nameForse già presa @voidsipp l’ha presa 19 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 64/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
-
TunnelsAperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 10/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
Issue simili
-
hand-to-AI
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
CactuseSecurity/firewall-orchestrator#5803 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
DXF with empty names failsApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 3 giorni
-
bug python
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
ilia-sokolov/OfficeAgent.NET#89 ·
I maintainer di solito rispondono entro 13 giorni