Data Storage: Difference between revisions

From Citizens Wiki

(Added new linear pathing)
Line 30: Line 30:
         {{H:title|First line of the NPC's chat.|0: Hello, there. I'm My_First_NPC.}}
         {{H:title|First line of the NPC's chat.|0: Hello, there. I'm My_First_NPC.}}
       {{H:title|Waypoints block|waypoints:}}
       {{H:title|Waypoints block|waypoints:}}
         {{H:title|Waypoints block (again, yes)|waypoints:}}
         {{H:title|Linear type of waypoints|linear:}}
          {{H:title|Waypoint number|'0':}}
          {{H:title|Points section of the linear block|points:}}
            {{H:title|Waypoint location block|location:}}
            {{H:title|Waypoint number|'0':}}
              {{H:title|World of the waypoint|world: MyWorld}}
              {{H:title|Waypoint location block|location:}}
              {{H:title|X coordinate of the waypoint|x: 60}}
                {{H:title|World of the waypoint|world: MyWorld}}
              {{H:title|Y coordinate of the waypoint|y: 64}}
                {{H:title|X coordinate of the waypoint|x: 60}}
              {{H:title|Z coordinate of the waypoint|z: 80}}
                {{H:title|Y coordinate of the waypoint|y: 64}}
              {{H:title|Pitch of the waypoint|pitch: 90}}
                {{H:title|Z coordinate of the waypoint|z: 80}}
              {{H:title|Yaw of the waypoint|yaw: 0}}
                {{H:title|Pitch of the waypoint|pitch: 90}}
          {{H:title|Waypoint number|'1':}}
                {{H:title|Yaw of the waypoint|yaw: 0}}
            {{H:title|Waypoint location block|location:}}
              {{H:title|How long to wait at this point|delay: 0}}
              {{H:title|World of the waypoint|world: MyWorld}}
            {{H:title|Waypoint number|'1':}}
              {{H:title|X coordinate of the waypoint|x: 65}}
              {{H:title|Waypoint location block|location:}}
              {{H:title|Y coordinate of the waypoint|y: 64}}
                {{H:title|World of the waypoint|world: MyWorld}}
              {{H:title|Z coordinate of the waypoint|z: 82}}
                {{H:title|X coordinate of the waypoint|x: 65}}
              {{H:title|Pitch of the waypoint|pitch: 45}}
                {{H:title|Y coordinate of the waypoint|y: 64}}
              {{H:title|Yaw of the waypoint|yaw: 0}}
                {{H:title|Z coordinate of the waypoint|z: 82}}
                {{H:title|Pitch of the waypoint|pitch: 45}}
                {{H:title|Yaw of the waypoint|yaw: 0}}
              {{H:title|How long to wait at this point|delay: 0}}
        {{H:title|Which pathfinder code do we use? (probably linear)|provider: linear}}


==Database==
==Database==

Revision as of 12:11, 8 October 2012

Data storage in Citizens2 is handled in one of two ways: YAML flatfile, or a SQL database.

saves.yml

saves.yml is used by default to store all data on created NPCs.

Structure

Mouseover to view info:

# Citizens NPC Storage
npc:
  '0':
   name: My_First_NPC
   traits:
     age:
       age: 0
       locked: true
     spawned: true
     type: PLAYER
     owner: Steve
     lookclose: true
     location:
       world: world
       x: '92.65002360423462'
       y: '3.0'
       z: '-264.5621058817138'
       yaw: '87.90003967285156'
       pitch: '21.14999008178711'
     text:
       talk-close: true
       random-talker: true
       0: Hello, there. I'm My_First_NPC.
     waypoints:
       linear:
         points:
           '0':
             location:
               world: MyWorld
               x: 60
               y: 64
               z: 80
               pitch: 90
               yaw: 0
             delay: 0
           '1':
             location:
               world: MyWorld
               x: 65
               y: 64
               z: 82
               pitch: 45
               yaw: 0
             delay: 0
       provider: linear

Database

Database usage can be configured inside of the config.yml. Database usage requires more setup, but may be quicker, more secure and more resilient when dealing with large numbers of NPCs.

SQL storage is not currently functioning correctly

Configuration

A quote from the config.yml (mouseover to view info):

database:
 password: 
 username: 
 url: 
 driver: 

See also: Configuration

    - Database settings -
    driver: the database type - eg. mysql, sqlite, postgres, h2
    url: the database url - eg. sqlite://path/to/your/database.db
    MySQL uses the database IP address - eg. mysql://localhost:2222/database

    The username and password settings are required to connect to certain types of databases such as MySQL.