Else Heart.Break()

Else Heart.Break()

Not enough ratings
Advanced Coding Guide
By Gl'bgolyb
A compendium of information the game doesn't tell you is possible.
3
   
Award
Favorite
Favorited
Unfavorite
Advanced IF/ELSE parameters
Sometimes, you might find yourself doing this:

if SomeCondition() #do nothing else #do something end

It's not a big deal, but wasting a line of "if" just to filter out all conditions in which something might be true gets annoying. So, the game doesn't tell you this, but you can do this a shorter way

if !SomeCondition() #do something end

Notice the "!"? If you start the conditions of an if statement with !, it inverts the value. This is generally referred to as a "not" statement, and is one of the most fundamentally important functions of sequental logic. Unfortunately, I've yet to find a single time in the game that it tells you that you can do this. And yet still, it works!

On that subject are "and" and "or" statements.
if x == 1 && y == 1 Print("both x and y equal 1") end if x == 1 || y == 1 Print("either x or y equals 1")

Sadly, I've found considerable issues ingame trying to combine ! with && or ||.


Functions with Return Values
Almost every function in the game that you will ever see is a "void" function, meaning it doesn't return a value. Most of the innate functions computers have that you regularly use, however, have return values. Void functions are great for a few things, but largely, their usage is limited and used for a single end.

However, you can make functions that return boolean values, strings, numbers, and even arrays. You make them much the same way as as void functions, but they have to end with a return value.

So, for example, let's say I want to make a function that takes a very large array like GetAllRooms(), and turn the resulting array into something more specific - Let's say I only want an array that contains rooms that have doors I can travel to.

array GetRoomsWithDoors(array rooms) var mf = Connect("MainFrame") array new = [] loop rooms loop things in rooms if mf.GetTypeOfThing(things) == "door" Append(new, @) break end end end return new end

This will return an array that only contains rooms with doors in them. Cool eh? All you have to do is call GetRoomsWithDoors(mf.GetAllRooms()).

Now, if you've ever tried to run a function like this, you might realize the actual depth of the problem- This function might not be very long, but the process to solve it is. In fact, this function searches EVERY ROOM IN THE GAME, looping through EVERY ITEM IN THE ROOM until it finds a door. Even if you've maxed your computer's ingame speed, this function will take more than a full minute to return all the rooms- something very annoying. There are less thorough, but MASSIVELY quicker ways to get this list, though.


StringContains() - An almost hidden function
StringContains(string s, string substring) returns true if string "s" contains the string "substring"

This function is invaluable for filtering out garbage in enormous arrays. It's almost absent from almost every computer in the game- existing only in the weird Recorder computers that track if sebastian enters or hacks things in a room. A few of them have screens- most do not.

So, let's say we go to one of these computers and make a much faster function than the one before.


array FilterOut(array old, string sub1, string sub2) array new = [] loop old if StringContains(@, sub1) #do nothing else if StringContains(@, sub2) #do nothing else Append(@, new) end end return new end array Rooms = FilterOut(mf.GetAllRooms(), "_locker", "_inventory")
This will give you Rooms, an array containing all rooms in the game, EXCEPT those with "_locker" or "_inventory" in their names, giving you a list almost immediately.

But, how often are you going to be in one of the few rooms with one of these recorder computers? There is a solution for this:


Using Remote Computers to Store Code
Most people are familiar with how to do this

var o = Connect("Osc1") o.Print("stuff")

This just makes the computer named "Osc1" print "stuff" on its screen. You can make a computer do anything in its API list by using the dot operator like this. However, you can do much, much more with it.

You can use remote computers to give you all sorts of things.

You might have noticed before I called Connect("MainFrame") to give me the GetAllRooms() function. You can make ANY item with the connect API do this.

var mf = Connect("MainFrame") array people = mf.GetPeople()

You can also call memories from any other computer the same way

var o = Connect("Osc1") string dat = o.LoadMemory("something")

This can be very useful for building programs that can do a wide variety of things that normally would require multiple different computers to achieve. But there's something else it can do too...

You can write your own string, number, bool, and array functions on another computer, and then call it from any computer in the game, without having to rewrite that function!

So imagine you make a tool like this on the computer Osc1

