Else Heart.Break()

Else Heart.Break()

Grey Cat Dec 8, 2020 @ 5:08pm
[BUG] Append Broken
Hey,
I am slowly learning some SPRAK on EHB and it's really fun.
But there a little problem that has got me pulling my hair out for the last 1-2 hours or so.

When I try to append anything to an array, number or string, the program just simply stops running, no error message, no crashy-smokey-wizzly, no nothing.

Sample Code:

Array arr1 = [1, 2, 3] Print("HEY") Append(arr1, 7) Print("YOU") Print(arr1)

The first print shows "HEY", but the second one isn't printed. Restarting the program by spamming CTRL-R just results in multiple "HEY"s in a row.
I am running the game on linux if that matters any.

If anyone could help,
Thanks.
Last edited by Grey Cat; Dec 8, 2020 @ 5:41pm
< >
Showing 1-7 of 7 comments
Grey Cat Dec 8, 2020 @ 5:40pm 
Another weird behavior I just found

array list = [1, 2, 3] Print("1: " + list) list[3] = 7 Print("2: " + list) Append(list, "no") Print("3: " + list)

The Append on print 3 works fine for some reason.
But if I replace:
list[3] = 7
at print 2 by:
Append(list, 7)
Anything including and after print 2 won't execute. I don't understand this.
Hmm, i tried your examples but they work fine for me. I don't understand this either. ;) I'm also playing on Linux so I think we can eliminate this as possible cause (as unlikely as it might be).

What version of the game are you using? (1.0.9?)
On what ingame computer did you run your code (type and location, or better name)?
And i suspect that is the only code you had on this computer?
(And no other computer connected to this computer and did things (remote execution interrupts the local program flow as far as i remember)? Though this is probably not the reason..)

I remember there being something a bit fishy with array handling last time i checked the EHB code.. but this was half a year ago.. maybe i get back to it during the holidays and can give a you a more in-depth answer. In the meantime some random facts about EHB arrays:
- For arrays I always use `var` instead of `array`, although i don't remember the exact reason why.. just that there was some.. xD
- array initialization from a string is kinda messed up (check the standard code of stoves, and replace `array letters` with `string letters` or `var letters` to see what i mean)
- EHB "arrays" are actually more like "dictionaries" in other progamming languages, meaning you can use arbitrary things as index, not only numbers. e.g. `list["hey"] = "you"` is valid.
Grey Cat Feb 1, 2021 @ 12:32pm 
Hey it's been a while, little update on this as I'm trying to come back to this and I've discoverd few things.

To answer the previous comment:
Originally posted by hannoman, the paper tiger:
What version of the game are you using? (1.0.9?)
1.0.9 yes.
Originally posted by hannoman, the paper tiger:
On what ingame computer did you run your code (type and location, or better name)?
And i suspect that is the only code you had on this computer?
(And no other computer connected to this computer and did things (remote execution interrupts the local program flow as far as i remember)? Though this is probably not the reason..)
A few of the computers, some on the walkway above the plaza, the hotel's lobby computer and other random ones. And yes it was the only code I used.

It still doesn't work really as expected but I have at least found an easy work-around.
To get it to work. you have to declare empty arrays for them to be 'Append'-able.
If you assign any number of elements using the '=' operator to a variable, a subsequent 'Append' will crash the execution of the whole program. (with no smoke smoke or sparks visible).

I have written a simple function to be able to declare an array with pre-existing elements if anyone else also stubles uppon this problem:
array arr(array old) array new = [] loop old Append(new, @) end return new end
Can be used like this
array arr1 = arr([1, 2, 3])

EDIT:
Also tried the game through proton, doesn't seem to work either. So not a linux problem most likely.
Last edited by Grey Cat; Feb 1, 2021 @ 12:34pm
Zem Feb 3, 2021 @ 3:17am 
Several months (years? since last update) and I can second that Append, used with the code samples above (in OP and follow-up post), is broken.

Running the latest version, not running Linux, so it's a safe assumption (including the output errors from Unity) that it applies to all versions and OS.

After running the broken code, output_log.txt contains the following:

