Made some changes, modded a datetime object, and started defining some parent classes.

This commit is contained in:
Luke Gebbink 2022-01-02 12:56:55 -07:00
parent 98bb5209e3
commit 2d2e65d8ae
15 changed files with 360 additions and 37 deletions

View File

@ -0,0 +1,16 @@
extends Node
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass

View File

@ -0,0 +1,16 @@
extends Node
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass

View File

@ -0,0 +1,5 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://Game.tscn" type="PackedScene" id=1]
[node name="Game" instance=ExtResource( 1 )]

View File

@ -0,0 +1,101 @@
#extention of Date.gd from vanskodje-godotengine / godot-plugin-calendar-button
extends Node
class_name Date
var day : int setget set_day
var month : int setget set_month
var year : int setget set_year
var hour : int setget set_hour
var minute : int setget set_minute
var seconds : int setget set_seconds
func _init(day : int = OS.get_datetime()["day"],
month : int = OS.get_datetime()["month"],
year : int = OS.get_datetime()["year"],
hour : int = OS.get_datetime()["hour"],
minute : int = OS.get_datetime()["minute"],
seconds : int = OS.get_datetime()["second"]):
self.day = day
self.month = month
self.year = year
self.hour = hour
self.minute = minute
self.seconds = seconds
# Supported Date Formats:
# DD : Two digit day of month
# MM : Two digit month
# YY : Two digit year
# YYYY : Four digit year
func date(date_format = "DD-MM-YY") -> String:
if("DD".is_subsequence_of(date_format)):
date_format = date_format.replace("DD", str(day()).pad_zeros(2))
if("MM".is_subsequence_of(date_format)):
date_format = date_format.replace("MM", str(month()).pad_zeros(2))
if("YYYY".is_subsequence_of(date_format)):
date_format = date_format.replace("YYYY", str(year()))
elif("YY".is_subsequence_of(date_format)):
date_format = date_format.replace("YY", str(year()).substr(2,3))
return date_format
func day() -> int:
return day
func month() -> int:
return month
func year() -> int:
return year
func hour() -> int:
return hour
func minute() -> int:
return minute
func seconds() -> int:
return seconds
func set_day(var _day : int):
day = _day
func set_month(var _month : int):
month = _month
func set_year(var _year : int):
year = _year
func set_hour(var _hour : int):
hour = _hour
func set_minute(var _minute : int):
minute = _minute
func set_seconds(var _seconds : int):
seconds = _seconds
func change_to_prev_month():
var selected_month = month()
selected_month -= 1
if(selected_month < 1):
set_month(12)
set_year(year() - 1)
else:
set_month(selected_month)
func change_to_next_month():
var selected_month = month()
selected_month += 1
if(selected_month > 12):
set_month(1)
set_year(year() + 1)
else:
set_month(selected_month)
func change_to_prev_year():
set_year(year() - 1)
func change_to_next_year():
set_year(year() + 1)

View File

@ -0,0 +1,49 @@
extends Node
class_name Die
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
enum DieCategory{
D4,
D6,
D8,
D10,
D12,
D00,
D20
}
var dieType = DieCategory
var numberOfFaces = 0
func SetNumberOfSides():
var DSides = dieType
match DSides:
D4:
numberOfFaces = 4
D6:
numberOfFaces = 6
D8:
numberOfFaces = 8
D10:
numberOfFaces = 10
D12:
numberOfFaces = 12
D00:
numberOfFaces = 100
D20:
numberOfFaces = 20
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass

View File

@ -1,38 +1,5 @@
extends MarginContainer
const SQLite = preload("res://addons/godot-sqlite/bin/gdsqlite.gdns")
var db
var db_name = "res://DataStore/database"
func _ready():
db = SQLite.new()
db.path = db_name
#commitDataToDB()
readFromDB()
getItemsByUserID(1)
func commitDataToDB():
db.open_db()
var tableName = "PlayerInfo"
var dict : Dictionary = Dictionary()
dict["Name"] = "This is a test user1"
dict["Score"] = 6000
db.insert_row(tableName,dict)
print("Row Inserted")
func readFromDB():
db.open_db()
var tableName = "PlayerInfo"
db.query("select * from " + tableName + ";")
for i in range(0,db.query_result.size()):
print("Query results ", db.query_result[i]["Name"], db.query_result[i])
func getItemsByUserID(id):
db.open_db()
#To Do, we should probably make this more generic, so it can query differnt tables
db.query("select playerinfo.name as pname, ItemIventory.name as iname from playerinfo left join ItemIventory on playerinfo.ID = ItemIventory.PlayerID where playerinfo.id = " + str(id))
for i in range(0, db.query_result.size()):
print("Query results ", db.query_result[i]["pname"], db.query_result[i]["iname"])
return db.query_result
var TimeTest = OS.get_datetime()
print(TimeTest)

View File

@ -1,4 +1,6 @@
[gd_scene load_steps=4 format=2]
[gd_scene load_steps=5 format=2]
[ext_resource path="res://GUI.gd" type="Script" id=1]
[sub_resource type="StyleBoxFlat" id=1]
bg_color = Color( 0.129412, 0.129412, 0.129412, 1 )
@ -12,6 +14,7 @@ bg_color = Color( 0.309804, 0.305882, 0.305882, 1 )
[node name="Game" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}

