@MoviusC soooo unreal tournament definitely tried terrain maps with their twitch-fps weapons and they were god damned awful lol (Today)

@MoviusC well if it were like a quake map there'd probably be less giant open spaces, or if there were they'd be in… t.co/0LK7FJCbVs (Today)

if PUBG was just like the same concept but a giant quake map and played like quake then I would be dead from playing it for 999999 hours (Today)

@TeddyDief ancient me: "my bloodline will carry out this task for me sometime before the sun consumes our home plan… t.co/T27Mb6a93W (Today)

RT @fell_martins: 💰💎✨ Boys and girls, I'm open for business ✨💎💰 Resposting artwork because most of my stuff is under very secretive NDAs.… (Today)

@RYStorm actually now that I think about it when I get really excited "dude" is one of the first things out of my m… t.co/xjxRg7aZtf (Today)

@dkoontz the brite side (Today)

@MOOMANiBE I grew up in ultra rural upstate new york and somehow I still got it (Today)

when i spend hours on a bug caused by typing x twice instead of x and y t.co/nOkvbJ2XQg (Today)

@NoelFB @RobClemmonsJr coffee totally kills my appetite and I may lean into that more than I should *passes out fro… t.co/QEri4qx8On (Today)

@NoelFB this is a "bad" habit, you say? hmm... interesting... heh heh... *totally not sweating nervously*... (Today)

I've accepted the fact that I'm just going to say "like" 500 times per minute when I'm talking, and that's just, like, how it is. (Today)

@raiganburns yeah something really frustrating about watching a term's meaning totally erode, especially when a ter… t.co/LnabpYVyJQ (Today)

@floatvoid holy poop I havent heard this one yet!! (Today)

