ID:1819679
 
Hello, everyone. I am rather new and had been lurking on the forums for a bit before finally deciding to create an account. I am a little bit experienced in Python, though I've not ever made anything notable. As for BYOND, I have been playing around with the Dream Maker for a couple months now since a friend in school showed it to me, but only at his house. Tsense's learner journal is what encouraged me to do this, and it can be found here: http://www.byond.com/forum/?post=1809475

While I am doing this, I would like to note-- I am not a very experienced programmer. I intend to be trying to learn heavily from tutorials and guides posted on the forums as opposed to just what I see in other sources though, and for that reason I hope to do okay. However, whenever you see something that I have done that is bad form, or have more efficient (but also just as readable) ways to do things, I would be happy to hear it. I may not listen in every instance (I find the absolute paths for proc and object definitions a lot more pleasant to work with), but I will seriously pay attention to criticism and do my best to improve. That is one reason to make this public, after all.

Without further ado, let's begin.

-----

DESIGN: Overall Game

Okay. I think that first off, I would like to make a fantasy game. I always used to play things like Runescape and Planeshift and Minions of Mirth. But I also think that a fantasy game to begin with would be a bit too much to tackle, so... A survival game would be a good initial framework to work from. I want to have things like hunger and sleepiness and maybe thirst and a health system and building and crafting and things like that. I think I can make it playable as a survival game first and then maybe organically add to turn it into that grand fantasy roleplay.

So. I want to have at least an idea of what I want to do before I begin working on it. Let's make a quick little design doc..

---
Interface Systems
* Need a visual way to see how hungry you are, how much sleep you need, how your limbs are doing, and.. interaction. That kind of thing. I honestly don't have the slightest clue how to do all this, so it will probably be last.


Player Systems
* Needs system: Food, sleep. Eat and sleep to fix.
* Crafting: No idea how to go about implementing this, but I will think of something. Most likely will see if I can use datums and 'recipes' to do it.
* Construction: Who doesn't want to create a great wooden hall or a massive castle and declare everyone their servants?
* Skills: Skills. Self explanatory. I hope.


Environment (?) Systems
* Wildlife: I want to have small game, big game which can be a minor threat, and a few little fantasy humanoid creatures.


World (?) Systems
* Time: I don't want a passage of years, but a basic day/night system would be nice. In addition to that, I would like to differentiate between seasons, though I am honestly uncertain on how to go about that...


Debug Systems
* Proper debug file once the game becomes large enough (5000+ lines).
* A configuration file that can be edited by the host in order to change details about the game.

---

Yup. That's it. I don't want to go into too much depth without having even started coding-- I think I can do it all, but I don't know everything yet. Once I am finished, I'll throw up the project onto github or something and then consider myself a newbie no more, chasing my little fantasy project. As for now, I think that I'll begin working on the actual game-- When I'm done for today, I'll make another post detailing what I've gone through.

I don't really expect much if any feedback now. Do hope I get some eventually, though. Time to head to work!
http://www.byond.com/forum/?post=35530

Well. First I think that I'm going to need to get some stats made, and I want to try my hand at datums. I used the tutorial and explanation by Lummox JR above, and after a couple failed starts, managed to create a stat datum that is similar to his.

/stat
var/value
var/max_value
var/modifier
var/description

proc/Modify(x)
var/change = x * modifier
value = min(max(value + change, 0), max_value)

proc/Set(x)
value = min(x, max_value)

proc/ConvertToText()
return "[value]/[max_value]"

New(value, max_value, modifier, description)
src.value = value
src.max_value = max_value
src.modifier = modifier
src.description = description


I confess that my "New()" procedure looks very similar to the __init__ function in Python. That's because that is pretty much exactly how I used it.

I added the modifier variable and the effect from it because I was thinking: stats aren't very different from skills. As far as behavior goes, they seem like pretty much the same thing. However, that brings me to a few new thoughts.

I want every mod to have stats. I do not think I want every mob to have skills-- few NPCs would make use of it, and it would be a waste of memory for every single one to have it. How do I find the solution?

