Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (degenerate_762, AbrahamR, AndrewAMD, ozgur), 667 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
str_for_entfile using last model name? #179546
01/23/08 19:35
01/23/08 19:35
Joined: Jan 2004
Posts: 59
S
SH6811 Offline OP
Junior Member
SH6811  Offline OP
Junior Member
S

Joined: Jan 2004
Posts: 59
Hello,

If I place the following code in the action attached to a model in order to "store" the name of the model for future use...why does the name that gets stored correspond to the LAST model that had this command in its action??

Code:

string entname(30);

action model1
{
...
str_for_entfile(entname, me); MODELS[my.offset] = handle(entname);
...
}

Re: str_for_entfile using last model name? [Re: SH6811] #179547
01/24/08 00:23
01/24/08 00:23
Joined: Sep 2003
Posts: 281
Arkansas\USA
raiden Offline
Member
raiden  Offline
Member

Joined: Sep 2003
Posts: 281
Arkansas\USA
... and you have MODELS like this:
Code:

define max_models, 100;
var MODELS[max_models];


... and offset like this:
Code:

define offset, skill1;



Just wanted to make sure those things were setup correct.

-raiden


"It doesn't matter if we win or lose, it's how we make the game."
--------------------
Links: 3DGS for Dummies
Re: str_for_entfile using last model name? [Re: raiden] #179548
01/24/08 00:26
01/24/08 00:26
Joined: Jan 2004
Posts: 59
S
SH6811 Offline OP
Junior Member
SH6811  Offline OP
Junior Member
S

Joined: Jan 2004
Posts: 59
Yes that's correct...

Re: str_for_entfile using last model name? [Re: SH6811] #179549
01/24/08 01:03
01/24/08 01:03
Joined: Sep 2003
Posts: 281
Arkansas\USA
raiden Offline
Member
raiden  Offline
Member

Joined: Sep 2003
Posts: 281
Arkansas\USA
Some things to try:
1. str_cpy(entname," "); before initializing entname to the character name file.

2. wait(1); before str_for_entfile(entname,me);.

3. Create a text object displaying entname, and put a breakpoint in the action to see if the name does change(hold ctrl+space to continue breakpoint stops). This isn't a fix, but it may help spot the problem.

-raiden


"It doesn't matter if we win or lose, it's how we make the game."
--------------------
Links: 3DGS for Dummies
Re: str_for_entfile using last model name? [Re: raiden] #179550
01/24/08 03:03
01/24/08 03:03
Joined: Jan 2004
Posts: 59
S
SH6811 Offline OP
Junior Member
SH6811  Offline OP
Junior Member
S

Joined: Jan 2004
Posts: 59
Thanks for your help...

Re: str_for_entfile using last model name? [Re: SH6811] #179551
01/24/08 22:04
01/24/08 22:04
Joined: Jan 2004
Posts: 59
S
SH6811 Offline OP
Junior Member
SH6811  Offline OP
Junior Member
S

Joined: Jan 2004
Posts: 59
Hi,

I'm still having some trouble with this. I've determined that the original handles seem to be set incorrectly...but I do not understand why?

When an "ent_morph" is performed what happens to the SKILLs of the "ORIGINAL" entity (the entity that was morphed)???

Re: str_for_entfile using last model name? [Re: SH6811] #179552
01/24/08 23:38
01/24/08 23:38
Joined: Jan 2004
Posts: 59
S
SH6811 Offline OP
Junior Member
SH6811  Offline OP
Junior Member
S

Joined: Jan 2004
Posts: 59
Hi,

Well I think I know what's happening however I have NO IDEA why?? It seems the assignment of the handle and subsequent calling of it works fine within the same function...but if the handle is assigned in one function and attempted to be called in another it doesn't work...for example:

function first()
{
index = 0;
SAMPLE_ENT = ptr_for_handle(Monsters[index]); //get entity pointer
str_cpy(entname, " "); str_for_entfile(entname, SAMPLE_ENT); //get file name
MODELS[SAMPLE_ENT.offset] = handle(entname); //store entity file name

...do stuff

DESC = ptr_for_handle(MODELS[SAMPLE_ENT.offset];
ent_morph(SAMPLE_ENT, DESC); //change back to "original" model/sprite
}

that above works FINE...however...

function first()
{
index = 0;
SAMPLE_ENT = ptr_for_handle(Monsters[index]); //get entity pointer
str_cpy(entname, " "); str_for_entfile(entname, SAMPLE_ENT); //get file name
MODELS[SAMPLE_ENT.offset] = handle(entname); //store entity file name
}

function second()
{
DESC = ptr_for_handle(MODELS[SAMPLE_ENT.offset];
ent_morph(SAMPLE_ENT, DESC); //change back to "original" model/sprite
}

This doesn't work at all, it simply uses the "last" entity that was accessed using the "str_for_entfile" command...WHY???

Re: str_for_entfile using last model name? [Re: SH6811] #179553
01/25/08 07:35
01/25/08 07:35
Joined: Sep 2003
Posts: 281
Arkansas\USA
raiden Offline
Member
raiden  Offline
Member

Joined: Sep 2003
Posts: 281
Arkansas\USA
I believe your losing it because SAMPLE_ENT is not being intialized properly in the "second()" function. I had a much better explanation a couple of hours ago before I started scripting out your problem, but its 1:30am, and my brain is fried, so I can't remember what it was, .

Anyway, I hope you like this piece I did for you.
Code:
define maxModels, 100; // maximum models
define maxModelTypes, 10; // maximum model types
//--
define typeMONSTERS, 0;
//define up 9 more types here, must initialize to 1,2,3,4...
//--
define offset, skill1;
//--
var MODELS[maxModelTypes];
//--
// multiarray - supports 10 types of different models, up to 10 each
// i.e. typeMONSTERS with skill1 offset from 0-9
// typeTREES with skill1 offset from 0-9
// etc.
var MORPHMDLS[1000]; // 10x100 multiarray
//--
var fncMorphCheck;
//--
entity* tempPtr;
//--
string entname;
//--
function setEntName(mdlType,index)
{
if(mdlType == typeMONSTERS && index < maxModelTypes)
{
my = ptr_for_handle(MODELS[index]); // get me
}
//--
str_for_entfile(entname,my); // copy the entity into the string
//--
if(mdlType == typeMONSTERS && str_len(entname) > 0)
{
MORPHMDLS[typeMONSTERS*maxModels+index] = handle(entname); // save a handle to the string
}
// more types
//--
if(str_len(entname) == 0) { error("entname not initialized!"); }
if(index >= maxModelTypes || mdlType >= maxModelTypes){ error("Invalid type or index"); }
}
//--
function morphEntName(mdlType,index)
{
if(mdlType == typeMONSTERS && index < maxModelTypes)
{
my = ptr_for_handle(MODELS[index]); // get me
tempPtr = ptr_for_handle(MORPHMDLS[typeMONSTERS*maxModels+index]); // get ptr from name
if(tempPtr == NULL) { breakpoint; }
ent_morph(my,tempPtr); // morph me to ptr from name
}
// more types
//--
if(index >= maxModelTypes || mdlType >= maxModelTypes){ error("Invalid type or index"); }
}
//--
action entityMonster
{
if(my.offset < maxModelTypes) { MODELS[my.skill1] = handle(my); }
if(my.offset >= maxModelTypes) { error("Invalid offset!"); return; }
//--
setEntName(typeMONSTERS,my.skill1); // set the entity name
//--
//..testing
ent_morph(me,"ball.mdl");
//..
wait(-5);
morphEntName(typeMonsters,my.skill1); // get the entity name, and morph back
//--
}



Hope thats what your after, I tested it and it works great. Let em know if you have any questions.

-raiden


"It doesn't matter if we win or lose, it's how we make the game."
--------------------
Links: 3DGS for Dummies
Re: str_for_entfile using last model name? [Re: raiden] #179554
02/09/08 02:49
02/09/08 02:49
Joined: Jan 2004
Posts: 59
S
SH6811 Offline OP
Junior Member
SH6811  Offline OP
Junior Member
S

Joined: Jan 2004
Posts: 59
Hi Raiden,

Sorry for the delay in the repsonse. I want to thank you for the code you wrote, that was very nice of you...

I used your code to work into mine and got some interesting results. Basically what I did (from memory here so it may not be exact...)

action MONSTER1
{
...
MODELS[my.skill1] = handle(my);
...
}

function first()
{
my = ptr_for_handle(MODELS[index]); // get me
str_for_entfile(entname,my); // copy the entity into the string
MORPHMDLS[index] = handle(entname); // save a handle to the string
}

function second
{
my = ptr_for_handle(MODELS[index]); // get me
tempPtr = ptr_for_handle(MORPHMDLS[my.offset]); // get ptr from name
ent_morph(my,tempPtr); // morph me to ptr from name
}

...that seemed to work fine, and thank you for that. My problem came when I did exactly the same thing for a second set of entities and set the pointers to another array...then I saw the original problem again. I have no idea as to why it does this...

I managed a work-around...so I'm just left with confusion as to what caused this odd behaviour. Thank you again for your help. Regards.

Re: str_for_entfile using last model name? [Re: SH6811] #179555
02/10/08 20:12
02/10/08 20:12
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
Quoting SH6811.
Quote:

why does the name that gets stored correspond to the LAST model that had this command in its action??



?:
*index++, offset++, skill1++?
*raiden seems to use a simulated multi-dimensional array (diff)
*ent(ptr) == mutEnt(ptr)? handles same? (not new?)
*formally tell the engine it's a STRING*?


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

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