ID:137079
 
I know you two are trying to get this thing out of beta and into the proper numbers (watch out, you might have beta 307 before long), I'd like to make a request for a proc that I'd find particularly useful.

I'd like to have a Hosted() proc that gets called whenever a user successfully changes the game through the host button. That way, I could easily add and remove options dependant on whether or not the program is running online.

If that's not too much trouble.
Awakening wrote:

I'd like to have a Hosted() proc that gets called whenever a user successfully changes the game through the host button. That way, I could easily add and remove options dependant on whether or not the program is running online.

You can use world.port to determine if the world is being hosted or not. Is that good enough?
In response to Tom (#1)
world.port will tell if the program is hosted or not, but how does the game know when to check world.port? A Hosted() proc that's only run when the world.port changes through the host button would allow a place to check what the current world.port is.
In response to Awakening (#2)
Awakening wrote:
world.port will tell if the program is hosted or not, but how does the game know when to check world.port? A Hosted() proc that's only run when the world.port changes through the host button would allow a place to check what the current world.port is.

Oh, I see what you mean. Good point. There are a couple of other places where we should probably provide hooks to user procs, like "Logout" and "Quit" (when the user manually activates these options). Maybe we ought to have one fixed routine that receives all of these user-determined messages.

Well, in the meantime, you can always workaround this with a low-frequency timer, such as:
world/New()
var/oldport = port
for()
if(port!=oldport)
oldport = port
PortChanged() // your proc
sleep 10

It sounds horribly inefficient, and it is admittedly silly, but it shouldn't have any impact on your game ticking away every second like this.
In response to Tom (#3)
sleep 10

No parentheses? You monster! ;-)

(Kinda funny -- I've adopted a no-parenthesis style in C++, but in BYOND if I don't see parentheses I get a little peeved now. In the past I was never decided on which to use, which probably caused a few discrepancies...)
In response to Tom (#3)
Hey!

I asked a while ago for a client.Host() proc that would be called when someone tries to host, and would let us return 1 or 0 based on whether we wanted to allow it, and put all sorts of other code in there too.

Z, back from PA
In response to Zilal (#5)
Parenthesis are a must! Darn you rebels and your no parenthesis!

Actually, I asked this same question several months ago when I was making the single player version of Shining. I wanted to prevent people from trying to host it. Eventually I settled on this:

client
New()
if(world.port)
world << "***Single Player Only, no hosting allowed***"
del(src)

A Hosted() proc would definetely be useful once the current version of byond gets stabilized :)