ScriptUO

Official ScriptUO EasyUO Scripts => Site Scripter Libraries => Endless Nights' Script Library => Topic started by: Endless Night on May 12, 2011, 05:18:10 AM

Title: (Retired) ENs - Subs - FlatFile Tables (Emulator)
Post by: Endless Night on May 12, 2011, 05:18:10 AM
ENs - FlatFile Tables
Emulator - being as EUO has no way to load and parse files so can only emulate database functions.

Debuggin this code gave me a serious migraine... but is dang useful. Use it as a called script, Set the path in %EN_Table

TABLE COMMANDS
set %EN_Table C:\easyuo/EUO , #spc , Scripts\ENs-Scripts\ENs-Subs-Tables.Txt
call %EN_Table EN_Table_Create       ; %1=TableName , %2...%z Field Names
;                                        ; Creates table and sets active table.
call %EN_Table EN_Table_Use          ; %1=TableName (Sets active Table)
call %EN_Table EN_Table_Goto         ; %1=RecordNum %2=Optional TableName  - sets fields
call %EN_Table EN_Table_Next         ; %1=Optional TableName  - sets fields
call %EN_Table EN_Table_Prior        ; %1=Optional TableName  - sets fields
call %EN_Table EN_Table_Top          ; %1=Optional TableName  - sets fields
call %EN_Table EN_Table_Bottom       ; %1=Optional TableName  - sets fields
call %EN_Table EN_Table_isDeteled    ; %1=Optional TableName  - Returns #true/#false
call %EN_Table EN_Table_Detele       ; %1=Optional TableName  - Sets Deleted Flag
call %EN_Table EN_Table_Recall       ; %1=Optional TableName  - Undeletes Record
call %EN_Table EN_Table_Append       ; Adds record to end of table *1
call %EN_Table EN_Table_Insert       ; Inserts Record at position EN_RecordOn *1
call %EN_Table EN_Table_Update       ; Updates Current Record *1
;                                       *1 (Uses %EN_TableOn, EN_RecordOn)
call EN_Table_Load   ;notdone yet
call EN_Table_Save  ; notdone yet

EXPOSED VARIABLES
%EN_TableOn  %EN_RecordOn
%TableName_  RecordCnt, FieldCnt, RecordOn, Deleted , Prior , Next , Top , Bottom
%TableName_  Fieldsnames...1...z   (as defined on the table create command)


All the normal bs ENs disclaimers apply...

REMEMBER: Feedback is important... good bad or not comment all important if you download give feedback

(C) 2007 All Rights Reserved JosephAJ
Commercial usage requires written permission from the author


NOTE: My scripts or any derivative of them are *not* for use in other players script/s!  
Title: Re: ENs - FlatFile Tables (Emulator)
Post by: Endless Night on May 12, 2011, 05:20:33 AM
Example Code
Create a table of items equipped on paperdoll. Scroll throw table displaying the information stored.

Code: [Select]
; Initialize Pathing and Create the table
set #lpc 9000
set %EN_Table C:\easyuo/EUO , #spc , Scripts\ENs-Scripts\ENs-Subs-Tables.Txt
call %EN_Table EN_Table_Create Equipped id Property Color    ; Create table

Code: [Select]
; populate table with equipment worn information
finditem * C_, #charid   
if #findcnt > 0
  {
  set !s #scnt
  for #findindex 1 #findcnt
    {
    event property #findid
    ; Method 1
    Call %EN_Table EN_Table_Append #findid #property #findcol
    ; Method 2
;    set %Equipped_id        #findid
;    set %Equipped_Property  #property
;    set %Equipped_Color     #findcol
;    Call %EN_Table EN_Table_Append
    }
    set !t #scnt - !s
    display ok Saved %Equipped_RecordCnt Records in !t seconds
  }

Code: [Select]
display ok  Scrolling  Thu Table By Record Number $$
for !RecNo 1 %Equipped_RecordCnt
  {
  CAll %EN_Table EN_Table_Goto !RecNo
  display ok TableOn: %EN_TableOn  RecordOn: %Equipped_RecordOn Deleted: %Equipped_Deleted $ $ ID= %Equipped_ID Property= %Equipped_Property  $$ %Equipped_RecordOn : prior= %Equipped_Prior Next= %Equipped_Next    ; at bottom
  }

Code: [Select]
display ok  Scrolling Thu Table via TOP Next
call %EN_Table EN_Table_Top
repeat
  display ok TableOn: %EN_TableOn  RecordOn: %Equipped_RecordOn Deleted: %Equipped_Deleted $ $ ID= %Equipped_ID Property= %Equipped_Property  $$ %Equipped_RecordOn : prior= %Equipped_Prior Next= %Equipped_Next    ; at bottom
  call %EN_Table EN_Table_Next
Until #result = #false   ; at bottom

Code: [Select]
display ok Scroll Thu Table Backwards via Bottom Prior
call %EN_Table EN_Table_Bottom
repeat
  display ok TableOn: %EN_TableOn  RecordOn: %Equipped_RecordOn Deleted: %Equipped_Deleted $ $ ID= %Equipped_ID Property= %Equipped_Property  $$ %Equipped_RecordOn : prior= %Equipped_Prior Next= %Equipped_Next    ; at bottom
  call %EN_Table EN_Table_Prior
Until #result = #false   ; at bottom
Title: Re: ENs - FlatFile Tables (Emulator)
Post by: Endless Night on May 12, 2011, 05:41:23 AM
Example Code 2
Relationships and filters.   Experimental .. code not yet implemented.


Code: [Select]
; Create tables and assign Data.

call EN_Table Create Food        Catagory Discription       ; Create table 'Food' with 2 fields
call EN_Table Create FoodTypes   Catagory Name    

call EN_Table Use Food   ; set active table
call EN_Table Add Cheese Cheese

call EN_Table Use FoodTypes   ; set active table
call EN_Table Add %Food_Catagory Provolone
call EN_Table Add %Food_Catagory Swiss
call EN_Table Add %Food_Catagory Cheddar
call EN_Table Add %Food_Catagory Feta

call EN_Table Use Food   ; set active table
call EN_Table Add Milk  Milk
call EN_Table Use FoodTypes  
call EN_Table Add %Food_Catagory  Soy
call EN_Table Add %Food_Catagory  Haznut
call EN_Table Add %Food_Catagory  Non-Fat
call EN_Table Add %Food_Catagory  Low-Fat
call EN_Table Add %Food_Catagory  Whole

Code: [Select]
; Get a Subset of data by setting a filter from one table to another

call EN_Table Use FoodTypes   ; set active table
call EN_Table SetFilter  Catagory = %Food_Catagory




Title: Re: ENs - FlatFile Tables (Emulator)
Post by: Endless Night on May 12, 2011, 01:12:09 PM
If anyone is interested in this work let me know.  I will be using this to create my Action Template Tables.
Title: Re: ENs - FlatFile Tables (Emulator)
Post by: Outlaw Josey Wales on May 12, 2011, 07:09:40 PM
hands 12 some tylenol along with a fifth of bourban
Title: Re: ENs - FlatFile Tables (Emulator)
Post by: Paulonius on May 13, 2011, 02:40:57 PM
I am going to take a look at these and figure out how to use them in the near future.  I am wondering whether a file like this could replace the craftinfo script.