@raiganburns seems folks have been using rogue-whatever when they just mean procedural generation for awhile now. (… t.co/yYGOokKJUu (Today)

when are these so called major "esports" teams going to pick up players for link to the past randomizer races?? t.co/mxXI5JRG2X (Yesterday)

@AshBlueWD @ESAdevlog this is legit one of my favorite games of the past couple years. amazingly executed metroidva… t.co/WAQq7r3MQs (2 days ago)

@dannyBstyle Yeah it was an insane disaster and I'm amazed everyone signed on and was like yeah cool this sounds good let's do this (2 days ago)

RT @ESAdevlog: Btw, ESA is 60% off (and OST 30%) this weekend on Steam & Humble Store!! Completely forgot to announce that, whoops https://… (2 days ago)

@dannyBstyle Haha too late. It was... a thing. The original trailer for it was amazing though so I'll just keep watching that. (2 days ago)

follow
search
posts tagged with: google

2015 - 1 - 26 / 12:37 am / tools

Google Spreadsheet Sync

Google Spreadsheet Sync

Have you ever wanted to take the contents of a Google Spreadsheet and drop it right into your game project? So have I! That's why I made a tool that will take the contents of a Google Spreadsheet and turn it into a C# code file full of data!

Demo
Let's say we have a spreadsheet full of data for our video game written in C#, and it looks something like this.

Image

The resulting output of that spreadsheet will be this.

class Sheets {

public static Dictionary<string, CharactersRow> Characters = new Dictionary<string, CharactersRow>() {
{"Adventurer", new CharactersRow() {
Name = "Adventurer",
Health = 100,
Magic = 100,
Attack = 100,
Defense = 100,
Speed = 100,
VictoryPhrase = "Nice try, \"chump!\"",
FailurePhrase = "Ah... well done..."
}},
{"Thief", new CharactersRow() {
Name = "Thief",
Health = 75,
Magic = 100,
Attack = 100,
Defense = 50,
Speed = 200,
VictoryPhrase = "I take what I want!",
FailurePhrase = "Not fair!"
}},
{"Assassin", new CharactersRow() {
Name = "Assassin",
Health = 100,
Magic = 50,
Attack = 200,
Defense = 50,
Speed = 100,
VictoryPhrase = "You're lucky to be alive.",
FailurePhrase = "How could you defeat me?!"
}}
};

public class CharactersRow {
public string Name;
public int Health;
public int Magic;
public int Attack;
public int Defense;
public int Speed;
public string VictoryPhrase;
public string FailurePhrase;
}

public static Dictionary<string, WeaponsRow> Weapons = new Dictionary<string, WeaponsRow>() {
{"Bronze Sword", new WeaponsRow() {
Name = "Bronze Sword",
Attack = 45,
Defense = 0,
Type = WeaponType.Sword,
Value = 100,
CanUpgrade = true
}},
{"Silver Bow", new WeaponsRow() {
Name = "Silver Bow",
Attack = 20,
Defense = 0,
Type = WeaponType.Bow,
Value = 250,
CanUpgrade = true
}},
{"Fire Wand", new WeaponsRow() {
Name = "Fire Wand",
Attack = 35,
Defense = 15,
Type = WeaponType.Staff,
Value = 400,
CanUpgrade = false
}},
{"Lasso", new WeaponsRow() {
Name = "Lasso",
Attack = 30,
Defense = 0,
Type = WeaponType.Whip,
Value = 150,
CanUpgrade = true
}}
};

public class WeaponsRow {
public string Name;
public int Attack;
public int Defense;
public WeaponType Type;
public int Value;
public bool CanUpgrade;
}
}


With a class like that in my project now it becomes very simple to get data from the spreadsheet with the key of the row (the first column.)

var charName = "Adventurer";
var health = Sheets.Characters[charName].Health;
var victoryPhrase = Sheets.Characters[charName].VictoryPhrase;
Console.WriteLine(victoryPhrase);


Download
Download GoogleSpreadsheetSync.zip (0.02MB)

Usage
I use Visual Studio, so I can only really tell you about that.

It's easiest to set this up as an EXTERNAL TOOL in Visual Studio.
* In Visual Studio go to the Tools menu at the top, select "External Tools..."

Image
* Click "Add"
* Name it something like "Google Spreadsheet Sync"
* For Command, press the "..." button to the right and find the exe.
* For arguments you can use "$(TargetName)" "$(ProjectDir)GoogleSheet.key"
* Include the quotes in those arguments!
* For Initial Directory put $(ProjectDir)
* No quotes in that one.
* Below that check the "Use Output Window" option.

Image

Before you run it though you're going to need to create a GoogleSheet.key file. That file should only contain google spreadsheet key.

For this example here's a URL to a published google spreadsheet: https://docs.google.com/spreadsheets/d/11Ia3wr-Pon1180M0_KRR1hywEITLn_P1BoUedbNQeqw/pubhtml

The key is that big long section: 11Ia3wr-Pon1180M0_KRR1hywEITLn_P1BoUedbNQeqw So in this example the contents of your GoogleSheet.key file should only be:

11Ia3wr-Pon1180M0_KRR1hywEITLn_P1BoUedbNQeqw

Save the file as GoogleSheet.key inside your root project folder. (So probably the same folder as your Program.cs)

Image

You should be all set to now run it from Visual Studio! It should appear in your Tools menu. You can even set a keyboard shortcut for it later if you want.

Run the tool from the Tools menu and what should happen is a Sheets.cs file is generated with all the data from your spreadsheets.

Image

Source
Of course it would be way better if you're able to take this tool and craft it into your own needs, so here's the source code!

I've started a public repository where I'll keep any useful tools I create right here.

Trouble?
If you run into any trouble feel free to post a comment and I'll try to help! Or you can reach me at hi@kpulv.com, or the contact form at the bottom of my site.

No Comments

about

About

Hi! My name's Kyle, and I make video games most of the time in Denver, Colorado. Here you will find my thoughts, games, websites, doodles, and other stuff like that. I worked on Snapshot, Offspring Fling, and a whole bunch of other games. I also created and maintain Otter, a 2d game making framework. If you want to get a hold of me use the form on the bottom of the page, leave a comment, or just tweet at me. I try to post three times a week. Thanks for stoppin' by! You're the coolest.

blog stuff

categories

tags

archives

facebook

videos

Do you want to make a Let's Play of one of my games, or a just a video featuring footage of my games? You have my full permission to do so! Even if you are monetizing your videos, you still have my full permission to use any footage from any of my games. Go for it!

contact

Your message has been sent! Thanks :)
SEND MESSAGE