Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-10-2008, 12:02 AM
RozenMaiden RozenMaiden is offline
Registered User
Join Date: Dec 2008
Posts: 27
RozenMaiden is on a distinguished road
NPCs incorrect information (alter npc load order?)

Hi,

so I currently have a little problem.

I have an npc that scans for a special type of other npcs in the npcs array of the level at onCreated(); now that worked fine, but now i'm scanning for 2 special types and a problem came up: it scans too early.

I wouldn't like to use sleep or something like that to delay the scan. Because if it scans at onCreated atleast one of the second-special-type npcs hasnt set its attribs (nick, etc) yet and thus isnt recognized as that special-type-npc by the main npc. Now my question is it possible to delay the loading of an npc? Like let it load and call onCreated() after all other npcs are loaded?
Reply With Quote
  #2  
Old 12-10-2008, 12:19 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
You can delay the loading of the rest of the NPC by doing this I guess
PHP Code:
//#CLIENTSIDE
function onCreated() {
  while (
temp.wait 10) {
    
temp.wait++;
    
sleep(0.05);
  }
  [
Other Stuff Here]

But it would probably be better practice to do it this way:
PHP Code:
function onCreated() {
  
scheduleEvent(1"NewCreated"NULL);
}

function 
onNewCreated() {
  [
Other Stuff Here]

__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #3  
Old 12-10-2008, 12:40 AM
RozenMaiden RozenMaiden is offline
Registered User
Join Date: Dec 2008
Posts: 27
RozenMaiden is on a distinguished road
Yeah I know that, but I'd like a way that makes sure all other npcs have loaded. Is there something like that?
Reply With Quote
  #4  
Old 12-10-2008, 12:57 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Quote:
Originally Posted by RozenMaiden View Post
Yeah I know that, but I'd like a way that makes sure all other npcs have loaded. Is there something like that?
Shouldn't take more than 0.05 seconds for all of the NPCs to load.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #5  
Old 12-10-2008, 02:57 PM
RozenMaiden RozenMaiden is offline
Registered User
Join Date: Dec 2008
Posts: 27
RozenMaiden is on a distinguished road
Hm guess i'll just delay it by 1 sec then, ty

another problem:

i have a problem with an npc. it's called by another npc but it doesnt do anything before i grab it? O_o

someone told me it may be that the npc may be "inactive" (as graal thinks it does nothing). how do i work around that

Last edited by RozenMaiden; 12-10-2008 at 05:30 PM..
Reply With Quote
  #6  
Old 12-10-2008, 05:34 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by RozenMaiden View Post
Hm guess i'll just delay it by 1 sec then, ty

another problem:

i have a problem with an npc. it's called by another npc but it doesnt do anything before i grab it? O_o

someone told me it may be that the npc may be "inactive" (as graal thinks it does nothing). how do i work around that
Try this:
PHP Code:
npc.trigger("update"nil); 
Reply With Quote
  #7  
Old 12-10-2008, 05:35 PM
RozenMaiden RozenMaiden is offline
Registered User
Join Date: Dec 2008
Posts: 27
RozenMaiden is on a distinguished road
uh well, do i only have to do that one time or everytime i do an update?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 04:00 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.