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 Discussion / In game item Handling

Author
Message
Evad
23
Years of Service
User Offline
Joined: 7th Apr 2003
Location: United States
Posted: 7th Apr 2003 22:47
On an in-game menu system, what would be a good code to handle items picked up by the character, so they can be added to an inventory list? Would you have to create functions for each item? or just use them as strings?(Ex. Potion$, or Ether$) Any help would be apprechiated, thanks.

--Evad
Kentaree
23
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 7th Apr 2003 23:18
Use variables with values for each item. Give descriptive names, like potion, or ether, and then set the value to however much you have. i.e, if you have 0, they wont be displayed in the inventory, if the value is 2, you have 2 of them etc.

Whatever I did I didn't do it!
Evad
23
Years of Service
User Offline
Joined: 7th Apr 2003
Location: United States
Posted: 8th Apr 2003 00:20
Okay, now I know how to assign the number of them, thanks. Now for the next question, how would you assign what the item does?

Ex:

if potion$ "is used" (I know the code) then hp=hp + 200
print "", hp


-----

would that work?

--Evad

Evad
23
Years of Service
User Offline
Joined: 7th Apr 2003
Location: United States
Posted: 8th Apr 2003 00:28
Sorry, another Question....

would this be able to be done with a function for each item?

Ex.

potion(amount)
blah blah


or maybe an amount function, instead of using variables, if you used a variable you would have to create line of code for each item amount:

Ex.

if potion$=1
print "", potion$

DUH!!! never mind..I just answered my question

print "", potion$ will print the current amount of the string right?

andrew11
23
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 9th Apr 2003 05:15 Edited at: 9th Apr 2003 05:15
A string is a type of variable. You wouldn't say "Potion$ = 1" You could say "Potion$ = "1"" or "Potion = 1". They are incompatible data types.

I think the best way is to use arrays.

Like This:


All programmers are playwrights and all computers are lousy actors." -Anon.
<--- Uh... Um... Oh I forgot
Evad
23
Years of Service
User Offline
Joined: 7th Apr 2003
Location: United States
Posted: 9th Apr 2003 19:26
Okay, that is a good idea, I will use it thanks, I have one more question now...how would you make the item "usable" in game...what I mean is...if you are "here" and returnkey = 1 then items stuff goes here.

How would you declare where "here" is?

Login to post a reply

Server time is: 2026-06-11 15:09:26
Your offset time is: 2026-06-11 15:09:26