I considered creating a 'skills' variable which would be a list on every single mob. Then, on creation of the mob, I would populate it with necessary skills. However, I'm not quite sure how this would be accomplished-- I need to learn working with lists a bit better before I try that. Or maybe that is how I will learn working with lists a bit better.

Another possibility would be to connect the skills and other things to a 'mind' sort of variable on mobs. That is, create another datum which is a mind and simply populate it with the skills and such. Players would move around with the 'mind'. This would allow you to, for example, add something like a player being moved out of their body and enter another. They would retain skills (a mental thing) while the actual stats would be whatever the body that they entered had. Could create some interesting possibilities.

But that was just silly thinking, rather than action. I thought about it and decided not to do it until the functionality is needed-- I've not even made a map or other mobs to go into or even a human, after all. I'll work on that later, when I also am more certain of being able to manage.

As for now, I think that I will go ahead and create something like a 'who' verb. Later I will add it to the interface.

var/list/players = list()

mob
Login()
..()
players += src

Logout()
players -= src


I decided to put it into a list because I thought about how later I might want to add whispers between players or an OOC or such. I also happened to read this a few days ago and decided at the time that it was very reasonable: http://www.byond.com/forum/?post=1810538

I put some time into it and out popped a who verb and an OOC verb. I decided to do the OOC because-- why not? It would take only a few seconds.

mob
verb/Who()
src << "Players Online: [length(players)]"
for(var/mob/player in players)
src << "[player.key]"

verb/OOC(msg as text)
players << "(OOC) [src.key]: [msg]"


So then there was that.

Now is a good time for me to show my project organization, since I am done for the night. I am trying to do this very well-organized and am focusing on code-correctness above speed and how much I get done. So this will start off slow.. but I think it'll speed up once I get the hang of things. Just doing these simple things required running through the reference back and forth and looking up multiple guides. But I think I'll do well!



I confess, it isn't much. Hopefully it'll turn into something soon. Also: I use workplace files to actually do my code, because it just feels so annoying to go back and forth between files, and the tabs are not very.. efficient, since they stay open automatically. It'd be nice if I could choose ones specifically to stay open. Oh, well.

------

Immediate things I need to learn:

Working with lists beyond just knowing that they exist and I can add and remove stuff from them.

Text manipulation. I want to be able to color and style and do whatever I want to do with the text.

If anyone would be kind enough to send me links to guides for either or both, I would appreciate it. I do intend to review the blue book for both, but either way it would be nice for some community-member made guides-- I've been finding they help a long way.
Python master race.

Just wanted to say I've just started reading your log too. I'm glad people are sharing their thought process, and I'm looking forward to seeing how you guys design games. This looks to be interesting !

