Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #14  
Old 06-26-2013, 05:07 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by fowlplay4 View Post
This could probably be optimized to use onAllRCChat now.
I was actually working on something similar recently, with the idea being to capture the account of the person making the change as well, so that could be passed to gsync and used to commit the change to source control under their name. Also works for level uploads (which are essentially text, after all). It's a lot messier than yours, but this is what I came up with:

PHP Code:
function onAllRCChat(temp.msg) {  
  if (
temp.msg.starts("Script ") && temp.msg.pos(" updated by ") > (- 1)) {
    
temp.tokens temp.msg.tokenize();
    
temp.acc temp.tokens[temp.tokens.size() - 1];
    
this.handleUpdate(temp.acc, {{"script"temp.tokens[1]}});
  } else if (
temp.msg.starts("Script ") && temp.msg.pos(" deleted by ") > (- 1)) {
    
temp.tokens temp.msg.tokenize();
    
temp.acc temp.tokens[temp.tokens.size() - 1];
    
this.handleUpdate(temp.acc, {{"script"temp.tokens[1]}});
  } else if (
temp.msg.starts("The script of NPC ") && temp.msg.pos(" has been updated by ") > (- 1)) {
    
temp.tokens temp.msg.tokenize();
    
temp.acc temp.tokens[temp.tokens.size() - 1];
    
this.handleUpdate(temp.acc, {{"npc"temp.tokens[4]}});
  } else if (
temp.msg.starts("NPC ") && temp.msg.pos(" has been added by ") > (- 1)) {
    
temp.tokens temp.msg.tokenize();
    
temp.acc temp.tokens[temp.tokens.size() - 1];
    
this.handleUpdate(temp.acc, {{"npc"temp.tokens[1]}});
  } else if (
temp.msg.starts("The npc ") && temp.msg.pos(" has been deleted by ") > (- 1)) {
    
temp.tokens temp.msg.tokenize();
    
temp.acc temp.tokens[temp.tokens.size() - 1];
    
this.handleUpdate(temp.acc, {{"npc"temp.tokens[2]}});
  } else if (
temp.msg.starts("The flags of NPC ") && temp.msg.pos(" have been updated by ") > (- 1)) {
    
temp.tokens temp.msg.tokenize();
    
temp.acc temp.tokens[temp.tokens.size() - 1];
    
this.handleUpdate(temp.acc, {{"npc"temp.tokens[4]}});
  } else if (
temp.msg.starts("Weapon/GUI-script ") && temp.msg.pos(" added/updated by ") > (- 1)) {
    
temp.tokens temp.msg.tokenize();
    
temp.acc temp.tokens[temp.tokens.size() - 1];
    
this.handleUpdate(temp.acc, {{"weapon"temp.tokens[1]}});
  } else if (
temp.msg.starts("Weapon ") && temp.msg.pos(" deleted by ") > (- 1)) {
    
temp.tokens temp.msg.tokenize();
    
temp.acc temp.tokens[temp.tokens.size() - 1];
    
this.handleUpdate(temp.acc, {{"weapon"temp.tokens[1]}});
  }
}

// figure out who uploaded it by checking rclog.txt
function onLevelFileUpdated(temp.file) {
  
temp.file "levels/" temp.file;
  
  if (! 
temp.file.ends(".nw") && ! temp.file.ends(".gmap")) {
    return;
  }
  
  
temp.log.loadLines("logs/rclog.txt");
  
temp.lastLog temp.log[temp.log.size() - 1];
  
  
temp.acc "(npcserver)";
  
  if (
temp.lastLog.pos(temp.file) > (- 1)) {
    
temp.tokens temp.lastLog.tokenize();
    
temp.acc temp.tokens[0];
  }
  
  
this.handleUpdate(temp.acc, {{"file"temp.file}});
}

// public so this can also be hooked into online level/NPC editors
public function handleUpdate(temp.acctemp.files) {
  echo(
temp.acc ": " temp.files);

If I get some free time I might see about finishing this. It would be nice if gsync could work on a single changed file, rather than having to check every file every time. Also, you could store the account of the player, which is nifty to stick in source control.
__________________
Reply With Quote
 


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 07:17 PM.


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