Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (TipmyPip, 1 invisible), 18,758 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
array[n].property? Is this possible? #116545
03/11/07 09:49
03/11/07 09:49
Joined: Jan 2007
Posts: 36
Montana
webgovernor Offline OP
Newbie
webgovernor  Offline OP
Newbie

Joined: Jan 2007
Posts: 36
Montana
Hi All,

After searching the forums for quite awhile, and completing the C-script workshop, I am unable to figure this out:

array[n].property = "some_value";

Is this possible? A multi-value array/hash object?

Here's an example:

inventory_slot[1].item = "Bug Juice";
inventory_slot[1].value = 225;
inventory_slot[1].quantity = 6;
inventory_slot[2].name = "Soiled Diaper";
inventory_slot[2].value = 9785;
...etc

I here's code that doesn't return errors, but is unusable:

var inv_slot[4];
inv_slot[0].name = "Sword";


I really appreciate any help or ideas on this.

Thank you all very much.

-Aaron

Re: array[n].property? Is this possible? [Re: webgovernor] #116546
03/11/07 09:58
03/11/07 09:58
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline
Serious User
Happy Birthday Scorpion  Offline
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
no, that is not possible so..but you can make an easy trick:
here if you have 3 attributes:

inventory_slot[3*number+item]=xxx;

so:
inventroy_slot[3*0+0]="Bug Juice";
inventroy_slot[3*0+1]=255;
inventroy_slot[3*0+2]=6;
inventroy_slot[3*1+0]="Soiled Diaper";
inventroy_slot[3*1+1]=9785;
etc...

btw: it starts by 0, but you can also start by one..makes no real different...

Re: array[n].property? Is this possible? [Re: Scorpion] #116547
03/11/07 10:01
03/11/07 10:01
Joined: Jan 2007
Posts: 36
Montana
webgovernor Offline OP
Newbie
webgovernor  Offline OP
Newbie

Joined: Jan 2007
Posts: 36
Montana
bummer...

Thank you very much for the reply.

...

I can see where that would get complicated, especially when removing and inserting items into the inventory.

Thanks again.

Re: array[n].property? Is this possible? [Re: webgovernor] #116548
03/11/07 11:13
03/11/07 11:13
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline
Expert
Germanunkol  Offline
Expert

Joined: Jun 2006
Posts: 2,640
Earth
you can find it in the manual under vars - multidimensional arrays...

I don't think it's too bad. the algorithm is

[number_of_elements_in_a_row*current_row + element_number_in_current_row]

so, if you'd want to sort the rows, you simply have to move
[3*current_row + 0] and [3*current_row + 1] and [3*current_row + 2] in order to move the entire row. It does take some time to get your head around it, I guess, but once you get it it's a great option...


~"I never let school interfere with my education"~
-Mark Twain
Re: array[n].property? Is this possible? [Re: Germanunkol] #116549
03/11/07 18:29
03/11/07 18:29
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
You can use structs in Lite-C


xXxGuitar511
- Programmer
Re: array[n].property? Is this possible? [Re: Germanunkol] #116550
03/11/07 18:51
03/11/07 18:51
Joined: Apr 2006
Posts: 265
V
vartan_s Offline
Member
vartan_s  Offline
Member
V

Joined: Apr 2006
Posts: 265
Quote:

It does take some time to get your head around it, I guess, but once you get it it's a great option...




Yes, its useful once you get it... but isn't C-script was supposed to be easier than C++?

I mean why would they change C/C++ to make it more confusing?

Re: array[n].property? Is this possible? [Re: vartan_s] #116551
03/11/07 18:55
03/11/07 18:55
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
c-script is the easy one
c-lite is harder
c++ is hard

...and binary is the impossible


xXxGuitar511
- Programmer
Re: array[n].property? Is this possible? [Re: xXxGuitar511] #116552
03/11/07 19:37
03/11/07 19:37
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline
Serious User
Happy Birthday Scorpion  Offline
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
Quote:

...and binary is the impossible




lol...had someone written a 3d-engine binary ?!

but really, then you have the most control over all...

Last edited by Scorpion; 03/11/07 19:38.
Re: array[n].property? Is this possible? [Re: Scorpion] #116553
03/11/07 20:37
03/11/07 20:37
Joined: Jan 2006
Posts: 1,829
Neustadt, Germany
T
TWO Offline

Serious User
TWO  Offline

Serious User
T

Joined: Jan 2006
Posts: 1,829
Neustadt, Germany
no, after C++ follows assembler and then binary. Don't ask me what's harder

And why C++ is harder than C? If you know C it just a cat jump (like we germans say) to work in C++.

Re: array[n].property? Is this possible? [Re: TWO] #116554
03/11/07 23:00
03/11/07 23:00
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
ranked usage difficulty from least to greatest as complexity increases
(only opinions, of course)
C++ (easiest)
C (fairly obsolete?)
Lite-C (obsolete at birth? somewhat < C?)
C-Script (just plain bullsh!t? nearly 92% of 'real' modern languages are more powerful?)

Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1