Hello all,
I'm making a survival multiplayer (No, I'm not makng a knock-off, this one is completely original) and I was wondering how you would go about:
a: Making an inventory
b: Setting a weight limit a person can carry
c: Talking to someone they can see on the screen, but not
the entire world.
For a, I'm just unsure about how to go about it.
For b, I'm thinking I just want to give everything a weight value and add/sub from it as things move in and out of the inventory.
For c, I know you can talk in an area, but I'm not sure how to code it.
Thanks in advance,
Naughtilus
ID:154989
Oct 18 2011, 3:49 pm
|
|
Your contents is automatically your "inventory"
For a weight limit, do a check before picking something up to see if it's too heavy to go into the pack. To chat to world, send the output to view instead of world. |
Naughtilus wrote:
Hello all, Good Day Sir. I'm making a survival multiplayer (No, I'm not makng a knock-off, this one is completely original) and I was wondering how you would go about: The most common way to do this is to place items in a list. I prefer referencing a custom list rather than the default "contents" list given to each ATOM. I'm not sure why I do this, it just flows better for me. As for presentation, you can use the input() proc, Stat Panels, or even create your own Grid UI for it. I suggest the latter-most option as it give you the most creativity in design, and it looks much more professional. Take a look at the "Lists" section of the guide on how to set up a list. b: Setting a weight limit a person can carry Do that exactly. That's the optimal way of handling it. c: Talking to someone they can see on the screen, but not the entire world. Take a look at the guide. I believe it is within the beginning pages, it should explain view() and the output operator (<<). |
In response to Lugia319
|
|
This isn't good thinking, don't think, 'I MUST USE CONTENTS', because that's just silly wrong. Programming's all about doing it your own way, for example:
mob/var/list/Inventory = list() I'll leave you to add in the weight differences in the movement, and I must stress that this is just ONE way of doing it (And personally I wouldn't use this system). Vary it a little, and get what works for you. |
In response to El Wookie
|
|
No, you don't have to use contents, but there's no real reason not to. Sure, I could do it whatever way I want. I could code all of my stats to have max/min variables
mob Doesn't mean that I should though, when an easier way is available. Yeah, it gets the job done, but there's overhead that I might confuse myself with later. |
In response to Lugia319
|
|
It mostly depends what you want to do. For example (with your HP / stat scenario), I did cover a datum-based approach:
http://www.byond.com/members/ BYONDAnime?command=view_post&post=98823 The notion was simple, if you required that kind of functionality, do it once, and avoid the margin for confusion, by using a datum that "just works" and only needs adjusting when it's wrong (which as it's used frequently and thus hopefully debugged / proven, is not very often). The question is, with contents vs some other method, or raw HP stats vs datum-based control: "Does this fit my game's needs?". Contents is very well suited to "magic bag" inventories. Pop an item in the magic bag, fetch it out later. Rummage through the magic bag to see what's in there. Essentially, it's just a list with a few programming extras to it. For some games, this works great. For others, perhaps with a more complex slot / size system (a la Deus Ex for instance), contents isn't really suitable. It has no sense of stacking, available / spare space, awkwardly sized objects etc etc. Clearly another solution would be required. ---------- The OP of course was pleasantly vague, which is okay. Your proposed solution is quite fine, given what the OP has decided to share with us. And ... I went off on one, good job, me. |
Well, that was fast.
Thanks for all of the responses! Let's see if I can hit everyone's advice... FreeVagabon wrote: idk about the others but c could be Ah, I thought it was going to be a massive hassle to code that one. Now that I think about it, that should work. Lugia319 wrote: Your contents is automatically your "inventory" I saw the "contents" thing in the guide, but I wasn't sure that it was what I was looking for. The weight limit, it seems to me, is a unanimous "Just give the guy a weight var!" I think I'll do that. Back to the lists thing though... I'm thinking about a combination (maybe) of this: Solomn Architect wrote: The most common way to do this is to place items in a list. I prefer referencing a custom list rather than the default "contents" list given to each ATOM. I'm not sure why I do this, it just flows better for me. As for presentation, you can use the input() proc, Stat Panels, or even create your own Grid UI for it. I suggest the latter-most option as it give you the most creativity in design, and it looks much more professional. Take a look at the "Lists" section of the guide on how to set up a list. And: Stephen001 wrote: For others, perhaps with a more complex slot / size system (a la Deus Ex for instance), contents isn't really suitable. It has no sense of stacking, available / spare space, awkwardly sized objects etc etc. Clearly another solution would be required. This definitely seems like the best idea. However, I'm not going for something like "Move everything around in your inventory just to get this one thing to fit", it's more like "Stuff everything in your backpack, but it just needs to stay in and be light enough to carry." So what I'm thinking is: a & b: Make a weight and capacity variable, and use a list for the items themselves. c: Use FreeVagabon's suggestion. c should be easy now, and a & b as well; thanks! However, one more thing: If I did want to do my idea, but still have something graphic, could I list how many of an object I have next to the icon for it on a box on the screen? At the moment, I'm just looking for a Y/N answer for this, and if it IS possible, I'll look into adding it later. Example: [rock icon] Rock (x5, 1.25 lbs/ea, 5 cubic in ea.) [stick icon] Stick (x10, 0.25 lbs/ea, 2 cubic in ea.) Weight: 8.75/50 lbs. Capacity: 45/3456 cubic in. (Note for capacity: 1 cubic ft = 1728 cubic in. So your backpack is actually only 2 cubic ft.) Thanks for the help so far, and I'll keep you posted on how I'm doing! Naughtilus |
In response to Naughtilus
|
|
It's absolutely possible. All you would need is a stack variable to count the amount, and from there you can compress the items into one stack.
|
In response to Solomn Architect
|
|
Okay, thanks!
|
idk about the others but c could be
mob/verb/Say_to_View(t as text)
view()<<"[usr.name]: [t]"
this allows you to text people who are seen in your screen and not the world.