• Welcome to Valhalla Legends Archive.
 

Code from .txt ?

Started by WiLD, June 16, 2006, 07:13 AM

Previous topic - Next topic

rabbit

Grif: Yeah, and the people in the red states are mad because the people in the blue states are mean to them and want them to pay money for roads and schools instead of cool things like NASCAR and shotguns.  Also, there's something about ketchup in there.

ShadowDancer

Yes it is easy, i comonly create dinamyc instructions parsers for my programs, ei:


  if zstring(strstack[0],1) = 'walk' then
  begin
   li:=nil;
   if zstring(strstack[0],3) = 'comp_player' then
    li:=listview3.FindCaption(0,zstring(strstack[0],4),false,true,false);
   if zstring(strstack[0],3) = 'object' then
    li:=listview5.FindCaption(0,zstring(strstack[0],4),false,true,false);

   if li <> nil then
   begin
    bots[i].goingto.X:=strtoint('$'+li.SubItems.strings[2]);
    bots[i].goingto.Y:=strtoint('$'+li.SubItems.strings[3]);
   end
   else
    dec_ig_actionsstack(i,1);
  end;
  if zstring(strstack[0],1) = 'use_comp_player' then
  begin
    dwordstack[0]:=strtoint('$'+zstring(strstack[0],2));
    bytestack[0]:=strtoint('$'+zstring(strstack[0],3));
    d2g_sendpacket_0x38(bots[i].connections[2],0,dwordstack[0],bytestack[0]); // warriv go to east
  end;
  if zstring(strstack[0],1) = 'interact' then
  begin
   if zstring(strstack[0],3) = 'object' then
   begin
    dwordstack[0]:=strtoint('$'+zstring(strstack[0],4));
    d2g_sendpacket_0x13(bots[i].connections[2],2,dwordstack[0]);
    dec_ig_actionsstack(i,1);
   end;
   if zstring(strstack[0],3) = 'comp_player' then
   begin
    dwordstack[0]:=strtoint('$'+zstring(strstack[0],4));
    d2g_sendpacket_0x59(bots[i].connections[2],1,dwordstack[0],0,0);
    d2g_sendpacket_0x13(bots[i].connections[2],1,dwordstack[0]);
    d2g_sendpacket_0x2F(bots[i].connections[2],1,dwordstack[0]);
   end;
   if zstring(strstack[0],2) = 'end' then
   begin
    dwordstack[0]:=strtoint('$'+zstring(strstack[0],3));
    d2g_sendpacket_0x30(bots[i].connections[2],1,dwordstack[0]);
   end;
  end;


but the problem is that i cannt help you a little more bcoz I program in delphi, not vb =(
Quote from: MyndFyre-vL
No. We help people who help themselves.
http://sourceforge.net/projects/d2gs
http://assembla.com/space/d2gs

rabbit

A) Learn grammar please.
B) If you're not going to help at all, why post?  And why post a large block of code that has nothing to do with the thread?
Grif: Yeah, and the people in the red states are mad because the people in the blue states are mean to them and want them to pay money for roads and schools instead of cool things like NASCAR and shotguns.  Also, there's something about ketchup in there.

ShadowDancer

Quote from: rabbit on June 28, 2006, 01:28 PM
A) Learn grammar please.
B) If you're not going to help at all, why post?  And why post a large block of code that has nothing to do with the thread?

a) right :P

b) not at all...


var
       buf:array[0..1000] of byte; 
       strstack:array[0..10] of string;
       bufpos:longword;

procedure parseline();
begin
if (zstring(strstack[0],1) = 'openpacket') then
begin
  fillchar(buf, sizeof(buf), #0);
  bufpos:=0;
end;
if (zstring(strstack[0],1) = 'insertdword') then
begin
  writedword(buf, strtoint('$'+zstring(strstack[0],2)),bufpos);
end;
if (zstring(strstack[0],1) = 'insertword') then
begin
  writeword(buf, strtoint('$'+zstring(strstack[0],2)),bufpos);
end;
if (zstring(strstack[0],1) = 'insertbyte') then
begin
  writebyte(buf, strtoint('$'+zstring(strstack[0],2)),bufpos);
end;
if (zstring(strstack[0],1) = 'sendpacket') then
  socket.sendbuf(buf, bufpos,true);
if (zstring(strstack[0],1) = 'bsend') then // i dont undestand exactly what he mean with this
begin
  strstack[1]:=strstack[0]; delete(strstack[1],1,pos(' ',strstack[1])); //remove "bsend "
  socket.sendstr(strstack[1], true);
end;
end;


have the same structure and does that he wants to do...
Quote from: MyndFyre-vL
No. We help people who help themselves.
http://sourceforge.net/projects/d2gs
http://assembla.com/space/d2gs

l)ragon

If you were useing a .Net language you could use CodeDom.
*^~·.,¸¸,.·´¯`·.,¸¸,.-·~^*ˆ¨¯¯¨ˆ*^~·.,l)ragon,.-·~^*ˆ¨¯¯¨ˆ*^~·.,¸¸,.·´¯`·.,¸¸,.-·~^*