View File

@ -0,0 +1,21 @@
extends Node
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
var isPaused = false
func isPausedFunc():
print("Status is " + isPaused)
return isPaused
# Called when the node enters the scene tree for the first time.
func _ready():
isPausedFunc()
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass

View File

@ -0,0 +1,58 @@
extends Node
const SQLite = preload("res://addons/godot-sqlite/bin/gdsqlite.gdns")
var db
var db_name = "res://DataStore/database"
var isPaused = false
func isPausedFunc():
print(isPaused)
return isPaused
func _ready():
db = SQLite.new()
db.path = db_name
commitDataToDB()
#readFromDB()
getItemsByUserID(1)
isPausedFunc()
func onSaveGame():
print() #Return World object
func onLoadGame():
print() #Return World object
func commitDataToDB():
db.open_db()
var tableName = "PlayerInfo"
var dict : Dictionary = Dictionary()
dict["Name"] = "Elon Musk"
dict["Archetype"] = "The Best One"
dict["Culture"] = "South African"
dict["Desc"] = "One of the richest people alive"
dict["Bio"] = "A Rich Guy"
dict["Health"] = 100
dict["Gold"] = 6000
db.insert_row(tableName,dict)
print("Row Inserted")
func readFromDB():
db.open_db()
var tableName = "PlayerInfo"
db.query("select * from " + tableName + ";")
for i in range(0,db.query_result.size()):
print("Query results ", db.query_result[i]["Name"], db.query_result[i])
func getItemsByUserID(id):
db.open_db()
#To Do, we should probably make this more generic, so it can query differnt tables
db.query("select playerinfo.name as pname, ItemIventory.name as iname from playerinfo left join ItemIventory on playerinfo.ID = ItemIventory.PlayerID where playerinfo.id = " + str(id))
for i in range(0, db.query_result.size()):
print("Query results ", db.query_result[i]["pname"], db.query_result[i]["iname"])
return db.query_result# pass

View File

@ -14,4 +14,3 @@ func _on_Start_Game_gui_input(event):
print("Clicked Start Game")
get_tree().change_scene("res://TestNode2D.tscn")
# Start Game button opens a new node for that purpose

View File

@ -5,11 +5,25 @@ extends Node2D
# var a = 2
# var b = "text"
var isPaused = false
var wantsNewGame = false
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
func CreateNewGame():
print("Create World Object to save")
func _wantsNewGame():
if wantsNewGame == true:
print("Yes")
if wantsNewGame == false:
print("No")
return wantsNewGame
# Make this function return a boolean.
func _isPaused():
if isPaused == true:

View File

@ -0,0 +1,46 @@
extends MarginContainer
const SQLite = preload("res://addons/godot-sqlite/bin/gdsqlite.gdns")
var db
var db_name = "res://DataStore/database"
var isPaused = false
var isGameOver = false
func _ready():
db = SQLite.new()
db.path = db_name
commitDataToDB()
#readFromDB()
getItemsByUserID(1)
func commitDataToDB():
db.open_db()
var tableName = "PlayerInfo"
var dict : Dictionary = Dictionary()
dict["Name"] = "Elon Musk"
dict["Archetype"] = "The Best One"
dict["Culture"] = "South African"
dict["Desc"] = "One of the richest people alive"
dict["Bio"] = "A Rich Guy"
dict["Health"] = 100
dict["Gold"] = 6000
db.insert_row(tableName,dict)
print("Row Inserted")
func readFromDB():
db.open_db()
var tableName = "PlayerInfo"
db.query("select * from " + tableName + ";")
for i in range(0,db.query_result.size()):
print("Query results ", db.query_result[i]["Name"], db.query_result[i])
func getItemsByUserID(id):
db.open_db()
#To Do, we should probably make this more generic, so it can query differnt tables
db.query("select playerinfo.name as pname, ItemIventory.name as iname from playerinfo left join ItemIventory on playerinfo.ID = ItemIventory.PlayerID where playerinfo.id = " + str(id))
for i in range(0, db.query_result.size()):
print("Query results ", db.query_result[i]["pname"], db.query_result[i]["iname"])
return db.query_result

View File

@ -0,0 +1,16 @@
extends Node
const date = preload("res://Date.gd")
var isPaused = false
var isGameOver = false
var Scene = SceneTree
# var players = Array or Similar for Actors
# var history = Array or Similar for Nodes
# var decisions = Array or Similar for ints
var DateTime = date.new()
func _ready():
var TimeTest = OS.get_datetime()
print(TimeTest)

View File

@ -9,6 +9,16 @@
config_version=4
_global_script_classes=[ {
"base": "Node",
"class": "Date",
"language": "GDScript",
"path": "res://Date.gd"
}, {
"base": "Node",
"class": "Die",
"language": "GDScript",
"path": "res://Die.gd"
}, {
"base": "Resource",
"class": "SaveGame",
"language": "GDScript",
@ -20,6 +30,8 @@ _global_script_classes=[ {
"path": "res://SaveSystem/SceneObject.gd"
} ]
_global_script_class_icons={
"Date": "",
"Die": "",
"SaveGame": "",
"WorldObject": ""
}