remove old npcs
This commit is contained in:
parent
5e46b101b8
commit
6ed4b1c5e0
|
@ -20,9 +20,7 @@ default
|
|||
{
|
||||
state_entry()
|
||||
{
|
||||
|
||||
m_npcdata = llCSV2List(osGetPrivateDataValue("tmp." + llGetKey()));
|
||||
hardReset();
|
||||
removeOldNPC();
|
||||
|
||||
m_lastTimeCheck = llGetUnixTime();
|
||||
checkOSPermissions();
|
||||
|
@ -76,6 +74,11 @@ state running
|
|||
if (change & CHANGED_REGION_START)
|
||||
hardReset();
|
||||
}
|
||||
|
||||
on_rez(integer start_param)
|
||||
{
|
||||
hardReset();
|
||||
}
|
||||
}
|
||||
|
||||
//Script commands
|
||||
|
@ -99,6 +102,7 @@ integer script_create(integer slot, key npc, list command)
|
|||
|
||||
npc = osNpcCreate(llList2String(command, 1), llList2String(command, 2), llList2Vector(llGetObjectDetails(llList2Key(objects, 0), [OBJECT_POS]), 0), llList2String(command, 3) + ".appearance");
|
||||
m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + slot, npc);
|
||||
createNPCTempStorage();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -323,8 +327,6 @@ doNextScriptStep()
|
|||
llSay(0, "Unknown command '" + llList2String(lineCommandData, 0) + "' in nc '"+ currentncname +"' on line '" + currentLine + "' failed.");
|
||||
}
|
||||
}
|
||||
|
||||
osSetPrivateDataValue("tmp." + llGetKey(), llList2CSV(m_npcdata));
|
||||
}
|
||||
|
||||
readNPCPathNC(string ncName)
|
||||
|
@ -386,9 +388,32 @@ hardReset()
|
|||
if(checkDataEntryInDataList(m_npcdata, "npc." + dataListCount))
|
||||
osNpcRemove((key)getDataEntryFromDataList(m_npcdata, "npc." + dataListCount));
|
||||
|
||||
m_lastTimeCheck = 0;
|
||||
m_npcdata = [];
|
||||
osDeletePrivateDataValue("tmp." + llGetKey());
|
||||
llResetScript();
|
||||
}
|
||||
|
||||
createNPCTempStorage()
|
||||
{
|
||||
list npcKeys = [];
|
||||
|
||||
integer currentNPCSlot = 0;
|
||||
for (currentNPCSlot = 0; currentNPCSlot < llGetListLength(m_npcdata); currentNPCSlot++)
|
||||
{
|
||||
key currentNPCKey = getDataEntryFromDataList(m_npcdata, "npc." + currentNPCSlot);
|
||||
npcKeys += [currentNPCKey];
|
||||
}
|
||||
|
||||
osSetPrivateDataValue("tmpNPCList." + llGetKey(), llList2CSV(npcKeys));
|
||||
}
|
||||
|
||||
removeOldNPC()
|
||||
{
|
||||
list npcdata = llCSV2List(osGetPrivateDataValue("tmpNPCList." + llGetKey()));
|
||||
integer count = llGetListLength(npcdata);
|
||||
|
||||
while(count--)
|
||||
{
|
||||
osNpcRemove(llList2Key(npcdata, count));
|
||||
}
|
||||
}
|
||||
|
||||
//Generic Helpers
|
||||
|
|
Loading…
Reference in New Issue