ID:179387
 
Soon I'll be adding a game in progress to the hub. For now it will be purely single player, is there any standard way to limit a game to single player, meaning people can't host a server of the game? I know I can do it by only allowing one login but that won't stop people from hosting it.
There's no way that I know of to do this.
Page Darkness. He told me about an auto-closing port code that he knew something about, but he did not tell me what that code was because I did not ask him. Good luck!
var/ppl = 0
client/New()
. = ..()
if(ppl) del src
else ppl = 1

That works well enough for a quick fix.
In response to Nadrew
I just had an idea to set the port = 0 whenever a new client is created, effectively stopping the world from hosting, but it says port is a constant :(

I ended up with this:

client/New()
. = ..()
if(world.port)
world << "*****No Hosting, Single Player Only*****"
del(src)

I tend to use too many global variables as simple solutions so I've been making a special effort to limit using them.
In response to English
I think I probably use global variables too much also. Though, most of the time they cannot be avoided; they need to be set here and loaded and manipulated here, by different clients with different types of mobs and different means of modifying information.
In response to Lord of Water
Lord of Water wrote:
I think I probably use global variables too much also. Though, most of the time they cannot be avoided; they need to be set here and loaded and manipulated here, by different clients with different types of mobs and different means of modifying information.

I rarely have more than 2 or 3 global variables...and often just one: The GameController. If I need a global I put it in the GameController...this way when referencing it, I know where it lives, and it's easy to convert access to the information to a proc if necessary.

Small games can survive with globals...but if your game has much code to it, it won't be long before you have no idea whether certain things being referenced are globals or class variables or locals, and you may not be sure whether it's okay to modify the variable.

If I need controls on modification, I add an underscore in front of the GameController variable (_turn_number), which lets me know it should never be accessed directly, and then create accessor functions for setting and getting the value.

I'm not pedantic about it...Birdland is a pretty small set of code, and I do fall to using actual globals more often out of quick convenience and desire to do less typing. But a game like Living & Dead is large, and I find if I don't follow policies like this religiously, there are 100+ globals floating around making things confusing.
In response to Deadron
I've got about 5 global variables in the game I'm working on now. Most of them are because the player does a whole lot of mob jumping and I need to keep track of what body their in, what body they were in, and what the original body at login was.

I'll be posting it in the hub soon (hopefully today), it's functional and doesn't have any bugs that I know of. I just need to add more spells, monsters, battles, ect. I suppose a story line could help too :p

Anyway, it's going to be called Shining and under strategy so check it out and tell me what you think of it so far if you get the chance.

By the way, I was kind of hesitant to read your savefile tutorial Deadron, but it wasn't nearly as hard as I thought it would be once I got the basic concepts down. Thanks for all the help, in that and on the boards, Newbies do appreciate it :p (that's to everyone, not just Deadron)
In response to English
English wrote:
I've got about 5 global variables in the game I'm working on now. Most of them are because the player does a whole lot of mob jumping and I need to keep track of what body their in, what body they were in, and what the original body at login was.

You might want to put these in the client...then they will stay with the player no matter what, and it will be easy to handle multiple players later if you want.
In response to Deadron
To tell you the truth I've ignored Client for the most part. I guess it's time I learned more about it because I know virtually nothing about how to use it. *Hit's F1*
In response to English
English wrote:
To tell you the truth I've ignored Client for the most part. I guess it's time I learned more about it because I know virtually nothing about how to use it. *Hit's F1*

It can be a little confusing at first, but it's reasonably simple:

The client is the player. The client/player can hook up to different mobs throughout the game, but the client is always associated with the player and that never changes.

So if you want vars/verbs to apply no matter which mob a player happens to be in, add them to the client.
In response to Deadron
That makes sense and will probably let me streamline the system for the multiplayer version. Thanks for the tip