Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Item Menu For RPG.. (Stacking,Queues,Lists,Sorting) Help

Author
Message
The Lone Programmer
23
Years of Service
User Offline
Joined: 29th Jan 2003
Location: California, USA
Posted: 30th Oct 2003 08:07
Ok,
I have decided I wanted to figure out how to use the Stack Commands for my menu. I am told that is what I should use if I have PRO.

Well not sure what I am doing. I thought that its pile ups of stuff. I dont know. Ok I made this very quick very simple Item menu. Well maybe not very simple but its simple enough. If you were a newb I am sure you can understand. Well the items in my menu dont sort themselves.

I got the 4 items.. They go to specific spots.. I want them to go to the empty spot nearest to the top. Well I have code for that with functions but that doesnt work for me...

Here is my code..


Well any advice on getting it to sort itself. Well since people never know what I am talking about here are good examples..

This is the order it comes in every time all the time.
Potion
Super Potion
Healing Water
Max Heal

What if I got
Empty
Super Potion
Healing Water

Well I want either potion or Max heal to end up in that empty spot.. Depending on what I add next. Or better yet I want all the items to move up a row to fill the empty.

Thanks
Nicolas

*Current Project: Untitled RPG
*Working With: Vash the Stampede 815
*Future Number: Eleventy
The Lone Programmer
23
Years of Service
User Offline
Joined: 29th Jan 2003
Location: California, USA
Posted: 31st Oct 2003 01:21
Any one know????

I feel like no one has ever made a form of RPG/Adventure game... Most of who I ask are clueless to my question.

please help if you can

Thanks
Nicolas

*Current Project: Untitled RPG
*Working With: Vash the Stampede 815
*http://www.blazing-fire.tk
Veneticus
23
Years of Service
User Offline
Joined: 29th Jan 2003
Location:
Posted: 31st Oct 2003 04:07 Edited at: 31st Oct 2003 04:08
Well, a few things:

1) You are combining the items with the inventory - you've hardcoded array item 4 as a certain type of item, as well as slot 4 in your inventory - you need to break them out into 2 separate arrays.

2) Stacks and Queues are used when you need access to only 1 item (whatever's on to), not when you need to see the whole array. Your example is not a good situation to use stacks.

3) You should be using a list for your inventory. Unfortunately, DBPro does some funky things with lists (try adding 10 items to a list, then deleting the 3rd item, and watch what it does to the remaining 6 items).

4) Since your inventory has a set amount (10 slots), just use a normal array, and keep track of positions yourself.

5) Here's some code to show you what I mean. It will add up to 20 of each type of item to a slot on your inventory. It doesn't automatically consolidate slots if the count goes less than 20, but that's an easy enough fix if you need it. (click on the source button below).
The Lone Programmer
23
Years of Service
User Offline
Joined: 29th Jan 2003
Location: California, USA
Posted: 1st Nov 2003 02:24
Are functions the only way to do this kind of thing??

I really like the menu deal that you made but I think functions are evil. I dont understand them and when I try to use them with similar functions everything becomes bad..
I really like if/thens and ifs. I also really like gotos/gosubs. I want to try to do this menu but with these kind of commands.

Unless I absolutely have to use functions then I would rather not.
In the sample you made me.. I couldnt seem to be able to increase the amount of slots it had. When I got it, it didnt tie up and everything was printed strangely (Lots of numbers everywhere).


Well thanks for the help.
Nicolas

*Current Project: Untitled RPG
*Working With: Vash the Stampede 815
*http://www.blazing-fire.tk
indi
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 1st Nov 2003 04:55
you shouldnt think of functions being a bad thing.
they allow you to reuse code in the long run..

think of your magic items and standard items being the same creature just that magic items have higher stats and normal items dont have any special stat bonuses in the fields for say magic resitance etc...


learn to make a type and even better a typed array.

Your going to have a whole bunch of poo if you try to skip these commands, Ive been tinkering with a 3d rpg for a while and had to face these issues.

Imagine being able to manage your items with a dot syntax.


As an example your code will look similar to this.



Broadsword(1).name$ : rem the name the player sees it as
Broadsword(1).filename$
Broadsword(1).itemlocation
Broadsword(1).tohit
Broadsword(1).damage
Broadsword(1).cost
Broadsword(1).MagicResistance

Normal items would have zeros in any magical property box but could be made magical later on.

This way your not recreating more code to manage the normals and magicals in one foul swoop.


Just keep in mind that normal and magical items can be grouped as the same creature because magic items are just souped up items in essence.


this way its a lot clearer in your mind and to code a whole bunch of items for use in your game.

Learn how to make a type with an array and learn how to use functions or be prepared to face a lot more hassles and a lot more code, Im not talking about a few extra lines, Im talking hundreds of lines just to achieve the same result.


Seriously dont even try to embark on your equipment system until you have mastered functions and typed arrays. Ive been there and it was hell, typed arrays can also be deployed for monsters and npcs and events and all sorts of yummy stuff that requires multiple instances of the same thing but with different properties.

have fun..
The Lone Programmer
23
Years of Service
User Offline
Joined: 29th Jan 2003
Location: California, USA
Posted: 1st Nov 2003 05:39
I know how to use types... I am having no troubles with them..

Functions are driving me crazy. It seems like when I try to clash some of them together I get my whole code all screwed up.

Like say I have a function that makes healing items on a page sort out so when a potion or something runs out then they move up.
Say I have another page with weapons. But with the same function or slightly different one. Both pages end up being the same. Or when I have a reset function that clears them, the previous healing menu stays a weapon menu.

That was my main bad experience. I will try to learn some functions, but can someone help me out. When you hate something, its hard to go to liking it alone.

Maybe someone want to be my private tutor, Indi do you have MSN?

Well, Thanks
Nicolas

*Current Project: Untitled RPG
*Working With: Vash the Stampede 815
*http://www.blazing-fire.tk
indi
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 8th Nov 2003 03:46
Im out of order until the 20th Nov, I dont usually tutor people but ill try to answer questions if you show your learning new things etc. and get stuck on stuff that ive already worked on.

Login to post a reply

Server time is: 2026-07-26 17:37:02
Your offset time is: 2026-07-26 17:37:02