ok, i need to make a door, that makes its own 7 diget ID, now heres the thing i want the door to know if another door in the whole world has the same ID if so it will randomate another and check again, anyways once it finds a ID that it will share with no other door, i want it to create a Key (door key) that will have the same ID as the door, thus being able to lock/unlock it, now every doors ID will be 0 and once the world starts any door with that 0 as its ID it will start its ID making.
The door will also carry the var Owner and if it does not have a Owner it will carry a verb, if the door is to a house it will say "Buy_House" to a shop it will be "Buy_Shop" to a mansion it will be "Buy_Mansion" and when someone clicks that i want it to check their gold and if its enough they get the Deed to the house and the doors Key.
Any Questions?
ID:164357
Jun 21 2007, 5:07 pm
|
|
Jun 21 2007, 6:29 pm
|
|
My question is... what is your question?
|
In response to Mikau
|
|
I was asking how would i go about doing it..
|
In response to VolksBlade
|
|
The only question you asked, was if we had any questions.
|
In response to Mikau
|
|
well i thought maybe you would see that this is the Dev-How-To and know that it was questions i was saying
|
In response to VolksBlade
|
|
ok, i need know how to make a door, that makes its own 7 diget ID, now heres the thing i want the door to know if another door in the whole world has the same ID if so it will randomate another and check again, anyways once it finds a ID that it will share with no other door, i want it to create a Key (door key) that will have the same ID as the door, thus being able to lock/unlock it, now every doors ID will be 0 and once the world starts any door with that 0 as its ID it will start its ID making.
The door will also carry the var Owner and if it does not have a Owner it will carry a verb, if the door is to a house it will say "Buy_House" to a shop it will be "Buy_Shop" to a mansion it will be "Buy_Mansion" and when someone clicks that i want it to check their gold and if its enough they get the Deed to the house and the doors Key. HOW would i go about doing that? that is my re-made version |
In response to VolksBlade
|
|
First, you'd scrap the whole "7-digit ID" crap. That's pointless. Give each door a unique tag (that's a built-in variable) starting at "Door_0" and going up to whatever. Then, give the keys a variable, which will be the same as the door that they'll unlock.
So, you'll need a global counter for the number of doors (this will need to be saved, by the way). In the New() proc for the door, if(!tag) (tag will be null by default), then tag = "Door_[doornum]". Then, increment global number of doors by 1. In turf/door/Enter(mob/M), loop through the keys in M's contents. If a key whose unlock variable (or whatever you call it) is equal to src.tag, then return 1 (or return ..(), if you wish to obey normal rules of entering turfs). Outside the for() loop, we can assume no keys were found (otherwise, the proc would've already returned), and we can give M an error message and return 0. As for buying doors (because we're not really buying a house, just the key to it), it's trivial. We can define a proc like this: turf/door/proc/Buy() Then, in turf/door/New(), you'll want to do verbs += /turf/door/proc/Buy(), provided it hasn't been bought yet. Notice that the Key in this instance is of type /obj/item/Key/Master. The Master subtype should work the same as a normal key, EXCEPT you'll be able to create copies, and if you fiddle around a bit, delete those copies as well. I'll show you how in a minute. One benefit of using tags instead of another variable is that you can use locate() to immediately find an object that has been tagged. So, for example, we can easily make a key teleport us to the door it unlocks: obj/item/Key/verb/teleport() Now, for Master keys. Creating a copy is simple: obj/item/Key/Master/verb/copy() Deleting copies is fairly difficult, however. Hopefully you'll put some effort into understanding this, because the line of reasoning behind it isn't exactly clear and mainly comes from experience. We'll also need to change copy() a bit from what I showed above (the indentation will also be different, because I'm opening up DM to write this one). var/list/KeysToDelete = list() //list of keys that should be deleted when they are created again That's not quite perfect, of course, but it should work. If you have any questions, feel free to ask. And if the question is "can you write that code for me?" the answer is no. I wrote that last big chunk because it was too complicated to describe (to a newbie, at least). The rest is stuff you should be able to figure out from my descriptions. |