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.

Newcomers DBPro Corner / Checking for specific data in an array.

Author
Message
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 22nd Jan 2003 14:02
OK, well Im coding the menu system for Eternal Destiny, and its coming along fine. I have it so it will read the item, and if you do want to use the item, then it will have the desired effects on the character.

As you would probably imagine I am using FLAGS for the item slots, eg
Dim Itemflags(20)

And if an item is in the first slot then

itemflags(1)=1

Now, how can I read through the array, until I find the quickest place that an itemflags() is equal to 0? I do not want to code the whole thing by hand because I know there is a way to do this. Help please!!!

One other thing- when I find which slot is open, how can I assign each slot a different SET CURSOR value. Eg

If itemflags(2)=0 then set cursor slot2 : print "potion"

How would I assign words to SET CURSOR (yea I know, that did sound noobish didnt it )

My brains sorta been in weird mode for a while so dont mind if these are really, really noobish questions

Thanks in advance-
RPGamer
Current - RPG: Eternal Destiny : Help Wanted!
http://www.halbrosproductions.netfirms.com
Dont ask those questions! Read the help files lazy!
jasuk70
21
Years of Service
User Offline
Joined: 3rd Dec 2002
Location: Hemel Hempstead
Posted: 22nd Jan 2003 14:12
The words bit should be simple

#CONSTANT Slot2 100,100

SET CURSOR Slot2
PRINT "Blah"
WAIT KEY

Not too sure about the finding in an array, i coded one myself for a similar thing by doing a for next loop. inside a function.

Jas
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 22nd Jan 2003 15:24
Try something like this (untested!)

John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 22nd Jan 2003 22:29
Ian: Worked- thx Dunno why I couldnt figure that out!! I was trying to get it = to 1, where I could have just said > 0 Thanks!!

Jasuk:
Nope- Doesnt work. Do you have reg or pro? I have regular DB v 1.13.

Ah oh well might as well just use set cursor, or just make function for each slot. Anyone have a good idea on how to do this?

RPGamer

Current - RPG: Eternal Destiny : Help Wanted!
http://www.halbrosproductions.netfirms.com
Dont ask those questions! Read the help files lazy!
Hamish McHaggis
21
Years of Service
User Offline
Joined: 13th Dec 2002
Location: Modgnik Detinu
Posted: 22nd Jan 2003 23:22
I dunno exacteley what you mean. Do you mean you want to find a way to give each slot coordinates quickly without having to code each one out like...

if slotflag(1)=1 then set cursor coord1,coord2:print "potion"
if slotflag(1)=1 then set cursor coord1,coord2:print "potion"
...

you could just use a for-next loop and assign an array with the coordinates of the slots. ie..



Yum! Yum! Yum! Yum!
The Darthster
22
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 22nd Jan 2003 23:41
Do you want to put the items in a list without spaces in between?



Makes a list of items you have, text spaced every 20 pixels down from 20. You need an array itemname$(20) which holds the name of each item. The stuff in curly brackets {} is optional.
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 23rd Jan 2003 00:58
OK- heres what I am trying to do. I got the whole slot thing down, but for the spacing...

You check to find an open slot first, and when you find one, Id like it to be like this....

set cursor (whatever open slot is)
print "the item"

Ill try that code.......

RPGamer

Current - RPG: Eternal Destiny : Help Wanted!
http://www.halbrosproductions.netfirms.com
Dont ask those questions! Read the help files lazy!
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 23rd Jan 2003 01:24
Cant get it working :*(

RPGamer

Current - RPG: Eternal Destiny : Help Wanted!
http://www.halbrosproductions.netfirms.com
Dont ask those questions! Read the help files lazy!
Hamish McHaggis
21
Years of Service
User Offline
Joined: 13th Dec 2002
Location: Modgnik Detinu
Posted: 23rd Jan 2003 17:34
Just use a for-next loop to assign the coordinates of the slots to an array, like I did. Then if you detect that one is open then set the cursor to the slot's array values. Maybe you want to use the text command rather than the print command as that is better for graphical menus

text coord_x,coord_y,string$

Yum! Yum! Yum! Yum!
The Darthster
22
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 23rd Jan 2003 19:16
You want the items to be in set spaces in the inventory? In my code just replace k*20 with i*20 and get rid of k=k+1.

To use my code you need to remove the curly brackets and one of the sets of commands within them, I just showed you both methods of outputting the text. Also get rid of the 'OR'.

Login to post a reply

Server time is: 2024-11-23 23:07:32
Your offset time is: 2024-11-23 23:07:32