Closed XarPL closed 5 years ago
I'll have a look. Can you share your call to LeGo_Init
, i.e. which packages do you initialize?
I'm using that call at the moment: LeGo_Init(LeGo_All &~ LeGo_Bloodsplats &~ LeGo_Focusnames &~ LeGo_Draw3D &~ LeGo_Sprite &~ LeGo_Render &~ LeGo_Cursor);
When do you call TAL_GetValue
? Can you provide the code and when it is called (from Startup
, Init_Global
, ...)
I'm using it to check some conditions in frame function and in on_equip function. But I tried to call in many places (even by making new console command) and it's always the same problem. Code is nothing special, it's based on your Names package.
Could you please provide a minimal code example with which this issue occurs (including setting the talent, getting the talent, and when exactly to call these functions)?
I just tried it with the Names example. After setting the name with ShowName(PAL_100_Friend)
, and then loading and saving, the new name is preserved. If I check TAL_GetValue(PAL_100_Friend, Talent_Names)
it returns 1 as expected - also after saving and loading.
This is why we need a code example from you of where it does not work and/or more details.
Yeah, this example somehow works for me as well (i had to add ShowName function) BUT when i'm use SetName outside Init_Global (i.e in dialog) it no longer works after loading. I tried it on clean scripts with only one npc with the same result.
SetName
has to be called from Init_Global
(or similar), to ensure that the name of the NPC is updated (every time) after loading, once it was activated with ShowName
.
Regardless, TAL_GetValue
should return the correct value. I don’t see any problem. Still waiting for a concrete code example from you where the issue occurs. Otherwise this is just guessing...
It should but it doesn't for some reason. I made very simple code for testing purpose: Startup file:
func void STARTUP_GLOBAL()
{
Game_InitGerman();
};
func void INIT_GLOBAL()
{
Game_InitGerman();
LeGo_Init(LeGo_All);
testTalent = TAL_CreateTalent();
};
func void STARTUP_TESTWORLD()
{
Wld_InsertNpc (DEV_2131_Xar, "XXX");
};
Dialog file:
var int testTalent;
// ************************************************************
// EXIT
// ************************************************************
instance DIA_Xar_EXIT(C_INFO)
{
npc = DEV_2131_Xar;
nr = 999;
condition = DIA_Xar_EXIT_Condition;
information = DIA_Xar_EXIT_Info;
permanent = true;
description = DIALOG_ENDE;
};
func int DIA_Xar_EXIT_Condition()
{
return true;
};
func void DIA_Xar_EXIT_Info()
{
AI_StopProcessInfos (self);
};
// ************************************************************
// Hello
// ************************************************************
instance DIA_Xar_Hello (C_INFO)
{
npc = DEV_2131_Xar;
nr = 1;
condition = DIA_Xar_Hello_Condition;
information = DIA_Xar_Hello_Info;
permanent = true;
important = false;
description = "Set talent value";
};
func int DIA_Xar_Hello_Condition()
{
return true;
};
func void DIA_Xar_Hello_Info()
{
TAL_SetValue(self, testTalent, 32);
};
// ************************************************************
// Hello2
// ************************************************************
instance DIA_Xar_Hello2 (C_INFO)
{
npc = DEV_2131_Xar;
nr = 1;
condition = DIA_Xar_Hello2_Condition;
information = DIA_Xar_Hello2_Info;
permanent = true;
important = false;
description = "Show talent value";
};
func int DIA_Xar_Hello2_Condition()
{
return true;
};
func void DIA_Xar_Hello2_Info()
{
print (IntToString(TAL_GetValue(self, testTalent)));
};
After loading it doesn't read previous value and even after setting value again it still returns 0
Thank you for the code example. With it, it is quite easy to spot the issue.
You reset the talent to zero on every loading, because the talent is created anew every time the Init_Global
is called, i.e. in this line testTalent = TAL_CreateTalent();
. If you check the Names example, this should only be done once.
You can do this like so:
func void INIT_GLOBAL()
{
// ...
if (!testTalent) {
testTalent = TAL_CreateTalent();
};
};
This should solve your problem.
Concerning the names example, just some further clarifications:
SetName
is used to "register" an NPC for renaming. This function has to be called after every loading, i.e in Init_Global
(or similar). It's purpose is to either set the new name of an NPC or the original name (in case the new name has not been activated yet) every time the NPC is loaded.
ShowName
, on the other hand, will activate the new name and is only called once, e.g. in a dialog that reveals the NPC's new name.
See here.
So you should add similar condition to yours init function, you're calling TAL_CreateTalent after every loading as well.
if (f & LeGo_Names) { Talent_Names = TAL_CreateTalent(); };
No, this line is wrapped inside another condition which is only met on new game:
if(!_LeGo_Loaded) {
// ...
};
Aw, my bad. Your solution works, thanks for help.
No worries. Thanks for your patience. Glad that it works!
As in subject, after load TAL_GetValue always returns 0.