ID:142338
 
Here it is... ammong those Original Rips (mainly DBZ Games) once you want to replace... lets say a GH owner you have to goto the source, change the name, wait for the host to be online (you can skip this step), upload the source and send it to the host...

Allow me to introduce to you my new system:

turf/var
hideout="Available"
mob/var
organization.name=""
exitpoint
it=0
turf/guild
exit
icon='turfs.dmi'
icon_state="hideout"
name="Organization Hideout"
Enter()
usr.loc=usr.exitpoint
switch(alert("Do you want to turn your IT on ?","Hideout","Yes","No"))
if("Yes")
usr.it=0
if("No")
usr.it=1
hideout
icon='turfs.dmi'
icon_state="hideout"
name="Hideout"
Enter()
if(usr.organization_name==src.hideout)
usr<<"Welcome to [src.hideout] hideout"
usr.exitpoint=usr.loc
usr.it=1
sleep(5)
usr.loc=locate(90,43,94)
else
usr<<"You can't enter this hideout"
Click()
if(usr.organization_name=="")
usr<<"You don't have a organization"
else
if(src.hideout=="Available")
switch(alert("Would you like to buy this hideout to your organization?","Hideout","Yes","No"))
if("Yes")
switch(alert("Well it costs about 100000000 Ryou, you want it ?","Hideout","Yes","No"))
if("Yes")
if(usr.Ryou>=100000000)
usr.Ryou-=100000000
src.hideout=usr.organization_name
sleep(10)
usr<<"You can now enter your organization hideout"
else
usr<<"You don't have enough money"
else
return
else
return
else
alert("This hideout belongs to [src.hideout] ")


As you can see... GM's with the edit verb can edit the Hideout var to give new owners to the GH, and players can buy them freely, isntead of constantly asking a GM to give them access to it...Anyways GM's are allways in control of the situation.

Tell me what you think...
Cybork
This code is bad. Not only is it needlessly long, ugly, and complicated, but it also has rampant usr abuse. This can be written to much, much shorter and handled much, much better.
In response to Popisfizzy
It has so many vars because I used it on my Naruto game and I've made no modifications.

If I used src instead of usr it would change the turf's vars...

I know it has a bad look, but it is simple and it works...
In response to Cybork
It works until an NPC goes to enter, and it only barely works. There are much, much better ways to handle it. It becomes much better if you include a map loading program, meaning the map can be changed at runtime to create a new guildhouse. An guildmaster could, in-game, move around and create the entire guildhouse, which would be saved upon the game shutting down. For example, if you were to use my map-loading library, I would do it like this:
guild
var
//This is the name of the guild.
name

list
//This stores the members of the guild. This is an
//associated list, and the associated value is a
//number, corresponding to an index in the ranks
//list.

members[0]
//These are the ranks.
ranks = list("Member", "Guild Admin", "Leader")

New(_name) name = _name

proc
//This is where you'd add handling for the ranks and
//members.
AddMember(mob/m, rank)
RemoveMember(mob/m)

//...

//Checks to see if m is a member of the guild.
IsMember(mob/m) return (m in members)

guildhouse
var
//The guild that the guildhouse belongs too.
guild/guild

//The /dynamic_map object handling the saving and loading
//of the guildhouse.
dynamic_map/map

turf
//These are the tags for the entrance and exit
//objects.
entrance_tag
exit_tag

New(guild/g, en_tag, ex_tag)
//This sets the guild.
guild = g

//These set the tags for the entrance and exit turfs.
entrance_tag = en_tag
exit_tag = ex_tag

proc
//Sets the tags of the turfs which act as the entrance
//and exit.
SetEntrance(turf/t)
var/turf/guild_entrance/g = new(t)
g.guildhouse = src
g.move_tag = entrance_tag
SetExit(turf/t) t.move_tag = exit_tag

//Outputs the name of the guildhouse.
Output() return "[guild.name]'s Guildhouse"

