Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
spacebanana420 committed Jul 27, 2024
1 parent 07d1128 commit a69c351
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/runner/runner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private def loopScript(s: Seq[String], ifunc: Seq[Int], nfunc: Seq[String], i: I
else addToArray(name, tvar.value_str)
loopScript(s, ifunc, nfunc, i+1)
case "arrget" =>
val (name, variable, index) = parseArrayAccess(s(i))
val (name, variable, index) = parseArrayAccess(s(i), 7)
getFromArray(name, index) match
case intValue: Int =>
declareInt(variable, intValue)
Expand All @@ -94,7 +94,7 @@ private def loopScript(s: Seq[String], ifunc: Seq[Int], nfunc: Seq[String], i: I
closeTofu(s"Type error! Value '$other' from array '$name' at index $index is not an Int or String!")
loopScript(s, ifunc, nfunc, i+1)
case "arreplace" =>
val (name, value, index) = parseArrayAccess(s(i))
val (name, value, index) = parseArrayAccess(s(i), 9)
val tvar = readVariable_class_safe(value)
if tvar.vartype == variable_type.integer then
replaceInArray(name, index, tvar.value_int)
Expand Down
4 changes: 2 additions & 2 deletions src/variables/varparser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def parseArrayAddition(line: String): (String, String) =
closeTofu(s"Syntax error in array addition: $line\n\nThe array name and/or the new value to append are missing!")
(parts(0), parts(1))

def parseArrayAccess(line: String): (String, String, Int) =
val start = findLineStart(line, 7)
def parseArrayAccess(line: String, keyword_length: Int): (String, String, Int) =
val start = findLineStart(line, keyword_length)
val parts = line.substring(start).split(",").map(x => x.trim())
if parts.length < 3 then
closeTofu(s"Syntax error in array access: $line\n\nThe array name, variable and/or the new value to get are missing!")
Expand Down

0 comments on commit a69c351

Please sign in to comment.