(p.s. I like the idea of a survival game too lol. Survival of the fittest.. it does appeal to me - maybe it's a human thing)
Alright. Let me see...

Today, I looked at the code and thought: "I want a configuration file. Not too flashy of one, but one where I can put settings into a simple txt file and use them to mess around with ingame stuff."

So I thought. To begin with, I skimmed the guide and the reference for things that would pertain, and got very lucky: the very first thing listed in the DM reference is the "cache", and within that a link to the file proc. So of course I immediately clicked it and read.

After managing to mess up something as simple as a browse of an html a couple times, I had managed to make a little "motd" file show up when you log in.



And a tiny little idea of how playing with files works. So I messed around a bit more and then decided that I had an idea of what I would do to make a configuration file.

First, I created a class datum called the "master_config", and added a few small variables to it.

master_config
var/motd
var/seasons


Next, I moved the code I had been using for the motd to work alongside this, within its own proc.

    proc/load_motd()
src.motd = file("config/motd.html")


I then began thinking of how I wanted my text files to work. I wanted to be able to give them comments, be able to choose a variable to set and then what I will set it to. For now, I only have the variable "seasons" to set, which I do not intend to keep-- But it will be there to let me know my system is working.

I think that I will need to create a variable which is a list, place into that list every single line within the text file (each line as its own element), and then parse each line. I can have it skip a line if it has a #, which I chose because Python still rules my soul on the inside. I will need something to separate the variable from its value. I think that I can easily just make that a space or a dash. So. First is to make a little procedure that will be able to turn lines of text into a list, with each line being its own element..

That didn't initially work. I couldn't figure out how to play with the text good enough. So I went away for a good hour and came back, this time deciding not only to figure it out, but to do it better. I ended up adding in another variable to the proc, "separator", so that I could separate it based on a bunch of stuff. In this case, I did it on a newline. I was able to figure out once I discovered the "findtext" proc. :D

This was my result:

/proc/text_to_list(text, separator)
var/separator_length = length(separator)
if (separator_length < 1) return list(text)

var/list/iii = list()
var/last_sep = 1
var/current_sep

do
current_sep = findtext(text, separator, last_sep, 0)
iii += copytext(text, last_sep, current_sep)
last_sep = current_sep + separator_length
while (current_sep)

return iii


I do not like that I used do ... while, just because I think it's ugly and confusing, but I couldn't quickly think of another way to ensure that it runs through at least once without making unnecessary variables. If anyone has any suggestions for other ways to make it work, I would be more than happy to listen to them.

It is at this point that I noticed that the built in conversion procs used the standard, "file2text". So I changed the names of my proc to reflect that while making the next one.

Now, I was able to merely bring in the file as text, and.. voila.

/proc/file2list(filename, separator = "\n")
return text2list(file2text(filename), separator)


I was able to turn a file into a list. Yay.

This one was quite a bit easier. I just created a list of lines, and proceeded to check each line. If it had a comment (hash) or was empty, I would use the continue line, regoing through the loop again. It searches for a dash, and if it finds one, it makes all the text before the dash be a text string for the variable 'variable' (creatively named, I know), and what is after the variable 'value'. Afterwards, it checks to ensure that there is a variable, and if there is, it uses a switch statement on it. From there, you can set messages and the actual variables based on what it got. :D

    proc/load(filename)
var/list/lines = file2list(filename)

for(var/iii in lines)
if(!iii) continue

if (length(iii) == 0) continue
if (copytext(iii, 1, 2) == "#") continue

var/pos = findtext(iii, "-")
var/variable = null
var/value = null

if (pos)
variable = lowertext(copytext(iii, 1, pos))
value = copytext(iii, pos + 1)

if (!variable) continue

switch(variable)

if ("seasons")
world << "Seasons set to [value]."
src.seasons = value


Then I made an initialize proc which started both of the loading procedures, motd and this settings one. Then set it to be called upon the world being created and with a debugging verb.

    proc/initialize()
world << "Loading message of the day..."
if(master.load_motd("motd"))
world << "MOTD loaded!"

world << "Loading world settings..."
if(master.load("config/world_settings.txt"))
world << "World settings loaded!"

var/master_config/master

world
New()
master = new()
master.initialize()

..()

/mob
verb/reload_configuration()
master.initialize()

verb/giveMeMotd()
src << browse(master.motd, "window=motd")


Then I moved everything into their respective files and sat down. That was a lot.

I probably didn't do this as efficiently as I could have. But I also couldn't find a guide over it or anything like that, so if someone knows of one, I'd appreciate being pointed over into its direction. But I learned a good bit about files and playing around with text. Still don't know much about lists in BYOND, aside from them not being zero-indexed (the cause of confusion for a bit before I realized it upon rereading the guide.)

One thing I dislike is that while I did get a nice little bit more framework in, I didn't really get any further towards a survival game. I think that next time I am going to go ahead and create a little basic world (itching to try out Ter's map editor guide/snippet thing).

Anyway. Any suggestions for something to try out? Once I have a world together, I have my eyes on creating some sort of lighting system. No idea how I could do that efficiently, though. Hm..

Then there is also map saving, and making the world efficient.. Maybe I could split up the world into chunks and not even do the lighting except for in chunks near a player? Would have to be big enough to be nice but small enough to not be laggy. I do want a day/night system. I also have no idea how to go about doing seasons-- I could have the four basic ones. But how to make the world itself change its look? Maybe there'll be something on the forums about it.

Thanks for reading!