Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by Zheka. 06/20/24 14:26
Lapsa's very own thread
by rki. 06/19/24 11:27
A simple game ...
by VoroneTZ. 06/18/24 10:50
Face player all the time ...
by bbn1982. 06/18/24 10:25
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (RealSerious3D, rvl), 1,187 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
squik, AemStones, LucasJoshua, Baklazhan, Hanky27
19060 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
! easy store skills in array ! #182518
02/07/08 09:17
02/07/08 09:17
Joined: Jul 2002
Posts: 2,002
Europe
ShoreVietam Offline OP
Expert
ShoreVietam  Offline OP
Expert

Joined: Jul 2002
Posts: 2,002
Europe
Moments ago I had a nice idea how to store skills into an array easily using call by reference.

Works with A6.31.4, but should work with every GS version supporting call by reference.

So here's the code:

Code:
var player_data[400];
function copySkills(&skillvar, num)
{
var cnt = 0;

num = 100 * num;
while (cnt < 100) {
player_data[num + cnt] = skillvar[cnt];
cnt += 1;
}

return;
}
function loadSkills(&skillvar, num)
{
var cnt = 0;

num = 100 * num;
while (cnt < 100) {
skillvar[cnt] = player_data[num + cnt];
cnt += 1;
}

return;
}




Description:
Pass a skill as first parameter, this skill (memory adress) can now (as a var) be handled as an array and being stored into another array, or the other way round.
The second parameter just is a unique player number that defines the offset to create a multidimensional array (100 slots per actor/ entity).


And that's how you call it:

Code:
copySkills(my.skill1, my._player_number);

loadSkills(my.skill1, my._player_number);



You always pass skill1 since this is the start of the "skill-arrya" and player number is the offset, for example 0 or 4 or 17, but you have to take care about the correct setup of the player numbers.


My project Schlacht um Kyoto - Das Samurai Browsergame! (sorry, german only)
Re: ! easy store skills in array ! [Re: ShoreVietam] #182519
02/07/08 10:31
02/07/08 10:31
Joined: Apr 2005
Posts: 3,815
Finland
Inestical Offline
Rabbit Developer
Inestical  Offline
Rabbit Developer

Joined: Apr 2005
Posts: 3,815
Finland
Oo.. I didn't know that feature. Nice. Thanks for sharing


"Yesterday was once today's tomorrow."
Re: ! easy store skills in array ! [Re: Inestical] #182520
02/07/08 12:19
02/07/08 12:19
Joined: Jul 2002
Posts: 2,002
Europe
ShoreVietam Offline OP
Expert
ShoreVietam  Offline OP
Expert

Joined: Jul 2002
Posts: 2,002
Europe
Actually it's no real "feature" but knowing how data is stored in the RAM.


My project Schlacht um Kyoto - Das Samurai Browsergame! (sorry, german only)
Re: ! easy store skills in array ! [Re: ShoreVietam] #182521
02/07/08 13:12
02/07/08 13:12
Joined: Apr 2005
Posts: 3,815
Finland
Inestical Offline
Rabbit Developer
Inestical  Offline
Rabbit Developer

Joined: Apr 2005
Posts: 3,815
Finland
I ment the fact that that my.skill1 can act as array pointer


"Yesterday was once today's tomorrow."
Re: ! easy store skills in array ! [Re: Inestical] #182522
02/08/08 11:09
02/08/08 11:09
Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
frazzle Offline
Expert
frazzle  Offline
Expert

Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
I actually already knew that this was possible but I never thought that it was a unique aspect ^^
Anyway, thanks for mentioning it

Cheers

Frazzle


Antec® Case
Intel® X58 Chipset
Intel® i7 975 Quad Core
8 GB RAM DDR3
SSD OCZ®-VERTEX2 3.5 x4 ; HD 600 GB
NVIDIA® GeForce GTX 295 Memory 1795GB

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | 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