//This checks to see if a mob is a member of the guild.
IsMember(mob/m) return guild.IsMember(m)

Entered(mob/m)
//Define stuff here for when a mob has
//entered their guildhouse.

turf
//This is the tag the entering mob will be
//relocated to.
var/move_tag
Entered(mob/m)
//Searched for an atom with the move_tag,
//assuming move_tag is true.
var/atom/a = move_tag && locate(move_tag)
if(a)
//If an atom is found, move the mob
//there.
m.loc = a

guild_entrance
//This is the guildhouse the turf is dealing
//with.
var/guildhouse/guildhouse
Enter(mob/m)
if(guilhouse.IsMember(m))
//If they are a member of the
//guild, let them in.
return ..()

//If not, tell them they can't enter.
world << "You can not enter [guildhouse.Output()]."
return 0

Entered(mob/m)
//Do all the normal stuff...
..()

//...then perform the special stuff that
//happens when the mob has entered their
//guildhouse.
guildhouse.Entered(m)
In response to Popisfizzy
NPC's cant enter it...
I wrote something like this:

if(usr.organization.name==src.hideout)
blah blah blah

And NPC's can't have the same organization names... and mine is pretty basic XP

Cybork
In response to Cybork
An NPC can still make an attempt to enter the turf, at which point you'll get a runtime error saying something about null.organization.
In response to Popisfizzy
Soo ? My proc works and its a basic one... Yours is good too but I think mine is more simpe for newbs.
In response to Cybork
The Correct response is that his works and yours doesn't...
In response to Popisfizzy
Popisfizzy wrote:
An NPC can still make an attempt to enter the turf, at which point you'll get a runtime error saying something about null.organization.

no
maybe an undefined variable error depending on what entered it, but it wouldnt be null

This code is bad. Not only is it needlessly long, ugly, and complicated, but it also has rampant usr abuse. This can be written to much, much shorter and handled much, much better.

You talk about needlessly long, ugly, and complicated coding and then you post that example you did?
All the comments make yours like 3 times as long as his.
Ugly? It looks like you attempted to write it in the post instead of in maker.
Complications? First off there are spelling errors in yours (which just furthers the thought that you wrote it in the post).
Pointlessly referenced calls to pointless procs that are completely unecessary (like an IsMember proc in the guildhouse and in the guild).
Plus there are logic/design errors (The use of move_tag pretty much everywhere you used it and outputting messages to the world instead of the player).
In general your system is overly complex and has far too many variables/datums which pointlessly reference eachother
And at least his was fluently readable, had to constantly hop around in the code to figure out wtf yours was trying to do
In response to Falacy
Falacy wrote:
no
maybe an undefined variable error depending on what entered it, but it wouldnt be null

Sure. Additionally, since usr is used, you could also end up having NPCs authorized to enter.

This code is bad. Not only is it needlessly long, ugly, and complicated, but it also has rampant usr abuse. This can be written to much, much shorter and handled much, much better.

You talk about needlessly long, ugly, and complicated coding and then you post that example you did?

Pop's code does a lot more things than the OP's code. For example it also includes implementation of guilds themselves. Also, it is not much longer than the OP's code, but that is irrelevant. It's okay if the code is a little long, that's not important as long as it works properly. The OP's code, was, however, much uglier, needlessly long (it has many things that are unneeded, as you can see Pop's code is longer and doesn't have those), and very, very badly done and broken, no offense intended but it is definitely not suitable for public publishing. Especially not for newbies to learn from, they've got enough bad practices as it is.

All the comments make yours like 3 times as long as his.

Oh boo hoo. Actually, it is better than being completely uncommented, and comments don't even count as code, either.

Ugly? It looks like you attempted to write it in the post instead of in maker.

Really? I don't see anything that suggests something like that. Of course, there is nothing wrong with writing code in posts, either, so you are just being silly. Competent programmers don't have to have the compiler's syntax highlighting and all that to produce good code. I make all of the code I post on the forums in the post itself; opening Dream Maker, doing it there and copying to the post is an unneeded sequence of actions.

