Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#include <stdio.h>
#include <iostream>
#include <sqlite3.h>
#include "libsqlite.hpp"
#include <ctime>
#include <thread>
#include <chrono>
using namespace std;
void speech1()
{
string sqlitefile = "npc.sqlite";
string streets1;
string name;
string speech; //states variables
int speechID;
string npcID;
try
{
sqlite::sqlite db(sqlitefile); //accesses required database
for( speechID = 1; speechID < 4; speechID++)
{
auto cur = db.get_statement();
cur->set_sql( "SELECT npcSpeech FROM Speech " //accesses required table
"WHERE speechID = ?"); //placeholder
cur->prepare();
cur->bind(1, speechID); //collects the required data
cur-> step() ;
speech = cur->get_text(0);
cout << speech <<endl; //outputs data from database
std::this_thread::sleep_for (std::chrono::seconds(1)); //tells the program to wait for 1 second
}
}
catch( sqlite::exception e )
{
std::cerr << e.what() << std::endl;
}
}
int speech2()
{
string sqlitefile = "npc.sqlite";
string streets1;
string name;
string speech;
int speechID;
string npcID;
try
{
sqlite::sqlite db(sqlitefile);
for( speechID = 4; speechID < 9; speechID++)
{
auto cur = db.get_statement();
cur->set_sql( "SELECT npcSpeech FROM Speech "
"WHERE speechID = ?");
cur->prepare();
cur->bind(1, speechID);
cur-> step() ;
speech = cur->get_text(0);
cout << speech <<endl;
std::this_thread::sleep_for (std::chrono::seconds(1));
}
}
catch( sqlite::exception e )
{
std::cerr << e.what() << std::endl;
}
}
int npc()
{
speech1();
}