AccidentalRebel.com

Karlo is a programmer for 10+ years who switched to cyber security. He is currently working as a L2 SOC Analyst and is focusing on malware reverse engineering and development.

Chef Wars Postmortem -- What went right: Having a Universe File

in chefwars, gamedev, mindcake, postmortem

Note: This is from a series of articles that outlines the things I've learned while making Chef Wars for 2+ years.

TLDR

  • All data in our game is contained in one excel file we call the "Universe".
  • Prototypes can be done on the Universe excel file itself
  • Iteration is easier as we only need to change one file.
  • We made a system that downloads changes from our server so players don't need to update their builds.

Before we started development on Chef Wars, Cliff, my co-founder and game designer for the team, already had pages of spreadsheets containing important values in the game. It's kinda like a game design document but in the form of tables, columns, and rows. This "Universe" file contained everything from stats, dialogue, competitions, locations, chefs, and enemies just to name a few.

01

*This file definitely gives a hint on what type of guy Cliff is …

Temp Solution For When Text Copying Does Not Work in Emacs Under Windows Subsytem for Linux

in emacs windows linux

One of the problems I was having with my Emacs environment under WSL (Windows Subsystem for Linux, aka. Bash On Windows) is that I could not copy text from WSL Emacs to other Windows applications. Copy and pasting from Windows to Emacs works without any problems so it's weird it does not work the other way around.

I tried a lot of solutions from Google but none of them seem to work. There was an emacs package called simpleclip that worked but the results were not consistent.

I then realized that a temporary solution would be to make use of Windows' clip.exe command line utility which can bme seen below.

(defun arebel-set-clipboard-data (str-val)
  "Puts text in Windows clipboard. Copying to Windows from WSL does 
not work on my end so this one is a temporary solution.

This function is called from within the simpleclip package when copy 
or bgcopy …

Converting org-journal entry to org-page post

in emacs org-mode

Since my recent switch from Wordpress to org-page I wanted a way to convert my org-journal entries to org-page posts. Instead of copying each entry by hand and pasting to an org-page new page buffer I decided to make an elisp code that would do it automatically which can be seen below:

(defun arebel-org-journal-entry-to-org-page-post ()
  "Copy the org-journal entry at point and then convert it to a org-page new post buffer."
  (interactive)
  (if (eq 'org-journal-mode major-mode)
      (let ((headline-text (nth 4 (org-heading-components)))
        (entry-text (org-get-entry)))
    (funcall-interactively 'op/new-post "blog" (concat (buffer-name) "-" headline-text))
    (goto-char (point-max))
    (insert entry-text))
    (message "This function can only be called inside org-journal-mode.")) )

The function is simple and uses functions from org-mode and org-page.

  • First, it checks if the current buffer is in org-journal-mode
  • Then it gets the headline text and entry texts
  • It then calls op/new-post. It does it interactively so that it will trigger the prompts needed to …

Converting org-journal entry to org-page post

in emacs

I needed a way to minify JSON files from Emacs so I made the short function below.

(defun arebel-minify-buffer-contents()
    "Minifies the buffer contents by removing whitespaces."
    (interactive)
    (delete-whitespace-rectangle (point-min) (point-max))
    (mark-whole-buffer)
    (goto-char (point-min))
    (while (search-forward "\n" nil t) (replace-match "" nil t)))

The function is very simple. First it deletes the whitespaces for the whole current buffer then removes every newline.

This effectively turns this:

{
    "glossary": {
        "title": "example glossary",
        "GlossDiv": {
            "title": "S",
            "GlossList": {
                "GlossEntry": {
                    "ID": "SGML",
                    "SortAs": "SGML",
                    "GlossTerm": "Standard Generalized Markup Language",
                    "Acronym": "SGML",
                    "Abbrev": "ISO 8879:1986",
"GlossDef": {


                          "para": "A meta-markup language, used to create markup languages such as DocBook.",
                        "GlossSeeAlso": ["GML", "XML"]
                    },
                    "GlossSee": "markup"
                }
            }
        }
    }
}

To this:

{"glossary": {"title": "example glossary","GlossDiv": {"title": "S","GlossList": {"GlossEntry": {"ID": "SGML","SortAs": "SGML","GlossTerm": "Standard Generalized Markup Language","Acronym": "SGML","Abbrev": "ISO 8879:1986","GlossDef": {"para": "A meta-markup language, used to create markup languages such as DocBook.","GlossSeeAlso": ["GML", "XML"]},"GlossSee": "markup …