I was inspired to create a save system when I read the idea from the creator of this thread:
http://forum.maratis3d.com/viewtopic.php?id=893

I tried to use the "dofile()" function to load a new "Lua" file that was in the directory of my game, but that didn't work for published games, so I studied the File functions of Lua to build upon the idea from that guy's post.

I've been searching the internet for snippets of code during my whole day.

I'll write the solution here for future generations that discover Maratis:

1. Create a new Project, and place a 3D object on the screen. Use "Player" as the object's name.

2. Create an empty script file called "GameScript.lua" and attach it to your Scene.

3. Then, paste this script into the empty file:

Player = getObject("Player")

function onSceneUpdate()


    --  When the Z button is pressed, we will create the content of the file,
    --  to simulate what happens when a player saves the game for the first time.


    if isKeyPressed("Z") then
    file = io.open("save_data.ini", "w+")
    file:write("1\n2\n3\nturn right")
    file:flush()
    file:close()
    end

    function checkLine(lineNumber, lineContent)

    -- Search for whatever you want by checking for a line number and then checking for the content of the line.
    -- You can copy and paste the next section to search for text in multiple lines.

        if lineNumber == 4 then
            if lineContent == "turn right" then
                rotate(Player, {10, 0, 0}, 1, "local")
            end
            if lineContent == "Maratis is my closest friend" then
                rotate(Player, {-10, 0, 0}, 1, "local")
            end
        end
    end



--  Pressing the X button on your keyboard will start the search by calling the function that's listed above.

    if isKeyPressed("X") then
        f = io.open("save_data.ini", "r")
        count = 0

        for line in f:lines() do
            count = count + 1
            checkLine(count, line)
        end

        f:close()
    end