array list() array things = [] things[0] = "SebastianCreditCard" things[1] = "Extractor" things[2] = "Teleporter" things[3] = "FranksModifier" things[4] = "BarYvonne_DoorToToilet" return things end

Then, on any computer

var o = Connect("Osc1") loop o.list() Print(@) end

Using this trick, you can make very long, monotonous things that you type all the time into a single function that you can put on any computer who's name you remember (like the Osc1 - Osc4 ones), and use it without having to type it ever again. I can't tell you how often I use sorting functions like the one I mentioned earlier, and despise typing it out so often. This trick makes coding things far, far faster.


UNDER CONSTRUCTION
There are lots of other quirks of SPRAK that never get told to you ingame, and other tips and tricks that I'll include later. Till now, enjoy. I hope you learned something.


7 Comments
tclord 11 Sep, 2021 @ 1:18pm 
Actually, if you want a very rarely used character, '%' isn't your best choice. I messed around with the character and string stuff in this game and found out a lot of interesting things. Like characters are 16 bits, since it is based on unicode I guess. The range is [-97, 65438], with actual characters being [-65,30]. Anything outside that range, such as for example, IntToChar(12345) just prints as a space, but it is a distinct character that doesn't match any other. So it's pretty easy to just pick some character as a guardian/separator character.
Gl'bgolyb  [author] 1 Sep, 2021 @ 7:55pm 
At some point, I will return to this game, but it's gonna be a while. I'm still in a very busy time in my life and I haven't been able to pave out time to do everything I want.
Gl'bgolyb  [author] 1 Sep, 2021 @ 7:54pm 
I spent a lot of time diving very deep into the game, and ended up just getting very busy with other things. If I continue this guide, I'll have to spend time getting used to it again. That said, I've been using Python at work a lot, so it probably won't be difficult to jump back in when I do.

At any rate, yes, StringContains() is very powerful for creating filtered lists of things- and if you mess around with it a bit, you can store big lists as a single string, and save it as a memory for later access, as long as you also write a code to decompress it. Easiest way I found was to take a character like % that doesn't get used much, and compress a list like [1, 2, 3] to '1%2%3%', then write a code that reads these strings and reallocates them into a list every time you want to access it.

As for other APIs with EnableApi(), I have tried several times to find new ones, but never made any discoveries.
tclord 1 Sep, 2021 @ 4:46pm 
The StringContains() is very interesting. Never noticed that. I guess you could use GetThignsOfType("computer") and filter that list using the existance of StringContains() to get a list of all recorder computers in the game. Think I'll try that.

Speaking of which, is this functionality part of some API you can enableAPI() to put on any computer? Are there any other APIs you know of besides "internet", "arcade", "floppy", "memory" and "door"? You never delivered on your promise in "under construction". I'd love to read more about anything else you'd care to share.
FCC 4 Sep, 2017 @ 2:50pm 
"i believe its the heart code. if you can figure out how to disrupt this without breaking the heart.
i think their might be another ending. (i think)"

Given that the dialog scripts are open source in the game directory, I would recommend not breaking your heart from working too hard at trying not to break the Heart. There's an alternate ending from the one you reported on the forums, but it's still a little sad.

But that's a really cool share about that mysterious floppy. When I played, I never learned how to decode that jumble of characters. Really neat find!
Elonmusk 3 Sep, 2017 @ 7:09pm 
add these to "Aniara OS v 3.5.0.1"

else if cmd == "getconn"
var cons = GetConnections()
loop cons
Print(@)
end
else if cmd == "rcall"
string conid = Input("Connect Id:")
#0 0 == cashiercomputer
string fnName = Input("function name:")
#Unlock
string arrayy = Input("array info")
#door name..
RemoteFunctionCall(conid,fnName,arrayy)
else
Elonmusk 3 Sep, 2017 @ 7:07pm 
var name = Input("Enter name of target: ")
var personId = Connect(name)


loop
Sleep(1.0)
if GetNumericData(name, "corruption") < 10
Sleep(4.0)
///REDACTED CODE///(name)
Sleep(1.0)
SetNumericData(name, "corruption", 100)
end

if Random() < 0.1
///REDACTED CODE///(name)
end
end


this is on a floppy pixie hands you
i believe its the heart code. if you can figure out how to disrupt this without breaking the heart.
i think their might be another ending. (i think)