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.

Author
Message
Flamertor
14
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 16th Feb 2014 15:15
I'm making an inventory system for my MMORPG 'The Scrolls of Eithador The Great War'. The way I am doing this is by having an array with the Object ID and the amount of that object you have of that type. The Object ID is 12 digits long. The problem I'm having is that it changes number when it is in the array

Code to put it in the array:



Results:

Actual ID : 10103001010

Returned : 1513066418

Ways Tried:

- Changing to String (Uses more memory and doesn't work well)
- Real Number (doesn't go into the array)

Thanks for the help in advance
Kevin Picone
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 16th Feb 2014 15:35
Seems like it'd overflow a 32bit integer.




Flamertor
14
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 16th Feb 2014 15:54
Hi Kevin,

Thanks for the quick response, would this fix the problems I'm having with very little problems or issues?
MonoCoder
20
Years of Service
User Offline
Joined: 4th Dec 2005
Location: england
Posted: 16th Feb 2014 16:18
You'll need to use strings for numbers that big, or smaller numbers. You might also be able to use double integers, but my understanding is that they're buggy, or poorly supported or somesuch. Could you say why the numbers have to be that big?
Flamertor
14
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 16th Feb 2014 16:28
The way I have structured the object code is like so

1st Keep Zero
2nd Material
3rd Material
4th Type
5th Type
6th Name
7th Name
8th Name
9th Weight
10th Weight
11th Weight (Decimal)

I am also thinking of adding another six digits or so to allow for the player ID to be held as well.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Feb 2014 17:59
Sounds like you should be using a string or a UDT. What's wrong with using a UDT for this? It seems to be the obvious solution for this sort of thing. You wouldn't need any awkward conversions between types then.



Powered by Free Banners
Flamertor
14
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 16th Feb 2014 18:08
what's a UDT?
ShellfishGames
13
Years of Service
User Offline
Joined: 6th Feb 2013
Location:
Posted: 16th Feb 2014 18:55
A user defined type, something like this:



Flamertor
14
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 16th Feb 2014 20:56
So how do they work exactly?
ShellfishGames
13
Years of Service
User Offline
Joined: 6th Feb 2013
Location:
Posted: 16th Feb 2014 21:57
Well basically you create your own more complex "data types" and assign them to variables (or arrays).
You can define a type using this notation:



You can then create a variable of that new type using "<variablename> as <typename>", and access as well as change each of the type variables using "<variablename>.<typevariable>".

So I assume in your case, instead of having an incredibly huge array of 10^12 elements (which you would need if your 12 digit object ID is used as index for the array), you'd have an array containing just the actually existing objects, and this array would be of a newly defined UDT containing the values you originally wanted to encode within the object ID.

zeroSlave
17
Years of Service
User Offline
Joined: 13th Jun 2009
Location: Springfield
Posted: 17th Feb 2014 01:02
Below is how you would set up and use types using your above information for the equipment values:



Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid.
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 17th Feb 2014 04:19
You can read my response in this thread to learn a little something about UDTs and using them with arrays.
http://forum.thegamecreators.com/?m=forum_view&t=209728&b=1

Flamertor
14
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 17th Feb 2014 11:10 Edited at: 17th Feb 2014 12:26
Okay thank you very much I can see how I can use the case command now.

Sorry I'm a bit confused, this is what I got currently

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 18th Feb 2014 03:31 Edited at: 18th Feb 2014 03:33
Without knowing exactly what you're trying to do with each object's properties, I can only take a guess on structure here. But here's an example using UDT's, arrays, and selecting different actions based on the item's properties.




Also, not sure if this is what you're going for, but here's an example of doing a Diablo-style inventory system, from a graphical standpoint anyway.
http://forum.thegamecreators.com/?m=forum_view&t=187859&b=6

Flamertor
14
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 20th Feb 2014 00:00
Thank you very much, I can see this being a better way which will allow me to have in the object ID other variables such as different designs an item or customization.

Thank you!

Login to post a reply

Server time is: 2026-07-07 01:54:32
Your offset time is: 2026-07-07 01:54:32