-- When the C button is pressed, you can modify a single line, like when your player unlocks more content.


    if isKeyPressed("C") then

        local hFile = io.open("save_data.ini", "r") --Reading.
        local lines = {}
        local restOfFile
        local lineCt = 1
        for line in hFile:lines() do
            if(lineCt == 4) then -- This number is the line that you will modify.
                lines[#lines + 1] = "Maratis is my closest friend" --  Change the content of that line here.
                restOfFile = hFile:read("*a")
                break
            else
                lineCt = lineCt + 1
                lines[#lines + 1] = line
            end
        end
        hFile:close()

        hFile = io.open("save_data.ini", "w") -- Write the file.
            for i, line in ipairs(lines) do
                hFile:write(line, "\n")
            end
        hFile:write(restOfFile)
        hFile:close()

    end

end

4. Now, press "File" to open the menu and click "Save", and then press "File" and click "Publish Project".

5. Find your project's directory, and then enter the "published" directory.

6. Create an empty file called "save_data.ini" in that directory.

7. Now, double-click the "exe" file to try the game.

8. When you hold the "X" button on your keyboard, the code will search line 4 of the text file for the text "turn right". Since the file is empty, it will not find the text, so your character won't rotate. When you press the "Z" button, four lines will be created in the text file, like this:

1
2
3
turn right

That's an example of what happens when a player starts a new game and doesn't have saved data yet.

Now that the words "turn right" have been saved in line 4, you can press the "X" button again, and your character will rotate while it's pressed!

You can use this to create a saving system. For example, when the game is first opened, you can make it search for a piece of text on line 27 that says "100", which can mean that all levels have been unlocked. If that text is different, you can choose to only unlock a few levels for your players.

After you do all of that, you should press the "C" button. That will change the text of line 4 from "turn right" to "Maratis is my closest friend". Now, when you press the X button, your character will rotate left instead of right. Study the code to see if you can understand how the rotation changed.

Note: I don't know if your characters will rotate in the directions that I've mentioned because this might depend on how your 3D models are created, but they should still rotate. If they rotate in different directions than the ones I mentioned, you shouldn't think it's because of a glitch.


Important idea about people who are worried about people cheating by changing the text of the file:

If you're worried about people changing the text to unlock the whole game immediately, you can just encrypt it in your head. For example, don't use messages like "All-Weapons-Are-Unlocked". Create random gibberish and track it in a journal while you create your game, so "tztz47sda" on line 27 might mean that all weapons are unlocked. That means that at least one person will have to fully complete your game without cheating before the functions of your gibberish phrases are known. He can share his perfect save file with all other people later, but that happens will all games. Even with games created by professional companies, one guy can finish a whole game without cheating and share that save file with everyone, so don't be scared by this.

2

(64 replies, posted in News)

I installed "Visual Studio 2012 Express for Windows Desktop" and I tried to compile Maratis for Windows x64, but the build was unsuccessful, and I was terrified of the compilation warnings. I researched the errors, but I couldn't comprehend the advice that I found because I don't know how to modify the source code to convert some of the parts to x64.

I'll abandon that pursuit and use the 32-bit version that I compiled for Windows to finally start designing my game.

As a consolation, I compiled the 32-bit version for Linux! I quickly opened it with Lubuntu 14.04 for i386 and it worked after I installed a package called "libopenal1" with Synaptic Package Manager.

Get it here:
https://drive.google.com/drive/folders/ … sp=sharing

3

(64 replies, posted in News)

I also tried to set the "TARGET_ARCH" of SCons to "amd64” and I receive the same error that says " 'CL' is not recognized as an internal or external command, operable program or batch file". That error doesn't happen if I set the "TARGET_ARCH" back to "i386". I wonder if more complex changes must be done to the SCons files before it can compile a 64-bit version of Maratis. I searched for that error on google and many people said the location of the "cl.exe" file must be added to the system PATH environment variable in the SCons files, but I don't know how to do that. The official documentation for SCons is very confusing.

After that, I noticed that a project file for Visual Studio 2010 is included in the source files of Maratis, so I decided to try it, even though a text file says it might not be up to date.

Visual Studio 2010 doesn't include a 64-bit compiler in the Express version, but a free SDK enables 64-bit compilation, so I installed it. Then I opened the project file for Visual Studio 2010, and I fixed many of the compilation errors, but the last few are bothering me.

In Vusual Studio 2010, the part called "MCore" compiles successfully, but when compiling the part called "MEngine", it says a file called "MLog" is missing.

In the Solution Explorer, I see a file called "MLog" and a file called "MLog.h". With a normal file manager, I checked all directories for a file called "MLog" without a file extension, but it doesn't exist. Since this seems like a user error, I deleted "MLog" from the Solution Explorer and added "MLog.cpp" in the same place (and with the same properties) that the "MLog" item had.

Then, I tried compiling MEngine again, and I see this error:

MLog.cpp
..\..\MSDK\MEngine\Sources\MLog.cpp : fatal error C1033: cannot open program database 'c:\maratisvs2010\trunk\dev\projects\visualstudio2010\release\vc100.pdb'

(I wasn't lazy. Visual Studio displays the file location with all lowercase letters.)

Microsoft's documentation says that error C1033 might be a file disk error, possibly related to multi-byte characters in the directory path:
https://msdn.microsoft.com/en-us/librar … .100).aspx
https://docs.microsoft.com/en-us/cpp/er … rror-c1033

The "Maratis" and "MaratisPlayer" parts of the project almost compile correctly. Only two errors appear for each of them, and they are the same for both: It complains of one missing file called "Bullet-C-API.cpp" that actually doesn't exist in Anaël's source files, and it shows this error about a file named MWin32Window.cpp:

..\..\MSDK\MGui\Sources\WIN32\MWin32Window.cpp(961): warning C4090: '=' : different '__unaligned' qualifiers

Do any of you have advice for fixing these few errors?

Is my assumption about the "MLog" file correct, or is a file called "MLog" without a file extension actually supposed to be in the source files?

4

(64 replies, posted in News)

I compiled a version for Windows 32-bit. It's based on the most recent version of Maratis from the archive on Google Code (Commit 243):

You can download it here:
https://drive.google.com/drive/folders/ … sp=sharing

I haven't had time to test it thoroughly.

I compiled it on Windows 10 Pro 64-bit with a 64-bit processor, but the "SCons" tool still decided to compile the 32-bit version!

I spent all day trying to compile a 64-bit version for Windows, but I must admit my inadequacies by sleeping now. Hahaha. I will try again tomorrow.

I have these versions of Visual Studio installed:

1: Visual Studio 2010 Express (I read that the "Express" versions cannot compile 64-bit programs unless the SDK is used, and I don't know if the automatic process of SCons can use the SDK.)
2: Visual Studio 2013 Community
3: Visual Studio 2017 Community

I tried many ideas, like editing the SCons files to search for MSVC 12.0 (version 12.0 is actually Visual Studio 2013), and SCons always says that version 12.0 isn't installed! Version 11.0 is detected as installed, even though that number is for Visual Studio 2012 and I DON'T have that installed. As a test, I set the MSVC section of the SCons file to "11.0", and then I changed the option that said "x86" to "x86_64", and the compilation always showed an error similar to "CL not found".

This is the order of my actions:

1. I only had Visual Studio 2017 installed and I couldn't compile it.

2. Then, I installed Visual Studio 2010, and it compiled during the first try.

3. Then, I installed Visual Studio 2013 because I read that the Express versions cannot normally compile 64-bit files, and since Visual Studio 2017 wasn't working (even though it's not an Express version), I needed to move to an older version that can compile 64-bit files with their free versions. Those are called "Community", and the oldest community version is for Visual Studio 2013, so I installed it. I haven't tried to compile a 32-bit version again, so I don't know if installing VS 2013 ruined that process.