(Filename: Line: -1) ArgumentException: key already present in dictionary Parameter name: key at System.Collections.Generic.SortedDictionary`2[ProgrammingLanguageNr1.KeyWrapper,System.Object].Add (KeyWrapper key, System.Object value) [0x00000] in <filename unknown>:0 at ProgrammingLanguageNr1.SprakRunner.API_append (System.Object[] args) [0x00000] in <filename unknown>:0 at ProgrammingLanguageNr1.InterpreterTwo.CallExternalFunction (System.String pFunctionName, System.Object[] pParameters) [0x00000] in <filename unknown>:0 at ProgrammingLanguageNr1.InterpreterTwo.JumpToFunction () [0x00000] in <filename unknown>:0 at ProgrammingLanguageNr1.InterpreterTwo.SwitchOnStatement () [0x00000] in <filename unknown>:0 at ProgrammingLanguageNr1.InterpreterTwo.ExecuteNextStatement () [0x00000] in <filename unknown>:0 at ProgrammingLanguageNr1.InterpreterTwo+<GetEnumerator>c__Iterator0.MoveNext () [0x00000] in <filename unknown>:0 at ProgrammingLanguageNr1.SprakRunner.Step () [0x00000] in <filename unknown>:0 at GameWorld2.Program.Execute (Int32 pExecutions) [0x00000] in <filename unknown>:0 at GameWorld2.Program.Update (Single dt) [0x00000] in <filename unknown>:0 at GameWorld2.ProgramRunner.Update (Single dt) [0x00000] in <filename unknown>:0 at GameWorld2.World.Update (Single dt) [0x00000] in <filename unknown>:0 at RunGameWorld.Update () [0x00000] in <filename unknown>:0 (Filename: Line: -1)

Doubt it'll get officially fixed, but I read something about open source, so someone might come along and drop a solution.

(I've also managed to break Print doing unusual things, except that bug doesn't result in an invisible failure -- It instead complains about not being able to pretty text. Related but separate, I've also managed to cause in-game run-time errors (program compiles fine but smokes out mid-run) by trying code reflection, attempting to daisy-chain connects and remote calls.)
Thx for the helpful post Zem! With the new info i'll be going to dig deeper into it in the next days.
Zem Feb 3, 2021 @ 4:20pm 
Did a little more looking around, and as near as I can tell, the way Append is implemented is inaccurate, or the order of execution is jank.

Array arr1 = [1, 2, 3] Print("HEY") Append(arr1[arr1], 7) Print("YOU") Print(arr1)
(notice the tiny change in Append)

Will compile fine, and run "fine", and give the output of:
HEY YOU [1, 2, 3]

However, after doing so the computer/program will smoke, and upon checking it will have 2 errors (also logged to output_log.txt from Unity):

Error: Can't find the index 'System.Collections.Generic.SortedDictionary`2[ProgrammingLanguageNr1.KeyWrapper,System.Object]' (array) in the array 'arr1'

Error: Can't access value (have you forgotten to return a value from a function?)


The unusual part is that it runs to completion before smoking, and acts as if the Append was never there until after the fact...


One last thing on Append, this will work and spit out no errors:
Array arr1 = [1, 2, 3, arr1] Array arr2 = GetIndexes(arr1) number arrc = Count(arr1) - 1 Print("HEY") Append(arr1[arrc], 7) Print("YOU") Print(arr1) Print(arr2) Print(7) Print(arrc)
With output of:
HEY YOU [1, 2, 3, [7]] [0i, 1i, 2i, 3i] 7 3
So make of that what you will.



Unrelated but also bugged: You can soft-lock yourself by moving into your inventory
-- From any Recorder, or TrapAPI, MovePerson("Sebastian","SebastianCreditCard") if it's in your inventory, or by Slurping to the same place with Connect("SebastianCreditCard") Slurp()
Last edited by Zem; Feb 3, 2021 @ 5:48pm
Grey Cat Feb 11, 2021 @ 12:10pm 
Hey Zem, nice interesting posts !
I had thought to use Count() but wasn't familiar with it yet so I hadn't used it. I wonder if Count is faster than looping over the array hmm

On your first example:
Array arr1 = [1, 2, 3]
Print("HEY")
Append(arr1[arr1], 7)
Print("YOU")
Print(arr1)
It seems like it's trying to use the type or the "address" of 'arr1' to try and dereference the array or something like that. You can get the same behavior by decalring another array or var with no value (instead of Generic.SortedDictionary, you get a Generic.UknownType something like that) and Append to arr1[<var>].
But yeah, the fact that it runs to completion is weird. I put the append and print part into a loop, it runs once, but you get an error on the second iteration on the Append's line.

On you second example I think it works because you are actually Appending to a empty array, "arr1[arrc]" is an undeclared/undefined index/variable, when you Append to it you create an array and it doesn't crash since that array is empty.
This works too for example:
Array arr1 = [1, [], 3] Print("HEY") Append(arr1[1], 7) Print("YOU") Print(arr1)
< >
Showing 1-7 of 7 comments
Per page: 1530 50