It is currently Sun Dec 16, 2018 5:12 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: SQL driven MUD
PostPosted: Mon Nov 26, 2018 5:18 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Feb 12, 2006 10:06 pm
Posts: 638
a few months ago, there was a post about creating a Multi-User Dungeon in Purebasic (but I can't seem to be able to find it now)
in any case, I started experimenting with a couple of different ways to code it - I'm hoping you guys might find my attempt as interesting as I do :)
the linked zip consists of:
mota.pb - the engine
dbinitialise.txt - sql initial objects (like rooms & items)
dbsetup.txt - sql framework
client.pb - console based client

it's definitely far from complete, but it's mostly functional :P

<dropbox link> - link removed; dropbox isn't playing nice as a host site - code is transcribed below instead

any feedback is more than welcome

_________________
there is no sig, only zuul (and the following disclaimer)

WARNING: may be talking out of his hat


Last edited by citystate on Mon Dec 03, 2018 12:26 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: SQL driven MUD
PostPosted: Sun Dec 02, 2018 5:25 am 
Offline
Enthusiast
Enthusiast

Joined: Mon Nov 25, 2013 5:38 am
Posts: 237
Location: Australia
The link has been disabled by Dropbox for too many requests or something. I find it highly doubtful because according to their article on traffic limits the following must have occurred:

20 GB per day: The total amount of traffic that all of your links and file requests combined can generate
100,000 downloads per day: The total number of downloads that all of your links combined can generate


Top
 Profile  
Reply with quote  
 Post subject: Re: SQL driven MUD
PostPosted: Sun Dec 02, 2018 10:24 am 
Offline
Addict
Addict
User avatar

Joined: Tue Oct 09, 2007 2:15 am
Posts: 1002
coco2 wrote:
The link has been disabled by Dropbox for too many requests or something. I find it highly doubtful because according to their article on traffic limits the following must have occurred:

20 GB per day: The total amount of traffic that all of your links and file requests combined can generate
100,000 downloads per day: The total number of downloads that all of your links combined can generate


It is doubtful !
I had included a gif graphic in this forum (a smiley) with 2KB file size.
after 2 days i got the same message....
I waited a long time for an answer from support, but it was only a standard answer. Result: Since a few years I can't share links anymore.
It will not be reset.

As long as you use the free account, you can't use dropbox as "hoster".

_________________
PureBasic 5.46 LTS / 5.62 (Windows x86/x64) | Windows10 Pro x64 | Z370 Extreme4 | i7 8770k | 32GB RAM | iChill GeForce GTX 980 X4 Ultra | HAF XF Evo​​
English is not my native language... (I often use DeepL to translate my texts.)


Top
 Profile  
Reply with quote  
 Post subject: Re: SQL driven MUD
PostPosted: Mon Dec 03, 2018 12:21 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Feb 12, 2006 10:06 pm
Posts: 638
dammit :?
I was hoping to make it easier for peeps - I'll just c/p below - it's a little large, so I'll break it up into three posts
you'll need to save everything in the same directory

MOTA.pb
Code:
CreateRegularExpression(0,"[\w()\d\-'#$%^&*+/\\]+(\.\d+)?|(["+#DQUOTE$+"])[\w()\d\s\-'#$%^&*+/\\,.?!]+(\2)")
CreateRegularExpression(1,"[^#]+")
CreateRegularExpression(2,"([^;]*(["+#DQUOTE$+"])[^"+#DQUOTE$+"]+(\2)[^;]*|[^;]+);?")

InitNetwork()

Enumeration
  #mudtick
  #mudinfo
EndEnumeration

Global netloop=CreateMutex()
Global netaccess=CreateMutex()
Global dbaccess=CreateMutex()
Global tick
Declare ProcessCmd(client,cmd.s)

Structure cl
  cl.i
  admin.b
  mname.s
  name.s
  pass.s
  mob.w
  gend.w
  class.w
  race.w
  state.w
  mode.b
  g.s
  c.s
  r.s
  ip.i
EndStructure

Enumeration
  #mud_GetName
  #mud_SetPass
  #mud_GetPass
  #mud_GetPass_fail1
  #mud_GetPass_fail2
  #mud_GetPass_fail3
  #mud_GetPass_confirm
  #mud_GetRace
  #mud_GetClass
  #mud_GetGend
  #mud_GetMobName
  #mud_CreateMob
  #mud_Play
EndEnumeration

Macro dbq(db,q,y=ok(),n=nok()):LockMutex(dbaccess):If DatabaseQuery(db,q):y:Else:Printg(q):n:EndIf:UnlockMutex(dbaccess):EndMacro
Macro dbu(db,q,y=ok(),n=fok()):LockMutex(dbaccess):If DatabaseUpdate(db,q):y:Else:Printg(q+#CRLF$+DatabaseError()):n:EndIf:UnlockMutex(dbaccess):EndMacro
Macro aan(a):StringField("a ,an ",1+Bool(FindString("aeiouyh",Left(LCase(a),1))),",")+a:EndMacro
Procedure printg(m$)
  AddGadgetItem(#mudinfo,-1,m$)
EndProcedure

Procedure printt(m$)
  SetGadgetText(#mudtick,m$)
EndProcedure

Procedure ok():EndProcedure
Procedure nok():Printg("database warning: "+#CRLF$+DatabaseError()):EndProcedure
Procedure fok():Printg("database error: "+#CRLF$+DatabaseError()):End:EndProcedure
Procedure.s getLine(id,n=1)
  cols=DatabaseColumns(id)
  While NextDatabaseRow(id)
    p+1
    If n=p Or n=-1
      For i=0 To cols-1
        a$+#TAB$+GetDatabaseString(id,i)
      Next
      If n<>-1:Break:EndIf
      a$+#CRLF$
    EndIf
  Wend
  FinishDatabaseQuery(id)
  ProcedureReturn a$
EndProcedure

Procedure LastID(id,label.s)
  SetDatabaseString(id,0,label)
  dbq(id,"select id from last where label=?",ProcedureReturn Val(getLine(id)))
EndProcedure

Procedure Success(id,label.s)
  SetDatabaseString(id,0,label)
  dbq(id,"select id from last where label=? and error=''",ProcedureReturn Val(getLine(id)))
EndProcedure

Procedure.s getAllLines(id,usecolumns=1)
  cols=DatabaseColumns(id)
  If usecolumns
    For i=0 To cols:b$+#TAB$+DatabaseColumnName(id,i):Next:b$+#CRLF$
  EndIf
  ProcedureReturn b$+getLine(id,-1)
EndProcedure

Procedure UpdateTable(from,target,table.s)
  n=DatabaseColumns(from)
  q$=Mid(ReplaceString(Space(n)," ",",?"),2)
  While NextDatabaseRow(from)
    If IsWindow(0):ev=WindowEvent():EndIf
    For i=0 To n-1:SetDatabaseString(target,i,GetDatabaseString(from,i)):Next
    dbu(target,"insert or replace into "+table+" values("+q$+")")
  Wend
EndProcedure

Procedure loadDBfile(id,file$)
  If OpenFile(0,file$)
    template.s="[1]"
    While Not Eof(0)
      c$=template
      a$=ReadString(0)
      b$=Left(a$,1)
      Select b$
        Case "#"
          template=Mid(a$,2)
        Case "!"
          a$=Mid(a$,2)
          For i=1 To 16
            SetDatabaseString(id,i-1,StringField(a$+"~~~~~~~~~~~~~~~~",i,"~"))
          Next
          dbu(id,"insert into cmd values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
        Default
          c=CountString(a$,"~")+1
          For i=1 To c
            c$=ReplaceString(c$,"["+Str(i)+"]",StringField(a$,i,"~"))
          Next
          dbu(id,c$)
      EndSelect
    Wend
  EndIf
EndProcedure

Procedure setupDB(file$)
  UseSQLiteDatabase()
  If FileSize(file$)<0
    CreateFile(0,file$):CloseFile(0)
  EndIf
  If OpenDatabase(0,file$,"","")
    loadDBfile(0,"dbsetup.txt")
    loadDBfile(0,"dbinitialise.txt")
  EndIf
EndProcedure

Procedure GetID(id,name.s,label.s="")
  SetDatabaseString(id,0,name)
  If label
    SetDatabaseString(id,1,label)
    q$=" and label like(?)"
  EndIf
  dbq(0,"select id from obj where name like(?)"+q$,ProcedureReturn Val(getLine(id)))
EndProcedure

Procedure GetUserOnline(id,name.s)
  SetDatabaseString(id,0,name)
  dbq(0,"select state from usr where name=?",ProcedureReturn Val(getLine(id)))
EndProcedure

Procedure.s GetNetworkString(cl)
  *b=AllocateMemory(1024)
  b=1024:b$=""
  While b=1024
    b=ReceiveNetworkData(cl,*b,1024)
    b$+PeekS(*b,-1,#PB_Ascii)
  Wend
  FreeMemory(*b)
  ProcedureReturn b$
EndProcedure

Procedure sendmessage(cl,msg$)
  If cl
    LockMutex(netaccess)
    SendNetworkString(cl,msg$)
    UnlockMutex(netaccess)
  EndIf
EndProcedure

Procedure sendCom(id)
  ocl=-1
  While NextDatabaseRow(id)
    cl=GetDatabaseLong(id,0)
    If ocl=cl Or ocl=-1
      m$+GetDatabaseString(id,1)+#CRLF$
    Else
      sendmessage(ocl,m$)
      m$=GetDatabaseString(id,1)+#CRLF$
    EndIf
    ocl=cl
  Wend
  sendmessage(ocl,m$)
EndProcedure

Procedure ticking(id)
  While TryLockMutex(netloop)=0
    Delay(1000)
    Printt(Str(tick+1))
    tick+1
  Wend
  UnlockMutex(netloop)
EndProcedure

Procedure CreateMob(id,*c.cl)
  SetDatabaseString(id,0,*c\mname)
  SetDatabaseString(id,1,aan(*c\g)+" "+*c\r+" "+*c\c)
  SetDatabaseString(id,2,*c\c)
  SetDatabaseString(id,3,*c\r)
  SetDatabaseString(id,4,*c\g)
  dbu(id,"insert into cmd(who,c1,c2,c3,c4,c5,c6,c7,c8) values(0,'new','mob',?,?,?,?,?,1)",ProcedureReturn LastID(0,"mob"))
EndProcedure

Procedure CreateUser(id,*c.cl)
  SetDatabaseString(id,0,*c\name)
  SetDatabaseString(id,1,*c\pass)
  SetDatabaseLong(id,2,*c\cl)
  SetDatabaseLong(id,3,*c\mob)
  dbu(id,"insert into usr(name,pass,state,mob,loc) values(?,?,?,?,1)",ProcedureReturn LastID(id,"usr"))
EndProcedure

Procedure netlisten(port)
  oldtick=0
  NewMap client.cl()
  If CreateNetworkServer(0,port)
    While TryLockMutex(netloop)=0
      Delay(0)
      SetDatabaseLong(0,0,tick)
      dbu(0,"update tick set tick=?")
      If oldtick<tick
        SetDatabaseLong(0,0,tick)
        dbq(0,"select state,message from com_ c,usr where mob=c.who and sent=0 and tick<=? order by c.id",sendCom(0))
        SetDatabaseLong(0,0,tick)
        dbu(0,"update com_ set sent=1 where tick<=? and sent=0")
        oldtick=tick
      EndIf
      LockMutex(netaccess)
      ne=NetworkServerEvent(0)
      cl=EventClient()
      *c.cl=FindMapElement(client(),Str(cl))
      If *c:id=GetID(0,*c\name,"usr"):EndIf
      UnlockMutex(netaccess)
      Select ne
        Case #PB_NetworkEvent_Connect
          *c=AddMapElement(client(),Str(cl))
          *c\state=#mud_GetName
          *c\cl=cl
          *c\ip=GetClientIP(cl)
          sendmessage(cl,"Welcome to PureMOTA."+#CRLF$+"What is your name?: |")
        Case #PB_NetworkEvent_Disconnect
          If *c
            SetDatabaseLong(0,0,*c\mob)
            SetDatabaseLong(0,1,id)
            dbu(0,"update usr set state=0,loc=(select loc from mob where id=?) where id=?")
            SetDatabaseLong(0,0,id)
            SetDatabaseLong(0,1,*c\mob)
            dbu(0,"update mob set active=0,loc=? where id=?")
          EndIf
          DeleteMapElement(client(),Str(cl))
        Case #PB_NetworkEvent_Data
          a$=GetNetworkString(cl)
          Select *c\state
            Case #mud_GetName
              If a$
                If GetUserOnline(0,a$)
                  sendmessage(cl,a$+" is already connected, please use a different account."+#CRLF$+"What is your name?: |")
                Else
                  *c\state=#mud_GetPass
                  sendmessage(cl,"Please enter your password: |")
                EndIf
                *c\name=a$
              EndIf
            Case #mud_GetPass To #mud_GetPass_fail2
              If a$
                If id
                  SetDatabaseLong(0,0,id)
                  SetDatabaseString(0,1,a$)
                  dbq(0,"select mob from usr where id=? and pass=?",ok=Val(getLine(0)))
                  If ok
                    SetDatabaseLong(0,0,id)
                    *c\state=#mud_Play
                    sendmessage(cl,"Logging you in."+#CRLF$)
                    SetDatabaseLong(0,0,cl)
                    SetDatabaseLong(0,1,id)
                    dbu(0,"update usr set state=? where id=?")
                    SetDatabaseLong(0,0,id)
                    SetDatabaseLong(0,1,ok)
                    dbu(0,"update mob set active=1,loc=(select loc from usr where id=?) where id=?")
                    *c\mob=ok
                    SetDatabaseLong(0,0,ok)
                    dbu(0,"insert into cmd(who,c1,c2) values(?,'look','room')")
                  Else
                    sendmessage(cl,"Password is incorrect, please try again: |")
                    *c\state+1
                  EndIf
                Else
                  *c\pass=a$
                  sendmessage(cl,"Please confirm your password: |")
                  *c\state=#mud_GetPass_confirm
                EndIf
              EndIf
            Case #mud_GetPass_fail3
              sendmessage(cl,"ERROR: Too many incorrect password attempts - disconnecting|")
              CloseNetworkConnection(cl)
              DeleteMapElement(client(),Str(cl))
            Case #mud_GetPass_confirm
              If *c\pass=a$
                dbq(0,"select name||' - '||desc from rac where id>5",r$=getAllLines(0,0))
                sendmessage(cl,"Password confirmed - what's your character's race?"+#CRLF$+r$+"Please Select: |")
                *c\state=#mud_GetRace
              Else
                sendmessage(cl,"Password and Confirmation don't match"+#CRLF$+"Please re-enter your password: |")
                *c\state=#mud_GetPass
              EndIf
            Case #mud_GetRace
              id=GetID(0,a$,"rac")
              If id
                *c\race=id
                *c\r=LCase(a$)
                *c\state=#mud_GetClass
                dbq(0,"select name||' - '||desc from cls where id>5",c$=getAllLines(0,0))
               
                sendmessage(cl,"Ok, your character will be "+aan(a$)+#CRLF$+"What's your character's profession?"+#CRLF$+c$+"Please select one: |")
              Else
                sendmessage(cl,"I don't recognise that race."+#CRLF$+"Please enter one from the list: |")
              EndIf
            Case #mud_GetClass
              id=GetID(0,a$,"cls")
              If id
                *c\class=id
                *c\c=a$
                *c\state=#mud_GetGend
                dbq(0,"select name||' ('||p1||'/'||p2||'/'||p3||')' from vgen",g$=getAllLines(0,0))
                sendmessage(cl,"Your character will be "+aan(a$)+#CRLF$+"Which gender describes your character?"+#CRLF$+g$+"Please select one: |")
              Else
                sendmessage(cl,"I don't recognise that profession."+#CRLF$+"Please enter one from the list: |")
              EndIf
            Case #mud_GetMobName
              id=GetID(0,a$,"mob")
              If id
                sendmessage(cl,"Looks like somebody is already called "+a$+"."+#CRLF$+"Please try a different name: |")
              Else
                *c\mname=a$
                *c\state=#mud_CreateMob
                m$=*c\mname+", "+aan(*c\g)+" "+*c\r+" "+*c\c
                sendmessage(cl,"Reviewing, your character will be:"+#CRLF$+m$+#CRLF$+"Does that sound Right (Y/N)? |")
             EndIf
            Case #mud_GetGend
              id=GetID(0,a$,"gen")
              If id
                *c\gend=id
                *c\g=LCase(a$)
                *c\state=#mud_GetMobName
                sendmessage(cl,"Your character is "+a$+#CRLF$+"What should we call you? |")
              Else
                sendmessage(cl,"I don't recognise that gender."+#CRLF$+"Please enter one from the list (or select agender for now, and PRAY to have your pronouns included)"+#CRLF$+"Please Select: |")
              EndIf
           Case #mud_CreateMob
             Select LCase(a$)
               Case "y","yes","oui","ja","o","j"
                 *c\mob=CreateMob(0,*c)
                 id=CreateUser(0,*c)
                 SetDatabaseLong(0,0,*c\mob)
                 dbu(0,"update mob set active=1 where id=?")
                 *c\state=#mud_Play
                 sendmessage(cl,"Character Created"+#CRLF$+#CRLF$)
                 SetDatabaseLong(0,0,*c\mob)
                 dbu(0,"insert into cmd(who,c1,c2) values(?,'look','room')")
               Case "n","no","non","nein"
                 *c\state=#mud_GetRace
                 dbq(0,"select name||' - '||desc from rac where id>5",r$=getAllLines(0,0))
                 sendmessage(cl,"Let's try again, then."+#CRLF$+"What is your character's race?"+#CRLF$+r$+"Please select one: |")
               Default
                 sendmessage(cl,"Only Y or N responses, please - try again: |")
             EndSelect
           Case #mud_Play
             ProcessCmd(*c,a$)
          EndSelect
        Default; #PB_NetworkEvent_None
      EndSelect
    Wend
    UnlockMutex(netloop)
  EndIf
EndProcedure

Procedure ProcessCmd(*c.cl,a$)
  who=*c\mob
  cl=*c\cl
  Dim c.s(0):wn=ExtractRegularExpression(0,a$,c())
  If *c\mode
    Select LCase(c(0))
      Case "switch"
        *c\mode=0
        a$="switching back to mota mode"+#CRLF$
      Case "select"
        dbq(0,a$,a$=getAllLines(0),a$="ERROR: "+DatabaseError())
      Default
        dbu(0,a$,a$="success",a$="ERROR: "+DatabaseError())
    EndSelect
    sendmessage(cl,a$)
  Else
    Dim b.s(0):ln=ExtractRegularExpression(2,a$,b())
    For i=0 To ln-1
      Dim c.s(0):wn=ExtractRegularExpression(0,b(i),c())
      Dim a.s(8):For j=0 To 8:If j<wn:a(j)=Trim(c(j),#DQUOTE$):Else:a(j)="":EndIf:Next
      Select LCase(a(0))
        Case "switch"
          If *c\ip=16777343
            sendmessage(cl,"switching to SQL mode"+#CRLF$)
            *c\mode=1
          Else
            sendmessage(cl,"SQL mode is restricted to local accounts"+#CRLF$)
          EndIf
        Default
          SetDatabaseLong(0,0,*c\mob)
          For j=0 To 8:SetDatabaseString(0,j+1,a(j)):Next
          dbu(0,"insert into cmd(who,c1,c2,c3,c4,c5,c6,c7,c8,c9) values(?,?,?,?,?,?,?,?,?,?)")
      EndSelect
    Next
  EndIf
EndProcedure
 
Procedure start()
  setupDB("mudfile.db")
EndProcedure

OpenWindow(0,0,0,800,600,"PureMota")
TextGadget(-1,5,5,90,20,"Global Tick"):EditorGadget(#mudtick,100,3,90,24,#PB_Editor_ReadOnly)
EditorGadget(#mudinfo,5,30,790,565,#PB_Editor_ReadOnly)

start()
LockMutex(netloop)
CreateThread(@netlisten(),8080)
CreateThread(@ticking(),0)
Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow
UnlockMutex(netloop)

_________________
there is no sig, only zuul (and the following disclaimer)

WARNING: may be talking out of his hat


Top
 Profile  
Reply with quote  
 Post subject: Re: SQL driven MUD
PostPosted: Mon Dec 03, 2018 12:22 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Feb 12, 2006 10:06 pm
Posts: 638
dbsetup.txt
Code:
#create table if not exists [1]([2])
last~label char primary key,id integer,error char
com_~id integer primary key autoincrement,tick integer,sent integer default 0,who integer,message char
log~id integer primary key autoincrement,tstamp char default current_timestamp,actioned integer,who integer,c1 char,c2 char,c3 char,c4 char,c5 char,c6 char,c7 char,c8 char,c9 char,ca char,cb char,cc char,cd char,ce char,cf char
obj~id integer primary key autoincrement,label char,name char,desc char,c1 char,v1 integer,v2 integer,v3 integer,v4 integer,v5 integer,v6 integer,v7 integer,v8 integer,v9 integer,va integer,vb integer,vv integer,vd integer,ve integer,vf integer
lst~i1 integer,i2 integer,c char,v integer
tick~id integer unique,tick integer
alias~id integer,alias char,alt char,primary key(id,alias)
validtarg~cmd char default '',target char default '',primary key(cmd,target)
#create view if not exists [1] as select [2]
com~tick,who,message from com_ order by id
aka~* from alias union select id,name,name from skl union select room,name,name from ext
mob~id,'' as who,name,desc,v1 as loc,v2 as class,v3 as race,v4 as level,v5 as gend,v6 as health,v7 as maxhealth,v8 as stats,v9 as active from obj where label='mob'
usr~id,'' as who,name,desc as pass,v1 as state,v2 as mob,v3 as loc from obj where label='usr'
efx~id,'' as who,name,desc from obj where label='efx'
rom~id,'' as who,name,desc from obj where label='rom'
cls~id,'' as who,name,desc from obj where label='cls'
rac~id,'' as who,name,desc from obj where label='rac'
pln~id,'' as who,name,desc,v1 as type,v2 as value,v3 as price from obj where label='pln'
itm~id,'' as who,name,desc,v1 as loc,v2 as plan,v3 as value,v4 as level,v5 as price,v6 as worn,v7 as durability from obj where label='itm'
gen~id,'' as who,name,v1 as p1,v2 as p2,v3 as p3 from obj where label='gen'
pno~id,'' as who,name from obj where label='pno'
stt~id,'' as who,name,desc from obj where label='stt'
skl~id,'' as who,name,desc,c1 as format,v1 as bonus from obj where label='skl'
skr~'' as who,i1 as race,i2 as skill,v as bonus from rac r,skl s,lst where i1=r.id and i2=s.id
skc~'' as who,i1 as class,i2 as skill,v as bonus from cls c,skl s,lst where i1=c.id and i2=s.id
skp~'' as who,i1 as plan,i2 as skill,v as strength from pln p,skl s,lst where i1=p.id and i2=s.id
ski~'' as who,i1 as item,i2 as skill,v as strength from itm i,skl s,lst where i1=i.id and i2=s.id
ske~'' as who,i1 as skill,i2 as effect,v as duration from efx e,skl s,lst where i1=s.id and i2=e.id
ext~'' as who,i1 as room,c as name,i2 as dest from rom r,rom d,lst where i1=r.id and i2=d.id
stb~'' as who,i1 as id,i2 as stat,v as value from rom r,rom d,lst where i1=r.id and i2=d.id
vgen~g.id,'' as who,g.name,n1.name as p1,n2.name as p2,n3.name as p3 from gen g,pno n1,pno n2,pno n3 where g.p1=n1.id and g.p2=n2.id and g.p3=n3.id
vskr~'' as who,race,k.skill,s.name,s.desc,k.bonus from skr k,skl s where k.skill=s.id
vskc~'' as who,class,k.skill,s.name,s.desc,k.bonus from skc k,skl s where k.skill=s.id
vskp~'' as who,plan,k.skill,s.name,s.desc,k.strength from skp k,skl s where k.skill=s.id
vski~'' as who,item,k.skill,s.name,s.desc,k.strength from ski k,skl s where k.skill=s.id
tskr~'' as who,r.name as race,s.name as skill,s.desc,k.bonus from skr k,rac r,skl s where k.skill=s.id and k.race=r.id
tskc~'' as who,c.name as class,s.name as skill,s.desc,k.bonus from skc k,cls c,skl s where k.skill=s.id and k.class=c.id
tskp~'' as who,p.name as plan,s.name as skill,s.desc,k.strength from skp k,pln p,skl s where k.skill=s.id and k.plan=p.id
tski~'' as who,i.name as item,s.name as skill,s.desc,k.strength from ski k,itm i,skl s where k.skill=s.id and k.item=i.id
cmd~who,c1,c2,c3,c4,c5,c6,c7,c8,c9,ca,cb,cc,cd,ce,cf from log
vinv~m.id as who,i.id as item,i.name,i.plan from mob m,itm i where i.loc=m.id
vinvfull~* from vinv union select m.id,i.id,i.id,i.plan from mob m,itm i where i.loc=m.id
vroommob~m.id as who,n.id as id,n.name from mob m,mob n where n.loc=m.loc and n.id<>m.id and n.active=1
vroommobfull~* from vroommob union select m.id,n.id,n.id from mob m,mob n where n.loc=m.loc and n.id<>m.id and n.active=1
vroomitm~m.id as who,n.id as id,n.name from mob m,itm n where n.loc=m.loc
vroomitmfull~* from vroomitm union select m.id,n.id,n.id from mob m,itm n where n.loc=m.loc
vroomext~m.id as who,e.room,e.name,e.dest,e.name as alt from mob m,ext e where m.loc=e.room
vromskl~m.id as who,s.id as skill,s.name,v as bonus from mob m,skl s,lst where i1=m.loc and i2=s.id
vmobskl~m.id as who,s.id as skill,s.name,v as bonus from mob m,skl s,lst where i1 in(0,2,3,m.class,m.race,m.id) and i2=s.id
vitmskl~m.id as who,s.id as skill,s.name,v as bonus from mob m,skl s,lst,vinv i where i1 in(i.item,i.plan) and i2=s.id and i.who=m.id
validcmds~* from vmobskl union select * from vitmskl union select * from vromskl union select who,room,name,dest from vroomext
aliascmds~who,skill,name,bonus from validcmds union select who,skill,alias,bonus from validcmds,aka where alt like(name)
vcml~distinct v.who,v.skill,v.name,(select sum(v0.bonus) from validcmds v0 where v0.skill=v.skill and v0.who=v.who) as bonus from aliascmds v
validtarget~cmd,target from validtarg union select alias,target from validtarg,aka where cmd like(alt) union select t.name,'' from validtarg,mob w,ext t where room=w.loc union select alias,'' from validtarg,mob w,ext t,aka where room=w.loc and t.name like(alt)
validtargets~distinct id as who,cmd,target from validtarget,mob w where cmd not in('@exit') and target not in('@gmob','@mob','@item','@user','@plan','@exit','@room','@gender','@race','@class','@pronoun','@skill','@effect') and exists(select 1 from vcml where name like(cmd) and who=w.id) union select distinct w.id,cmd,t.name from validtarget,mob w,vroommobfull t where w.id=t.who and target='@mob' and exists(select 1 from vcml where name like(cmd) and who=w.id) union select distinct w.id,cmd,t.name from validtarget,mob w,usr t where target='@user' and t.state<>0 and exists(select 1 from vcml where name like(cmd) and who=w.id) union select distinct w.id,cmd,t.name from validtarget,mob w,pln t where target='@plan' and exists(select 1 from vcml where name like(cmd) and who=w.id) union select distinct w.id,cmd,t.id from validtarget,mob w,pln t where target='@plan' and exists(select 1 from vcml where name like(cmd) and who=w.id) union select distinct w.id,cmd,t.id from validtarget,mob w,rom t where target='@room' and exists(select 1 from vcml where name like(cmd) and who=w.id) union select distinct w.id,cmd,t.id from validtarget,mob w,mob t where target='@gmob' and exists(select 1 from vcml where name like(cmd) and who=w.id) union select distinct w.id,cmd,t.id from validtarget,mob w,gen t where target='@gend' and exists(select 1 from vcml where name like(cmd) and who=w.id) union select distinct w.id,cmd,t.id from validtarget,mob w,pno t where target='@pronoun' and exists(select 1 from vcml where name like(cmd) and who=w.id) union select distinct w.id,cmd,t.id from validtarget,mob w,rac t where target='@race' and exists(select 1 from vcml where name like(cmd) and who=w.id) union select distinct w.id,cmd,t.id from validtarget,mob w,cls t where target='@class' and exists(select 1 from vcml where name like(cmd) and who=w.id) union select distinct w.id,cmd,t.name from validtarget,mob w,efx t where target='@effect' and exists(select 1 from vcml where name like(cmd) and who=w.id) union select distinct w.id,cmd,t.name from validtarget,mob w,skl t where target='@skill' and exists(select 1 from vcml where name like(cmd) and who=w.id) union select distinct w.id,t.name,'' from validtarget,mob w,ext t where cmd='@exit' and room=w.loc union select distinct w.id,cmd,t.name from validtarget,mob w,ext t where target='@exit' and room=w.loc and exists(select 1 from vcml where name like(cmd) and who=w.id) union select distinct w.id,cmd,t.name from validtarget,mob w,vroomitmfull t where target='@item' and w.id=t.who and exists(select 1 from vcml where name like(cmd) and who=w.id) union select distinct w.id,cmd,t.name from validtarget,mob w,vinvfull t where target='@item' and w.id=t.who and exists(select 1 from vcml where name like(cmd) and who=w.id)
#create trigger if not exists [1] [2] [3]
comsok~instead of~insert on com when new.message<>'' begin insert into com_(tick,sent,who,message) values(new.tick,0,new.who,new.message);end;
comsnok~instead of~insert on com when new.message='' begin select 1;end;
addaka1~instead of~insert on aka when exists(select 1 from ext where name like(new.alt)) begin insert or ignore into alias select 0,new.alias,name from ext where name like(new.alt);end;
addaka2~instead of~insert on aka when exists(select 1 from skl where name like(new.alt)) begin insert or ignore into alias select id,new.alias,name from skl where name like(new.alt);end;
addaka3~instead of~insert on aka when exists(select 1 from mob where name like(new.alt)) begin insert or ignore into alias select id,new.alias,name from mob where name like(new.alt);end;
addaka4~instead of~insert on aka when exists(select 1 from itm where name like(new.alt)) begin insert or ignore into alias select id,new.alias,name from itm where name like(new.alt);end;
lastobj~after~insert on obj begin insert or replace into last(label,id,error) values(new.label,new.id,'');end;
newmob0~instead of~insert on mob begin insert into com(tick,who,message) select tick+1,new.who,'new mob "'||new.name||'" created' from tick;end;
newmob1~instead of~insert on mob when coalesce(new.desc,' ')<>' ' begin insert into obj(label,name,desc,v1,v2,v3,v4,v5,v6,v7,v8) values('mob',new.name,new.desc,new.loc,new.class,new.race,new.level,new.gend,new.health,new.maxhealth,new.stats);end;
newmob2~instead of~insert on mob when coalesce(new.desc,' ')=' ' begin insert into obj(label,name,desc,v1,v2,v3,v4,v5,v6,v7,v8) values('mob',new.name,'a non-descript person',new.loc,new.class,new.race,new.level,new.gend,new.health,new.maxhealth,new.stats);end;
newusr1~instead of~insert on usr begin insert into obj(label,name,desc,v1,v2) values('usr',new.name,new.pass,new.state,new.mob);insert into com(tick,who,message) select tick+1,new.who,'new user "'||new.name||'" created' from tick;end;
newefx1~instead of~insert on efx begin insert into obj(label,name,desc) values('efx',new.name,new.desc);insert into com(tick,who,message) select tick+1,new.who,'new effect "'||new.name||'" created' from tick;end;
newrom1~instead of~insert on rom begin insert into obj(label,name,desc) values('rom',new.name,new.desc);insert into com(tick,who,message) select tick+1,new.who,'new room "'||new.name||'" created' from tick;end;
newcls1~instead of~insert on cls begin insert into obj(label,name,desc) values('cls',new.name,new.desc);insert into com(tick,who,message) select tick+1,new.who,'new class "'||new.name||'" created' from tick;end;
newrac1~instead of~insert on rac begin insert into obj(label,name,desc) values('rac',new.name,new.desc);insert into com(tick,who,message) select tick+1,new.who,'new race "'||new.name||'" created' from tick;end;
newpln1~instead of~insert on pln begin insert into obj(label,name,desc,v1,v2,v3) values('pln',new.name,new.desc,new.type,new.value,new.price);insert into com(tick,who,message) select tick+1,new.who,'new item template "'||new.name||'" created' from tick;end;
newitm1~instead of~insert on itm begin insert into obj(label,name,desc,v1,v2,v3,v4,v5) values('itm',new.name,new.desc,new.loc,new.plan,new.level,new.value,new.price);insert into com(tick,who,message) select tick+1,new.who,'new item "'||new.name||'" created from template "'||p.name||'"' from tick,pln p where p.id=new.plan;end;
newgen1~instead of~insert on gen begin insert into obj(label,name,v1,v2,v3) values('gen',new.name,new.p1,new.p2,new.p3);insert into com(tick,who,message) select tick+1,new.who,'new gender "'||new.name||'" created' from tick;end;
newpno1~instead of~insert on pno begin insert into obj(label,name) values('pno',new.name);insert into com(tick,who,message) select tick+1,new.who,'new pronoun "'||new.name||'" created' from tick;end;
newstt1~instead of~insert on stt begin insert into obj(label,name,desc) values('stt',new.name,new.desc);insert into com(tick,who,message) select tick+1,new.who,'new stat "'||new.name||'" created' from tick;end;
newskl1~instead of~insert on skl begin insert into obj(label,name,desc,c1) values('skl',new.name,new.desc,new.format);insert into com(tick,who,message) select tick+1,new.who,'new skill "'||new.name||'" created' from tick;end;
newskr1~instead of~insert on skr begin insert into lst(i1,i2,v) values(new.race,new.skill,new.bonus);insert into com(tick,who,message) select tick+1,new.who,'skill "'||s.name||'" added to race "'||r.name||'" skill list' from tick,skl s,rac r where s.id=new.skill and r.id=new.race;end;
newskc1~instead of~insert on skc begin insert into lst(i1,i2,v) values(new.class,new.skill,new.bonus);insert into com(tick,who,message) select tick+1,new.who,'skill "'||s.name||'" added to class "'||c.name||'" skill list' from tick,skl s,cls c where s.id=new.skill and c.id=new.class;end;
newskp1~instead of~insert on skp begin insert into lst(i1,i2,v) values(new.plan,new.skill,new.strength);insert into com(tick,who,message) select tick+1,new.who,'skill "'||s.name||'" added to template "'||p.name||'" skill list' from tick,skl s,pln p where s.id=new.skill and p.id=new.plan;end;
newski1~instead of~insert on ski begin insert into lst(i1,i2,v) values(new.item,new.skill,new.strength);insert into com(tick,who,message) select tick+1,new.who,'skill "'||s.name||'" added to item "'||i.name||'" skill list' from tick,skl s,itm i where s.id=new.skill and i.id=new.item;end;
newske1~instead of~insert on ske begin insert into lst(i1,i2,v) values(new.skill,new.effect,new.duration);insert into com(tick,who,message) select tick+1,new.who,'effect "'||e.name||'" added to skill "'||s.name||'"' from tick,skl s,efx e where s.id=new.skill and e.id=new.effect;end;
newext1~instead of~insert on ext when exists(select 1 from ext where room=new.room and name=new.name) begin insert into com(tick,who,message) select tick+1,new.who,'exit "'||new.name||'" already exists' from tick;end;
newext2~instead of~insert on ext when not exists(select 1 from ext where room=new.room and name=new.name) begin insert into lst(i1,c,i2) values(new.room,new.name,new.dest);insert into com(tick,who,message) select tick+1,new.who,'new exit "'||new.name||'" created' from tick;end;
modmob1~instead of~update of loc on mob begin update obj set name=old.name,desc=old.desc,v1=new.loc,v2=old.class,v3=old.race,v4=old.level,v5=old.gend,v6=old.health,v7=old.maxhealth,v8=old.stats,v9=old.active where id=old.id;insert into com(tick,who,message) select tick+1,old.who,'mob '||old.name||' location updated' from tick;end;
modmob2~instead of~update of class on mob begin update obj set name=old.name,desc=old.desc,v1=old.loc,v2=new.class,v3=old.race,v4=old.level,v5=old.gend,v6=old.health,v7=old.maxhealth,v8=old.stats,v9=old.active where id=old.id;insert into com(tick,who,message) select tick+1,old.who,'mob '||old.name||' class updated' from tick;end;
modmob3~instead of~update of race on mob begin update obj set name=old.name,desc=old.desc,v1=old.loc,v2=old.class,v3=new.race,v4=old.level,v5=old.gend,v6=old.health,v7=old.maxhealth,v8=old.stats,v9=old.active where id=old.id;insert into com(tick,who,message) select tick+1,old.who,'mob '||old.name||' race updated' from tick;end;
modmob4~instead of~update of level on mob begin update obj set name=old.name,desc=old.desc,v1=old.loc,v2=old.class,v3=old.race,v4=new.level,v5=old.gend,v6=old.health,v7=old.maxhealth,v8=old.stats,v9=old.active where id=old.id;insert into com(tick,who,message) select tick+1,old.who,'mob '||old.name||' level updated' from tick;end;
modmob5~instead of~update of gend on mob begin update obj set name=old.name,desc=old.desc,v1=old.loc,v2=old.class,v3=old.race,v4=old.level,v5=new.gend,v6=old.health,v7=old.maxhealth,v8=old.stats,v9=old.active where id=old.id;insert into com(tick,who,message) select tick+1,old.who,'mob '||old.name||' gender updated' from tick;end;
modmob6~instead of~update of health on mob begin update obj set name=old.name,desc=old.desc,v1=old.loc,v2=old.class,v3=old.race,v4=old.level,v5=old.gend,v6=new.health,v7=old.maxhealth,v8=old.stats,v9=old.active where id=old.id;insert into com(tick,who,message) select tick+1,old.who,'mob '||old.name||' health updated' from tick;end;
modmob7~instead of~update of maxhealth on mob begin update obj set name=old.name,desc=old.desc,v1=old.loc,v2=old.class,v3=old.race,v4=old.level,v5=old.gend,v6=old.health,v7=new.maxhealth,v8=old.stats,v9=old.active where id=old.id;insert into com(tick,who,message) select tick+1,old.who,'mob '||old.name||' max health updated' from tick;end;
modmob8~instead of~update of stats on mob begin update obj set name=old.name,desc=old.desc,v1=old.loc,v2=old.class,v3=old.race,v4=old.level,v5=old.gend,v6=old.health,v7=old.maxhealth,v8=new.stats,v9=old.active where id=old.id;insert into com(tick,who,message) select tick+1,old.who,'mob '||old.name||' stats updated' from tick;end;
modmob9~instead of~update of active on mob begin update obj set name=old.name,desc=old.desc,v1=old.loc,v2=old.class,v3=old.race,v4=old.level,v5=old.gend,v6=old.health,v7=old.maxhealth,v8=old.stats,v9=new.active where id=old.id;insert into com(tick,who,message) select tick+1,old.who,'mob '||old.name||' activation updated' from tick;end;
modmoba~instead of~update of name on mob begin update obj set name=new.name,desc=old.desc,v1=old.loc,v2=old.class,v3=old.race,v4=old.level,v5=old.gend,v6=old.health,v7=old.maxhealth,v8=old.stats,v9=old.active where id=old.id;insert into com(tick,who,message) select tick+1,old.who,'mob '||old.name||' name updated' from tick;end;
modmobb~instead of~update of desc on mob begin update obj set name=old.name,desc=new.desc,v1=old.loc,v2=old.class,v3=old.race,v4=old.level,v5=old.gend,v6=old.health,v7=old.maxhealth,v8=old.stats,v9=old.active where id=old.id;insert into com(tick,who,message) select tick+1,old.who,'mob '||old.name||' description updated' from tick;end;
modusr1~instead of~update on usr begin update obj set name=new.name,desc=new.pass,v1=new.state,v2=new.mob,v3=new.loc where id=old.id;insert into com(tick,who,message) select tick+1,new.who,'user "'||old.name||'" updated' from tick;end;
modrom1~instead of~update on rom begin update obj set name=new.name,desc=new.desc where id=old.id;insert into com(tick,who,message) select tick+1,new.who,'room "'||old.name||'" updated' from tick;end;
modcls1~instead of~update on cls begin update obj set name=new.name,desc=new.desc where id=old.id;insert into com(tick,who,message) select tick+1,new.who,'class "'||old.name||'" updated' from tick;end;
modrac1~instead of~update on rac begin update obj set name=new.name,desc=new.desc where id=old.id;insert into com(tick,who,message) select tick+1,new.who,'race "'||old.name||'" updated' from tick;end;
modpln1~instead of~update on pln begin update obj set name=new.name,desc=new.desc where id=old.id;insert into com(tick,who,message) select tick+1,new.who,'template "'||old.name||'" updated' from tick;end;
moditm1~instead of~update on itm begin update obj set name=new.name,desc=new.desc,v1=new.loc,v2=new.plan,v3=new.level,v4=new.value,v5=new.price where id=old.id;insert into com(tick,who,message) select tick+1,new.who,'item "'||old.name||'" updated' from tick;end;
modgen1~instead of~update on gen begin update obj set name=new.name,desc=new.desc,v1=new.p1,v2=new.p2,v3=new.p3 where id=old.id;insert into com(tick,who,message) select tick+1,new.who,'gender "'||old.name||'" updated' from tick;end;
modpno1~instead of~update on pno begin update obj set name=new.name,desc=new.desc where id=old.id;insert into com(tick,who,message) select tick+1,new.who,'item "'||old.name||'" updated' from tick;end;
newvsr~instead of~insert on vskr begin insert into skr(who,race,skill,bonus) values(new.who,new.race,new.skill,new.bonus);end;
newvsc~instead of~insert on vskc begin insert into skc(who,class,skill,bonus) values(new.who,new.class,new.skill,new.bonus);end;
newvsp~instead of~insert on vskp begin insert into skp(who,plan,skill,strength) values(new.who,new.plan,new.skill,new.strength);end;
newvsi~instead of~insert on vski begin insert into ski(who,item,skill,strength) values(new.who,new.item,new.skill,new.strength);end;
newvg0~instead of~insert on vgen when not exists(select 1 from gen where name=new.name) begin insert into gen(name) values(new.name);end;
newvg1~instead of~insert on vgen when not exists(select 1 from pno where name=new.p1) begin insert into pno(name) values(new.p1);end;
newvg2~instead of~insert on vgen when not exists(select 1 from pno where name=new.p2) begin insert into pno(name) values(new.p2);end;
newvg3~instead of~insert on vgen when not exists(select 1 from pno where name=new.p3) begin insert into pno(name) values(new.p3);end;
newvgn~instead of~insert on vgen begin insert into lst(i1,i2) select g.id,p.id from gen g,pno p where g.name=new.name and p.name=new.p1;insert into lst(i1,i2) select g.id,p.id from gen g,pno p where g.name=new.name and p.name=new.p2;insert into lst(i1,i2) select g.id,p.id from gen g,pno p where g.name=new.name and p.name=new.p3;end;
cmdlog~instead of~insert on cmd when exists(select 1 from validtargets where new.c1 like(cmd) and (new.c2 like(target) or target like('any'))) begin insert into log(actioned,who,c1,c2,c3,c4,c5,c6,c7,c8,c9,ca,cb,cc,cd,ce,cf) select 0,new.who,alt,new.c2,new.c3,new.c4,new.c5,new.c6,new.c7,new.c8,new.c9,new.ca,new.cb,new.cc,new.cd,new.ce,new.cf from aka where alias like(new.c1);end;
nocmdlog~instead of~insert on cmd when not exists(select 1 from validtargets where new.c1 like(cmd) and (new.c2 like(target) or target like('any'))) begin insert into com(tick,who,message) select tick+1,new.who,'"'||new.c1||' '||new.c2||'" is an unrecognised command' from tick;end;
insvaltarg~instead of~insert on validtarget begin insert into validtarg values(new.cmd,new.target);end;
cmdnewmob~after~insert on log when new.c1 like('new') and new.c2 like('mob') begin insert into mob(who,name,desc,loc,class,race,gend,level) select new.who,new.c3,new.c4,m.loc,c.id,r.id,g.id,new.c8 from mob m,rac r,cls c,gen g where m.id=new.who and new.c5 in(c.id,c.name) and new.c6 in(r.id,r.name) and new.c7 in(g.id,g.name);end;
cmdnewefx~after~insert on log when new.c1 like('new') and new.c2 like('effect') begin insert into efx(who,name,desc) select new.who,new.c3,new.c4 where not exists(select 1 from efx where name like(new.c3));end;
cmdnewrom~after~insert on log when new.c1 like('new') and new.c2 like('room') begin insert into rom(who,name,desc) values(new.who,new.c3,new.c4);end;
cmdnewcls~after~insert on log when new.c1 like('new') and new.c2 like('class') begin insert into cls(who,name,desc) select new.who,new.c3,new.c4 where not exists(select 1 from cls where name like(new.c3));end;
cmdnewrac~after~insert on log when new.c1 like('new') and new.c2 like('race') begin insert into rac(who,name,desc) select new.who,new.c3,new.c4 where not exists(select 1 from rac where name like(new.c3));end;
cmdnewgen~after~insert on log when new.c1 like('new') and new.c2 like('gender') begin insert into pno(who,name) select new.who,new.c4 where not exists(select 1 from pno where name like(new.c4));insert into pno(who,name) select new.who,new.c5 where not exists(select 1 from pno where name like(new.c5));insert into pno(who,name) select new.who,new.c6 where not exists(select 1 from pno where name like(new.c6));insert into gen(who,name,p1,p2,p3) select new.who,new.c3,p1.id,p2.id,p3.id from pno p1,pno p2,pno p3 where not exists(select 1 from gen where name like(new.c3)) and p1.name like(new.c4) and p2.name like(new.c5) and p3.name like(new.c6);end;
cmdnewpno~after~insert on log when new.c1 like('new') and new.c2 like('pronoun') begin insert into pno(who,name) select new.who,new.c3 where not exists(select 1 from pno where name like(new.c3));end;
cmdnewstt~after~insert on log when new.c1 like('new') and new.c2 like('stat') begin insert into stt(who,name,desc) select new.who,new.c3,new.c4 where not exists(select 1 from stt where name like(new.c3));end;
cmdnewskl~after~insert on log when new.c1 like('new') and new.c2 like('skill') begin insert into skl(who,name,desc,format) select new.who,new.c3,new.c4,new.c5 where not exists(select 1 from skl where name like(new.c3));end;
cmdnewskc~after~insert on log when new.c1 like('new') and new.c2 like('cskill') begin insert into vskc(who,class,skill,bonus) select new.who,c.id,s.id,new.c5 from skl s,cls c where new.c3 in(c.id,c.name) and new.c4 in(s.id,s.name);end;
cmdnewskr~after~insert on log when new.c1 like('new') and new.c2 like('rskill') begin insert into vskr(who,race,skill,bonus) select new.who,r.id,s.id,new.c5 from skl s,rac r where new.c3 in(r.id,r.name) and new.c4 in(s.id,s.name);end;
cmdnewskp~after~insert on log when new.c1 like('new') and new.c2 like('pskill') begin insert into vskp(who,plan,skill,strength) select new.who,p.id,s.id,new.c5 from skl s,pln p where new.c3 in(p.id,p.name) and new.c4 in(s.id,s.name);end;
cmdnewski~after~insert on log when new.c1 like('new') and new.c2 like('iskill') begin insert into vski(who,item,skill,strength) select new.who,i.id,s.id,new.c5 from skl s,itm i where new.c3 in(i.id,i.name) and new.c4 in(s.id,s.name);end;
cmdnewex1~after~insert on log when new.c1 like('new') and new.c2 like('exit') begin insert into ext(who,room,name,dest) select new.who,loc,new.c3,new.c4 from mob m where m.id=new.who and not exists(select 1 from ext where name=new.c4);end;
cmdnewex2~after~insert on log when new.c1 like('new') and new.c2 like('exit') and new.c5<>'' begin insert into ext(who,room,name,dest) select new.who,loc,new.c3,new.c4 from mob m where m.id=new.who and not exists(select 1 from ext where name=new.c3 and room=loc);insert into ext(who,room,name,dest) select new.who,new.c4,new.c5,loc from mob m where m.id=new.who and not exists(select 1 from ext where name=new.c5 and room=new.c4);end;
cmdnewtmp~after~insert on log when new.c1 like('new') and new.c2 like('template') begin insert into pln(who,name,desc,type,value,price) select new.who,new.c3,new.c4,new.c5,new.c6,new.c7 where not exists(select 1 from pln where name=new.c3);end;
cmdnewpln~after~insert on log when new.c1 like('new') and new.c2 like('plan') begin insert into pln(who,name,desc,type,value,price) select new.who,new.c3,new.c4,new.c5,new.c6,new.c7 where not exists(select 1 from pln where name=new.c3);end;
cmdnewit1~after~insert on log when new.c1 like('new') and new.c2 like('item') begin insert into itm(who,loc,name,desc,plan,level,value,price) select new.who,new.who,new.c3,new.c5,id,new.c6,new.c7,new.c8 from pln where (new.c4=id or name like(new.c4));insert into com(tick,who,message) select tick+1,new.who,'trying to add an item "'||new.c3||'"' from tick;end;
cmdnewit2~after~insert on log when new.c1 like('new') and (new.c2 in(select name from pln) or new.c2 in(select id from pln)) begin insert into itm(who,loc,name,desc,plan,level,value,price) select new.who,new.who,new.c3,new.c4,id,new.c5,new.c6,new.c7 from pln where (new.c2=id or name like(new.c2));insert into com(tick,who,message) select tick+1,new.who,'trying to add a '||new.c2||' "'||new.c3||'"' from tick;end;
cmdlistall~after~insert on log when new.c1 like('list') and (new.c2 like('all') or new.c2='') begin insert into com(tick,who,message) select tick+1,new.who,label||' '||name||'('||t.id||')' from tick,obj t order by label,t.id;end;
cmdlistext~after~insert on log when new.c1 like('list') and (new.c2 like('exits') or new.c2 like('exit')) begin insert into com(tick,who,message) select tick+1,new.who,name||' - connects rooms '||room||' and '||dest from ext t,tick;end;
cmdlistrom~after~insert on log when new.c1 like('list') and (new.c2 like('rooms') or new.c2 like('room')) begin insert into com(tick,who,message) select tick+1,new.who,name||'('||t.id||')' from rom t,tick;end;
cmdlistpln~after~insert on log when new.c1 like('list') and (new.c2 like('plans') or new.c2 like('templates') or new.c2 like('template') or new.c2 like('plan')) begin insert into com(tick,who,message) select tick+1,new.who,name||'('||t.id||')' from pln t,tick;end;
cmdlistitm~after~insert on log when new.c1 like('list') and (new.c2 like('items') or new.c2 like('item')) begin insert into com(tick,who,message) select tick+1,new.who,name||'('||t.id||')' from itm t,tick;end;
cmdlistmob~after~insert on log when new.c1 like('list') and (new.c2 like('mobs') or new.c2 like('mob')) begin insert into com(tick,who,message) select tick+1,new.who,name||'('||t.id||')' from mob t,tick;end;
cmdlistusr~after~insert on log when new.c1 like('list') and (new.c2 like('users') or new.c2 like('user')) begin insert into com(tick,who,message) select tick+1,new.who,name||'('||t.id||')' from usr t,tick;end;
cmdlistrac~after~insert on log when new.c1 like('list') and (new.c2 like('races') or new.c2 like('race')) begin insert into com(tick,who,message) select tick+1,new.who,name||'('||t.id||')' from rac t,tick where t.id>3;end;
cmdlistcls~after~insert on log when new.c1 like('list') and (new.c2 like('classes') or new.c2 like('class')) begin insert into com(tick,who,message) select tick+1,new.who,name||'('||t.id||')' from cls t,tick where t.id>3;end;
cmdlistgen~after~insert on log when new.c1 like('list') and (new.c2 like('genders') or new.c2 like('gender')) begin insert into com(tick,who,message) select tick+1,new.who,name||'('||t.id||') - '||p1||'/'||p2||'/'||p3 from vgen t,tick;end;
cmdlistskl~after~insert on log when new.c1 like('list') and (new.c2 like('skills') or new.c2 like('skill')) begin insert into com(tick,who,message) select tick+1,new.who,name||'('||t.id||')' from skl t,tick;end;
cmdhelp1~after~insert on log when new.c1 like('help') and not exists(select 1 from vmobskl s,vitmskl i where (s.who=new.who and new.c2 like(s.name)) or (i.who=new.who and new.c2 like(i.name))) begin insert into com(tick,who,message) select tick+1,new.who,s.name||' - '||desc from vmobskl v,skl s,tick where v.who=new.who and s.id=skill union select tick+1,new.who,s.name||' - '||desc from vitmskl v,skl s,tick where v.who=new.who and s.id=skill;end;
cmdhelp2~after~insert on log when new.c1 like('help') and exists(select 1 from vmobskl s,vitmskl i where (s.who=new.who and new.c2 like(s.name)) or (i.who=new.who and new.c2 like(i.name))) begin insert into com(tick,who,message) select tick+1,new.who,s.name||' - '||desc from skl s,tick where s.name like(new.c2);insert into com(tick,who,message) select tick+1,new.who,format from skl s,tick where s.name like(new.c2);end;
cmdadd0~after~insert on log when new.c1 like('add') and new.c2 like('effect') begin insert into ske(who,skill,effect,duration) select new.who,s.id,e.id,new.c5 from skl s,efx e where new.c4 in(s.id,s.name) and new.c3 in(e.id,e.name);end;
cmdadd1~after~insert on log when new.c1 like('add') and (new.c2 in(select name from efx) or new.c2 in(select id from efx)) begin insert into ske(who,skill,effect,duration) select new.who,s.id,e.id,new.c5 from skl s,efx e where new.c3 in(s.id,s.name) and new.c2 in(e.id,e.name);end;
cmdlookroom~after~insert on log when new.c1 like('look') and (new.c2='' or new.c2=null or new.c2 like('room')) begin insert into com(tick,who,message) select tick+1,new.who,'you look around' from tick; insert into com(tick,who,message) select tick+1,new.who,r.name from tick,rom r,mob m where m.id=new.who and r.id=m.loc; insert into com(tick,who,message) select tick+1,new.who,r.desc from tick,rom r,mob m where m.id=new.who and r.id=m.loc; insert into com(tick,who,message) select tick+1,new.who,case when exists(select 1 from ext e where e.room=m.loc) then 'visible exits:' else 'visible exits: none' end from tick,mob m where m.id=new.who; insert into com(tick,who,message) select distinct tick+1,new.who,e.name from tick,ext e,mob m where m.id=new.who and e.room=m.loc; insert into com(tick,who,message) select tick+1,new.who,'on the ground, you can see:' from tick,mob m where m.id=new.who and exists(select 1 from itm i where i.loc=m.loc); insert into com(tick,who,message) select distinct tick+1,new.who,(select count(*) from itm j where j.name like(i.name) and j.loc=i.loc)||' '||i.name from tick,itm i,mob m where m.id=new.who and i.loc=m.loc; insert into com(tick,who,message) select tick+1,new.who,'visiting the area, you can see: ' from tick,mob m where m.id=new.who and exists(select 1 from vroommob where who=new.who); insert into com(tick,who,message) select tick+1,new.who,''||v.name from tick,vroommob v where v.who=new.who;end;
cmdlookmob~after~insert on log when new.c1 like('look') and exists(select name from vroommobfull where who=new.who and name like(new.c2)) begin insert into com (tick,who,message) select tick+1,r.id,m.name||' looks at '||n.name from tick,mob m,vroommob n,vroommob r where m.id=new.who and n.who=new.who and r.who=new.who and (new.c2 like(n.name) or new.c2=n.id) and r.id<>n.id and r.id<>m.id; insert into com (tick,who,message) select tick+1,n.id,m.name||' looks at you' from tick,vroommob n,mob m where m.id=new.who and n.who=new.who and (new.c2 like(n.name) or new.c2=n.id); insert into com (tick,who,message) select tick+1,new.who,'you look at '||n.name from tick,vroommob n where n.who=new.who and (new.c2 like(n.name) or new.c2=n.id); insert into com (tick,who,message) select tick+1,new.who,n.name from tick,vroommob n where n.who=new.who and (new.c2 like(n.name) or new.c2=n.id); insert into com (tick,who,message) select tick+1,new.who,t.desc from tick,vroommob n,mob t where n.who=new.who and (new.c2 like(n.name) or new.c2=n.id) and n.id=t.id; insert into com (tick,who,message) select tick+1,new.who,'a level '||t.level||' '||g.name||' '||r.name||' '||c.name from tick,vroommob n,mob t,gen g,rac r,cls c where t.race=r.id and t.gend=g.id and t.class=c.id and n.who=new.who and (new.c2 like(n.name) or new.c2=n.id) and n.id=t.id;end;
cmdlookitem~after~insert on log when new.c1 like('look') and exists(select name from vroomitmfull where who=new.who and name like(new.c2)) begin insert into com (tick,who,message) select tick+1,new.who,'you look at the '||new.c2 from tick; insert into com (tick,who,message) select tick+1,r.id,m.name||' looks at the '||n.name||' on the floor' from tick,mob m,vroomitm n,vroommob r where m.id=new.who and n.who=new.who and r.who=new.who and r.id<>new.who and (new.c2 like(n.name) or new.c2=n.id); insert into com (tick,who,message) select tick+1,new.who,n.name from tick,vroomitm n where n.who=new.who and (new.c2 like(n.name) or new.c2=n.id); insert into com (tick,who,message) select tick+1,new.who,t.desc from tick,vroomitm n,itm t where n.who=new.who and (new.c2 like(n.name) or new.c2=n.id) and t.id=n.id;end;
cmdlookself~after~insert on log when new.c1 like('look') and (new.c2 like('me') or new.c2 like('self')) begin insert into com (tick,who,message) select tick+1,r.id,m.name||' checks '||p.name||'self out' from tick,mob m,gen g,pno p,vroommob r where m.id=new.who and g.id=m.gend and p.id=g.p2 and r.who=new.who and r.id<>m.id; insert into com (tick,who,message) select tick+1,new.who,'you examine yourself' from tick; insert into com (tick,who,message) select tick+1,new.who,m.name from tick,mob m where m.id=new.who; insert into com (tick,who,message) select tick+1,new.who,m.desc from tick,mob m where m.id=new.who; insert into com (tick,who,message) select tick+1,new.who,'a level '||t.level||' '||g.name||' '||r.name||' '||c.name from tick,mob t,gen g,rac r,cls c where t.id=new.who and g.id=t.gend and r.id=t.race and c.id=t.class; insert into com (tick,who,message) select tick+1,new.who,k.name||' '||s.value from tick,stt k,stb s where s.id=new.who and k.id=s.stat;end;
cmdlookinv~after~insert on log when new.c1 like('look') and exists(select name from vinvfull where who=new.who and name like(new.c2)) begin insert into com (tick,who,message) select tick+1,new.who,'you look at your '||new.c2 from tick; insert into com (tick,who,message) select tick+1,r.id,m.name||' examines something in '||v.p3||' backpack' from tick,mob m,vgen v,vroommob r where m.id=new.who and v.id=m.gend and r.who=new.who; insert into com (tick,who,message) select tick+1,new.who,n.name from tick,vinv n where n.who=new.who and (new.c2 like(n.name) or new.c2=n.item); insert into com (tick,who,message) select tick+1,new.who,t.desc from tick,vinv n,itm t where n.who=new.who and (new.c2 like(n.name) or new.c2=n.item) and t.id=n.item;end;
cmdinv1~after~insert on log when new.c1 like('inv') begin insert into com (tick,who,message) select tick+1,new.who,'you look through your backpack ' from tick; insert into com (tick,who,message) select tick+1,r.id,m.name||' rummages through '||v.p3||' backpack' from tick,mob m,vgen v,vroommob r where m.id=new.who and v.id=m.gend and r.who=new.who; insert into com(tick,who,message) select distinct tick+1,new.who,(select count(*) from itm j where j.name like(i.name) and j.loc=i.loc)||' '||i.name from tick,itm i,mob m where m.id=new.who and i.loc=new.who;end;
cmdget1~after~insert on log when new.c1 like('get') and exists(select name from vroomitmfull where who=new.who and name like(new.c2)) begin insert into com (tick,who,message) select tick+1,new.who,'you collect the '||new.c2||' from the ground.' from tick; insert into com (tick,who,message) select tick+1,r.id,m.name||' grabs the '||n.name||' from the floor' from tick,mob m,vroomitm n,vroommob r where m.id=new.who and n.who=new.who and r.who=new.who and r.id<>new.who and (new.c2 like(n.name) or new.c2=n.id); update obj set v1=new.who where id=(select id from vroomitmfull where who=new.who and name like(new.c2));end;
cmddrop1~after~insert on log when new.c1 like('drop') and exists(select name from vinv where who=new.who and name like(new.c2)) begin update obj set v1=(select loc from mob where id=new.who) where id=(select item from vinv where who=new.who and name like(new.c2)); insert into com (tick,who,message) select tick+1,new.who,'you place the '||new.c2||' on the ground.' from tick; insert into com (tick,who,message) select tick+1,r.id,m.name||' drops a '||n.name||' to the floor' from tick,mob m,vroomitm n,vroommob r where m.id=new.who and n.who=new.who and r.who=new.who and r.id<>new.who and (new.c2 like(n.name) or new.c2=n.id);end;
cmdgive1~after~insert on log when new.c1 like('give') and exists(select name from vinv where who=new.who and name like(new.c2)) and exists(select name from vroommobfull where who=new.who and name like(new.c3)) begin update obj set v1=(select id from vroommobfull where name like(new.c3) and who=new.who) where id=(select item from vinv where who=new.who and name like(new.c2)); insert into com (tick,who,message) select tick+1,new.who,'you give your '||new.c2||' to '||new.c3||'.' from tick; insert into com (tick,who,message) select tick+1,v.id,m.name||' gives you a '||new.c2||'.' from tick,mob m,vroommobfull v where m.id=new.who and v.who=new.who and v.name like(new.c3);end;
cmdgive2~after~insert on log when new.c1 like('give') and exists(select name from vinv where who=new.who and name like(new.c2)) and not exists(select name from vroommobfull where who=new.who and name like(new.c3)) begin insert into com (tick,who,message) select tick+1,new.who,new.c3||' is not here.' from tick; end;
cmdgive3~after~insert on log when new.c1 like('give') and not exists(select name from vinv where who=new.who and name like(new.c2)) begin insert into com (tick,who,message) select tick+1,new.who,'you have no '||new.c3||' to give.' from tick; end;
cmdgo1~after~insert on log when new.c1 like('go') and exists(select 1 from vroomext where who=new.who and new.c2 like(name)) begin insert into com (tick,who,message) select tick+1,new.who,'you head '||v.alt from tick,vroomext v where v.who=new.who and v.name like(new.c2); insert into com (tick,who,message) select tick+1,r.id,m.name||' leaves '||new.c2 from tick,mob m,vroommob r where m.id=new.who and r.who=new.who and r.id<>new.who; update obj set v1=(select dest from vroomext v,mob m where m.id=new.who and m.loc=room and v.who=new.who and new.c2 like(v.name)) where id=new.who; insert into com (tick,who,message) select tick+1,r.id,m.name||' wanders in' from tick,mob m,vroommob r where m.id=new.who and r.who=new.who and r.id<>new.who;insert into com(tick,who,message) select tick+1,new.who,r.name from tick,rom r,mob m where m.id=new.who and r.id=m.loc; insert into com(tick,who,message) select tick+1,new.who,r.desc from tick,rom r,mob m where m.id=new.who and r.id=m.loc; insert into com(tick,who,message) select tick+1,new.who,case when exists(select 1 from ext e where e.room=m.loc) then 'visible exits:' else 'visible exits: none' end from tick,mob m where m.id=new.who; insert into com(tick,who,message) select distinct tick+1,new.who,e.name from tick,ext e,mob m where m.id=new.who and e.room=m.loc; insert into com(tick,who,message) select tick+1,new.who,'on the ground, you can see:' from tick,mob m where m.id=new.who and exists(select 1 from itm i where i.loc=m.loc); insert into com(tick,who,message) select distinct tick+1,new.who,(select count(*) from itm j where j.name like(i.name) and j.loc=i.loc)||' '||i.name from tick,itm i,mob m where m.id=new.who and i.loc=m.loc; insert into com(tick,who,message) select tick+1,new.who,'visiting the area, you can see: ' from tick,mob m where m.id=new.who and exists(select 1 from vroommob where who=new.who); insert into com(tick,who,message) select tick+1,new.who,''||v.name from tick,vroommob v where v.who=new.who;end;
cmdgo2~after~insert on log when exists(select 1 from vroomext where who=new.who and new.c1 like(name)) begin insert into com (tick,who,message) select tick+1,new.who,'you head '||v.alt from tick,vroomext v where v.who=new.who and v.name like(new.c1); insert into com (tick,who,message) select tick+1,r.id,m.name||' leaves '||new.c1 from tick,mob m,vroommob r where m.id=new.who and r.who=new.who and r.id<>new.who; update obj set v1=(select dest from vroomext v,mob m where m.id=new.who and m.loc=room and v.who=new.who and new.c1 like(v.name)) where id=new.who; insert into com (tick,who,message) select tick+1,r.id,m.name||' wanders in' from tick,mob m,vroommob r where m.id=new.who and r.who=new.who and r.id<>new.who;insert into com(tick,who,message) select tick+1,new.who,r.name from tick,rom r,mob m where m.id=new.who and r.id=m.loc; insert into com(tick,who,message) select tick+1,new.who,r.desc from tick,rom r,mob m where m.id=new.who and r.id=m.loc; insert into com(tick,who,message) select tick+1,new.who,case when exists(select 1 from ext e where e.room=m.loc) then 'visible exits:' else 'visible exits: none' end from tick,mob m where m.id=new.who; insert into com(tick,who,message) select distinct tick+1,new.who,e.name from tick,ext e,mob m where m.id=new.who and e.room=m.loc; insert into com(tick,who,message) select tick+1,new.who,'on the ground, you can see:' from tick,mob m where m.id=new.who and exists(select 1 from itm i where i.loc=m.loc); insert into com(tick,who,message) select distinct tick+1,new.who,(select count(*) from itm j where j.name like(i.name) and j.loc=i.loc)||' '||i.name from tick,itm i,mob m where m.id=new.who and i.loc=m.loc; insert into com(tick,who,message) select tick+1,new.who,'visiting the area, you can see: ' from tick,mob m where m.id=new.who and exists(select 1 from vroommob where who=new.who); insert into com(tick,who,message) select tick+1,new.who,''||v.name from tick,vroommob v where v.who=new.who;end;
cmddescself~after~insert on log when new.c1 like('describe') and new.c2 like('self') begin insert into com (tick,who,message) select tick+1,new.who,'your new description reads: "'||new.c3||'"' from tick;update mob set desc=new.c3 where id=new.who;end;
cmddescmob~after~insert on log when new.c1 like('redescribe') and exists(select name from vroommobfull where who=new.who and name like(new.c2)) begin insert into com (tick,who,message) select tick+1,n.id,m.name||' updates your description' from tick,vroommob n,mob m where m.id=new.who and n.who=new.who and (new.c2 like(n.name) or new.c2=n.id); insert into com (tick,who,message) select tick+1,new.who,n.name||'s new description reads: "'||new.c3||'"' from tick,vroommob n where n.who=new.who and (new.c2 like(n.name) or new.c2=n.id);update mob set desc=new.c3 where id=new.c2 or name like(new.c2);end;
cmddescitem~after~insert on log when new.c1 like('redescribe') and exists(select name from vroomitmfull where who=new.who and name like(new.c2)) begin insert into com (tick,who,message) select tick+1,new.who,n.name||'s new description reads: "'||new.c3||'"' from tick,vroomitm n where n.who=new.who and (new.c2 like(n.name) or new.c2=n.id); update itm set desc=new.c3 where id=new.c2 or name like(new.c2);end;
cmddescinv~after~insert on log when new.c1 like('redescribe') and exists(select name from vinvfull where who=new.who and name like(new.c2)) begin insert into com (tick,who,message) select tick+1,new.who,n.name||'s new description reads: "'||new.c3||'"' from tick,vinvfull n where n.who=new.who and new.c2 like(n.name); update itm set desc=new.c3 where id=new.c2 or name like(new.c2);end;
cmddescpln~after~insert on log when new.c1 like('redescribe') and exists(select name from pln where name like(new.c2)) begin insert into com (tick,who,message) select tick+1,new.who,n.name||'s new description reads: "'||new.c3||'"' from tick,pln n where (new.c2 like(n.name) or new.c2=n.id); update pln set desc=new.c3 where id=new.c2 or name like(new.c2);end;
cmddescrom~after~insert on log when new.c1 like('redescribe') and new.c2 like('room') begin insert into com (tick,who,message) select tick+1,new.who,'rooms new description reads: "'||new.c3||'"' from tick; update rom set desc=new.c3 where id=(select loc from mob where id=new.who);end;
cmdskil~after~insert on log when new.actioned=1 begin insert into com(tick,who,message) select tick+1,new.who,'you '||e.name||' '||new.c2 from tick,ske k,skl s,efx e where k.effect=e.id and k.skill=s.id and new.c1 in(s.name,s.id); insert into com(tick,who,message) select tick+1,t.id,m.name||' '||e.name||'s '||new.c2 from tick,mob m,mob t,ske k,skl s,efx e where m.id=new.who and m.id<>t.id and m.loc=t.loc and k.effect=e.id and k.skill=s.id and t.active=1 and new.c1 in(s.name,s.id);end;
#insert or ignore into [1] values([2]);
validtarget~'new','mob'
validtarget~'new','room'
validtarget~'new','exit'
validtarget~'new','template'
validtarget~'new','effect'
validtarget~'new','skill'
validtarget~'new','race'
validtarget~'new','class'
validtarget~'new','gender'
validtarget~'new','pskill'
validtarget~'new','cskill'
validtarget~'new','rskill'
validtarget~'new','iskill'
validtarget~'new','@plan'
validtarget~'new','plan'
validtarget~'new','item'
validtarget~'new','pronoun'
validtarget~'list',''
validtarget~'list','all'
validtarget~'list','exit'
validtarget~'list','exits'
validtarget~'list','room'
validtarget~'list','rooms'
validtarget~'list','plan'
validtarget~'list','plans'
validtarget~'list','template'
validtarget~'list','templates'
validtarget~'list','item'
validtarget~'list','items'
validtarget~'list','mob'
validtarget~'list','mobs'
validtarget~'list','user'
validtarget~'list','users'
validtarget~'list','race'
validtarget~'list','races'
validtarget~'list','class'
validtarget~'list','classes'
validtarget~'list','gender'
validtarget~'list','genders'
validtarget~'list','skill'
validtarget~'list','skills'
validtarget~'help',''
validtarget~'help','any'
validtarget~'help','@skill'
validtarget~'add','effect'
validtarget~'add','@effect'
validtarget~'look',''
validtarget~'look','room'
validtarget~'look','self'
validtarget~'look','@mob'
validtarget~'look','@item'
validtarget~'inv',''
validtarget~'get','@item'
validtarget~'drop','@item'
validtarget~'give','@item'
validtarget~'go','@exit'
validtarget~'@exit',''
validtarget~'describe','self'
validtarget~'redescribe','@mob'
validtarget~'redescribe','@item'
validtarget~'redescribe','@plan'
validtarget~'redescribe','@room'
tick~1,0


dbinitialise.txt
Code:
#insert or ignore into [1]([2]) values([3]);
obj~id,label,name,desc,v1,v2,v3,v4,v5,v6,v7,v8,v9~0,'mob','The Universe','',1,0,0,0,0,0,0,0,0
obj~id,label,name,desc,v1,v2,v3,v4,v5,v6,v7,v8~1,'rom','Void','an empty void, ready for you to start creating',0,0,0,0,0,0,0,0
obj~id,label,name,desc,v1,v2,v3,v4,v5,v6,v7,v8~2,'cls','all','',0,0,0,0,0,0,0,0
obj~id,label,name,desc,v1,v2,v3,v4,v5,v6,v7,v8~3,'rac','all','',0,0,0,0,0,0,0,0
obj~id,label,name,desc,c1~4,'skl','new','create something new','NEW skill,template,item,room,mob,exit,effect,rskill,pskill'
obj~id,label,name,desc~5,'pln','admin','an item template that allows admin skills'
obj~id,label,v1,name,desc,v2,v3,v4,v5,v6,v7~6,'itm',0,'Orb','this ball of light pulses with the power of creation',5,0,0,0,0,0
obj~id,label,name,desc,v1,v2,v3,v4,v5,v6,v7,v8~7,'rom','Void','an empty void, ready for you to start creating',0,0,0,0,0,0,0,0
obj~id,label,name,desc,v1,v2,v3,v4,v5,v6,v7,v8~8,'rom','Void','an empty void, ready for you to start creating',0,0,0,0,0,0,0,0
obj~id,label,name,desc,v1,v2,v3,v4,v5,v6,v7,v8~9,'rom','Void','an empty void, ready for you to start creating',0,0,0,0,0,0,0,0
obj~id,label,v1,name,desc,v2,v3,v4,v5,v6,v7~10,'itm',1,'Orb','this ball of light pulses with the power of creation',5,0,0,0,0,0
#insert or ignore into [1] values([2]);
lst(i1,c,i2)~1,'north',7
lst(i1,c,i2)~7,'south',1
lst(i1,c,i2)~1,'east',8
lst(i1,c,i2)~8,'west',1
lst(i1,c,i2)~1,'up',9
lst(i1,c,i2)~9,'down',1
#insert or ignore into [1]([2]) values([3]);
obj~id,label,name,desc,c1~11,'skl','list','list an internal table','LIST all,mobs,users,races,classes,genders,rooms,exits,effects,items,templates'
obj~id,label,name,desc,c1~12,'skl','tick','advance the internal timer','TICK (amount)'
obj~id,label,name,desc,c1~13,'skl','look','look at something','LOOK target'
obj~id,label,name,desc,c1~14,'skl','add','imbue an effect to an object','ADD effect skill'
obj~id,label,name,desc,c1~15,'skl','get','pick up an item from the floor','GET item'
obj~id,label,name,desc,c1~16,'skl','drop','drop an item from your backpack','DROP item'
obj~id,label,name,desc,c1~17,'skl','give','give an item to someone','GIVE item target'
obj~id,label,name,desc,c1~18,'skl','go','move in a direction','GO direction'
obj~id,label,name,desc,c1~19,'skl','inv','look at your inventory','INV'
obj~id,label,name,desc,c1~34,'skl','help','help on commands','HELP (command)'
obj~id,label,name,desc,c1~21,'skl','skills','help on commands','SKILLS (command)'
obj~id,label,name,desc,c1~22,'skl','describe','change your description','DESC self "new description"'
obj~id,label,name,desc,c1~23,'skl','redescribe','change targets description','REDES target "new description"'
lst~i1,i2~5,4
lst~i1,i2~5,11
lst~i1,i2~5,12
lst~i1,i2~5,14
lst~i1,i2~5,23
lst~i1,i2~5,13
lst~i1,i2~5,15
lst~i1,i2~5,16
lst~i1,i2~5,17
lst~i1,i2~5,18
lst~i1,i2~5,19
lst~i1,i2~5,34
lst~i1,i2~5,21
lst~i1,i2~5,22
obj~id,label,name,desc~24,'efx','damage','hurt if applied'
obj~id,label,name,desc~25,'efx','heal','restore damage'
obj~id,label,name,desc~26,'efx','silence','prevents ability to make a sound'
obj~id,label,name,desc~27,'rac','human','the most versatile race, able to adapt to almost any environment'
obj~id,label,name,desc~28,'rac','elf','pointy ears, handy with a bow, nuff said'
obj~id,label,name,desc~29,'rac','dwarf','born from the earth, they are masters of their element'
obj~id,label,name,desc~30,'cls','peasant','stinky, but good people'
obj~id,label,name,v1,v2,v3~31,'gen','agender',32,33,43
obj~id,label,name~32,'pno','they'
obj~id,label,name~33,'pno','them'
obj~id,label,name~43,'pno','their'
obj~id,label,name,v1,v2,v3~35,'gen','female',36,37,37
obj~id,label,name~36,'pno','she'
obj~id,label,name~37,'pno','her'
obj~id,label,name~38,'pno','hers'
obj~id,label,name,v1,v2,v3~39,'gen','male',40,41,42
obj~id,label,name~40,'pno','he'
obj~id,label,name~41,'pno','him'
obj~id,label,name~42,'pno','his'
alias~alias,alt~'l','look'
alias~alias,alt~'i','inv'
alias~alias,alt~'inventory','inv'
alias~alias,alt~'n','north'
alias~alias,alt~'s','south'
alias~alias,alt~'e','east'
alias~alias,alt~'w','west'
alias~alias,alt~'u','up'
alias~alias,alt~'d','down'
alias~alias,alt~'create','new'
alias~alias,alt~'skills','help'
alias~alias,alt~'skill','help'
alias~alias,alt~'desc','describe'
alias~alias,alt~'redes','redescribe'

_________________
there is no sig, only zuul (and the following disclaimer)

WARNING: may be talking out of his hat


Top
 Profile  
Reply with quote  
 Post subject: Re: SQL driven MUD
PostPosted: Mon Dec 03, 2018 12:23 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Feb 12, 2006 10:06 pm
Posts: 638
CLIENT.pb
Code:
OpenConsole()
;EnableGraphicalConsole(1)
InitNetwork()
a$="127.0.0.1"
port=8080
c=CountProgramParameters()
If c
  a$=ProgramParameter()
  If c>1
    port=Val(ProgramParameter())
  EndIf
EndIf

sv=OpenNetworkConnection(a$,port)

Procedure thread(sv)
  While 1
    Delay(0)
    ne=NetworkClientEvent(sv)
    Select ne
      Case #PB_NetworkEvent_Data
        *b=AllocateMemory(1024)
        b=1024:b$=""
        While b=1024
          b=ReceiveNetworkData(sv,*b,1024)
          b$+PeekS(*b,-1,#PB_Ascii)
        Wend
        FreeMemory(*b)
        b$=ReplaceString(ReplaceString(b$,#CRLF$,Chr(1)),#TAB$,"    ")
        For j=1 To 1
        For i=0 To CountString(b$,Chr(1))
          c$=StringField(b$,i+1,Chr(1))
          If Right(c$,1)="|"
            Print(Left(c$,Len(c$)-1))
            Break 2
          Else
            PrintN(c$)
          EndIf
        Next
        Print("Command> ")
        Next
    EndSelect
  Wend
EndProcedure

CreateThread(@thread(),sv)
While sv
  Delay(0)
  a$=Input()
  If a$="q" Or a$="quit"
    sv=0
  ElseIf a$
    SendNetworkString(sv,a$)
  Else
    Print("Command> ")
  EndIf
Wend

_________________
there is no sig, only zuul (and the following disclaimer)

WARNING: may be talking out of his hat


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye