Page 1 of 1
Ident as Net-Variable
Posted: 11 May 2013, 18:38
by steeffeen
Hey there,
I'm wondering why Idents can't be declared as net-variable since quite some time, is there a major problem which would prevent this or may it be possible in the future?
Because it would help a lot if it would be possible to pass Idents to clients
example:
Code: Select all
declare netwrite Ident Net_ImportantPlayerId for UI;
Regards,
Steff
Re: Ident as Net-Variable
Posted: 11 May 2013, 18:48
by TGYoshi
Idents are instance references and thus can not be serialized properly. It's probably the reason why not and it's quite logical.
Re: Ident as Net-Variable
Posted: 11 May 2013, 18:51
by steeffeen
hm, i don't really get the "Instance references" thing, isn't
Ident a simple type used as key in many array? if it's a reference, how do i get the according instance from the Ident then?
thanks for the response anyways

Re: Ident as Net-Variable
Posted: 11 May 2013, 18:58
by TGYoshi
Idents seem to be some internal dirty thing.
Idents are, however, dynamic on their own, which could also be the reason why it's not transferable.
Re: Ident as Net-Variable
Posted: 11 May 2013, 19:00
by steeffeen
TGYoshi wrote:Idents seem to be some internal dirty thing.
i will probably go with that

Re: Ident as Net-Variable
Posted: 11 May 2013, 19:07
by Kaphene
is there not a way to convert an Ident to a text or string type variable and then pass that to net?
like
declare Text[] PlayersIdents;
foreach(Player in Players)
{
PlayersIdents.add(Player.Id);
}
and then do whatever you want with PlayersIdents?
I know it's not that simple exactly, but isn't there some way to convert?
Re: Ident as Net-Variable
Posted: 11 May 2013, 19:11
by steeffeen
Kaphene wrote:is there not a way to convert an Ident to a text or string type variable and then pass that to net?
well, yes
it would rather be like:
Code: Select all
declare Text[] PlayersIdents;
foreach(Player in Players)
{
PlayersIdents.add(""^Player.Id);
}
but you can't use the string as key for the arrays, you would have to compare
(IdentString == ""^Object.Id) all the time, i know that there are some work-arounds but using the Idents directly would be a lot easier
Re: Ident as Net-Variable
Posted: 11 May 2013, 19:36
by TGYoshi
Well Idents ARE insanely dirty.
For example take the BlockScriptId in an EditorPlugin. It's an integer. However, it refers to the Ident of a block when a maptype is ran so you have to convert the Ident of a block when the game runs to an integer (first to a string, then strip the # using TextLib) to compare it...