Issue information

Issue ID
#4984
Status
Fixed
Severity
Low
Started
Hercules Elf Bot
Jun 27, 2011 13:03
Last Post
AnnieRuru
Mar 19, 2014 20:18
Confirmation
Yes (4)
No (0)

Hercules Elf Bot - Jun 27, 2011 13:03

Originally posted by [b]~AnnieRuru~[/b]
http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=4984

http://eathena-project.googlecode.com/svn/...t_duplicate.txt

CODE
// Outcome (r11216 trunk):
// * the variables are _shared_ between all duplicates
yes it is
if you test this script these 3 porings always tells you same coordinate,
because the npc variable overwriting each other

it should use an array or getd ...


maybe something like this
CODE
-    script    Test Script    -1,1,1,{
    mes "Hi.";
    set .@id, atoi( strnpcinfo(2) );
    mes "My coords are "+ .map$[.@id] +", "+ .x[.@id] +"/" +.y[.@id];
    close;

OnInit:
    set .@id, atoi( strnpcinfo(2) );
    getmapxy .map$[.@id], .x[.@id], .y[.@id], 1;
    end;

OnTouch:
    emotion e_scissors;
    end;
}

prontera,150,175,4    duplicate(Test Script)    Test1#1    909
prontera,155,175,4    duplicate(Test Script)    Test2#2    909,2,2
prontera,160,175,4    duplicate(Test Script)    Test3#3    909,3,3

but please do not revert the npc variable to not sharing among duplicates,
because some of our event scripts which uses duplicates already adept to this system

This post has been edited by ~AnnieRuru~: Jun 27 2011, 06:03 AM

Hercules Elf Bot - Dec 23, 2011 9:20

Originally posted by [b]GodLesZ[/b]
Uhm.. maybe its to early for me, but shouldnt the [font=courier new,courier,monospace]OnTouch[/font] event overwrite the existing [font=courier new,courier,monospace].map$[/font] and coordinate variables?
Therefore the coordinates should be different.

Hercules Elf Bot - Feb 7, 2012 21:32

Originally posted by [b]Kenpachi[/b]
Temporary NPC variables should be flushed when the instance runs out. So in my opinion the sample should use permanent variables.

Hercules Elf Bot - Jul 21, 2012 23:20

Originally posted by [b]Kenpachi[/b]
I just tested the script and it's true that the duplicates share the variables. All three showed "My coords are prontera, 155/175".

That's something a core dev should take care of ASAP I think!

Ind - Apr 16, 2013 4:22

this is not a core problem it is a documentation problem (npcs duplicates have been modified to be a link to the original npc script instead of a actual duplicate loong time ago in eathena). moving to documentation.

AnnieRuru - Mar 19, 2014 20:18

fixed in
[url="https://github.com/HerculesWS/Hercules/commit/f7cd6b42179e2cdb5bbea3b9c060d0fc56d265b6"]https://github.com/HerculesWS/Hercules/commit/f7cd6b42179e2cdb5bbea3b9c060d0fc56d265b6[/url]

when I test with this script, I always get this result[code=auto:0][Debug]: script debug : 0 110000003 : Test3 [Debug]: script debug : 0 110000002 : Test2 [Debug]: script debug : 0 110000001 : Test1 [Debug]: script debug : 0 110000000 : Test Script[/code]it anyone gets a different result please tell