ID:164148
![]() Jul 14 2007, 8:58 am
|
|
I want to know how to set up a good equip system, where if the helmet spot was open, the player could click on it and it takes the spot, but if it isn't it would provide a message to the player. So how do I make this work?
|
You should really look up on how to use boolean.. that way, you can set the variables to the object itself and say thing like "[Head.name] is already equipped!"
I made an equipment demo a while ago but it could be greatly improved. ID:556577 |
Siientxx wrote:
mob/var //list of mob varibles There's really no way to sugarcoat this: That's truly horrible code. It's not merely one of the many wrong ways to do equipment; it's one of the wrongest. The standard wrong way to do equipment is to give each obj a var that says it's equipped or not. Then at least you can go through your objects to tell which ones are equipped. Having to do that loop process is why this method is wrong. What makes your method even wronger is that the mob knows something is equipped, but it has no way at all to tell what is equipped. The correct way to do equipment is to keep vars or a list with the mob, but instead of using 1 and 0, point to the actual object itself. mob/var When equipping a weapon, you'd set mob.weapon=item. To unequip it, you'd set mob.weapon=null. if(mob.weapon) tells you if a weapon in use. There are other good ways to handle equipment, but they all keep the information with the mob, and they all involve using references to the equipped objects themselves. Other problems in your code:
|
Siientxx wrote:
Yeah my last time coding was a year or two ago, so it might be amateur and outdated. =P |
What I mean it is like an inventory system but like:
Helm: (image and name) Body: (image and name) Legs: (image and name) so forth...... Silent made it sound really good, but I need to figure out how to do what I want it to do. |
DadGun wrote:
What I mean it is like an inventory system but like: You can't make such use out of Siientxx's code, because it blows. It will not help you. There are some actual good demos for equipment systems online. Check out the one by Wizkidd0123. Lummox JR |
Siientxx wrote:
Siientxx wrote: Amateur and outdated would be bad, but far better than sloppy and wrong. To say your code was outdated would be to suggest that approach was ever a good idea. I can see easily forgetting syntax, but design flaws are easy to recognize. Lummox JR |
These are examples. Switch them over to procs, and you could do this with the slots (Which are objects in a statpanel or an overlay on someone's screen) this is an example:
Then you could add in input boxes to allow them to select what object to equip to the head part. Add a var to object called type and set all helmets and whatnot to "helmet", run an if conditional and see if the object they want to equip is an object that can be equiped to the head, then equip it.
I would recommend when you click the head slot with an item equipped you ask for confirmation to see if the user really wants to remove the item. Much like so:
Have fun,
Siientx