For quite a while the programmimg holy grail is a system to allow for game that has true runtime coding, the ability to alter, add to, and create completely new code for the program while it’s running.
I found a way to do something similar in codea
Here is my code (I apologize for bad formating with the code sample, I’m new to the forum).
function setup()
print("Hello World!")
parameter.text("editCode",
readProjectTab("Main"))
end
function draw()
background(40, 40, 50)
strokeWidth()
saveProjectTab("Main", editCode)
mainTab = readProjectTab("Main")
end
How you use this is you edit the project’s script through the text field, then you tap the restart button. If this was used in a game you would have persistent data containing information such as player location, enemy location, health, inventory, etc so that progress isn’t lost when the project is refreshed. An application of this is ingame modding while running the game
There’s a feature built in to Codea called AirCode that lets you edit the code of your program wirelessly from your desktop, which is kind of similar to what you made here.
@Archimedes - I’ve used this feature to dump extensive debugging output, or to store data, and I know some other people have explored self modifying code.
However, I wouldn’t use it for inventory, health etc, because Codea has specific commands to store and retrieve data.