Complications? First off there are spelling errors in yours (which just furthers the thought that you wrote it in the post).

Again, you are exaggerating the trivial. I didn't see any spelling errors in my skim of it, but such things have nothing to do with code complications. Nitpicking much? Jealous, perhaps?

Pointlessly referenced calls to pointless procs that are completely unecessary (like an IsMember proc in the guildhouse and in the guild).

Those kind of procs may indeed initially be observed pointless, however they're included in libraries and the like for convenience and ease of use purposes. Also, they can be overridden to add new custom behavior if wanted, or whatnot. And if you don't need that, then you don't need to use those procs.

Plus there are logic/design errors (The use of move_tag pretty much everywhere you used it and outputting messages to the world instead of the player).

Again you're exaggerating one mistake into multiple. Accusing Pop's code of being badly designed while simultaneously defending the OP's code is ignorant and hypocritical almost beyond belief.

And at least his was fluently readable, had to constantly hop around in the code to figure out wtf yours was trying to do

If you had trouble understanding his code it doesn't necessarily mean there was anything wrong with it. In fact, it likely pertains to suggesting the opposite; from your post here among others, it seems you cannot stand correctly made and designed code. But that's not our problem, so the pointless spasm was uncalled for.
In response to Falacy
Falacy wrote:
You talk about needlessly long, ugly, and complicated coding and then you post that example you did?
All the comments make yours like 3 times as long as his.

Lots of comments is a good thing, Falacy.
In response to Cybork
Cybork wrote:
I know it has a bad look, but it is simple and it works...

It may work for your game, since your game doesn't create any situations that would cause your code to bug up, but that doesn't make it suitable for the general public to use. Just because something works in your game doesn't mean it will work everywhere else.

If you don't know how to make your code suitable for general use, or you're still being plagued by programming problems that are common among newer users, then you really shouldn't try to release your code here.
In response to Falacy
Actually, I wrote it in Notepad and then added a few more things inside the post, which accounts for a few cases of mangled whitespace. Of course, code isn't supposed to be copied from the forums in any case, so this is entirely a non-issue. As well, there may be a few spelling errors but, once again, code shouldn't be copied and pasted, and spelling errors that cause problems should come out easily when typed again.

Also, you think I make too many "needless" proc calls? Perhaps you should learn a few basics of modular design, as well as why it's a good thing.

[Edit]
Also, his was hardly fluently readable. Extremely nested statements made it damned hard to read through without struggling, which isn't helped by me getting easily frustrated when looking through bad code.
In response to Cybork
Yours is good too but I think mine is more simpe for newbs.

I'm sorry for driving this a little off-topic, but I'd like to express my annoyance to people who think code is written for newbies. It might be a little shocking, but code is not written for newbies, and it shouldn't be. Okay?

Edit: Uh, please don't take this personally. I just feel it should be said.
In response to DivineO'peanut
DivineO'peanut wrote:
It might be a little shocking, but code is not written for newbies, and it shouldn't be. Okay?

On the Developer How-To and Code Problems, it should be, though, unless the OP is clearly not a newbie, which is pretty seldom.
In response to Kaioken
No.
In response to DivineO'peanut
If you're writing complexified, overly compactified code that is too difficultified (ok, ok... difficult) to understand, I'm afraid it's quite useless and you might as well not include any code in your post instead. Often alike posts that contain code only with no comments.
But yeah, guess it's very off topic here, meh.
In response to Kaioken
But there's a different between code that is written for newbies and code that is easy to understand. I have nothing against the latter; it should be encouraged.

Also: what's wrong with including complicated code in your posts?
In response to Foomer
I use BYOND since 2005 therefore I don't really consider me a new user.
This engine was not for public to use, simply to let them know that basicly they could use a turf var to edit Guild Houses owners instead of going to the source...
I did this to help people not to start wars...
In response to Kaioken
Why are you calling me OP ? What does that mean ?
Page: 1 2