Started working on DB interaction
This commit is contained in:
parent
8c9cc7e31d
commit
bf2a5b8cf1
@ -2,6 +2,13 @@ extends Node2D
|
||||
|
||||
var ShowInventory = 0
|
||||
var LeftClick = 0
|
||||
var player_inventory_items = []
|
||||
|
||||
func LoadSave():
|
||||
Database.OpenConnection()
|
||||
|
||||
func _input(event):
|
||||
pass
|
||||
|
||||
func _ready():
|
||||
pass
|
||||
|
@ -47,3 +47,5 @@ func _input(event):
|
||||
if Input.is_action_pressed("map_interaction"):
|
||||
pass
|
||||
|
||||
func _ready():
|
||||
Global.player_inventory_items = Database.GetInventoryItems()
|
||||
|
1
Menu.gd
1
Menu.gd
@ -4,4 +4,5 @@ func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
func _on_Btn_PlayGame_pressed():
|
||||
Global.LoadSave()
|
||||
get_tree().change_scene("res://river_intersection_home2.tscn")
|
||||
|
@ -10,14 +10,23 @@ var empty_style: StyleBoxTexture = null
|
||||
|
||||
var ItemClass = preload("res://MiscScenes/Item.tscn")
|
||||
var item = null
|
||||
var id = 0
|
||||
#onready var id = int(self.name[4:0])
|
||||
|
||||
func _ready():
|
||||
if self.name.length() == 5:
|
||||
self.id = int(self.name.right(1)) - 1
|
||||
else:
|
||||
self.id = int(self.name.right(2)) - 1
|
||||
default_style = StyleBoxTexture.new()
|
||||
empty_style = StyleBoxTexture.new()
|
||||
#default_style.texture = default_tex
|
||||
#empty_style.texture = empty_tex
|
||||
|
||||
if randi() % 2 == 0:
|
||||
# print(self.get)
|
||||
# if randi() % 2 == 0:
|
||||
print(Global.player_inventory_items)
|
||||
print(Global.player_inventory_items[self.id])
|
||||
if Global.player_inventory_items[self.id] != null:
|
||||
item = ItemClass.instance()
|
||||
add_child(item)
|
||||
# refresh_style()
|
||||
|
31
Storage/Database.gd
Normal file
31
Storage/Database.gd
Normal file
@ -0,0 +1,31 @@
|
||||
extends Node
|
||||
const SQLite = preload("res://addons/godot-sqlite/bin/gdsqlite.gdns")
|
||||
|
||||
var path = "res://Storage/World1.db"
|
||||
var db_name = "RingOfRaces"
|
||||
var db = null
|
||||
var verbose = true
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
func OpenConnection():
|
||||
self.db = SQLite.new()
|
||||
self.db.path = path
|
||||
self.db.verbose_mode = verbose
|
||||
self.db.open_db()
|
||||
|
||||
func OpenConnectionIfClosed():
|
||||
if self.db == null:
|
||||
OpenConnection()
|
||||
|
||||
func GetInventoryItems():
|
||||
OpenConnectionIfClosed()
|
||||
var ret = []
|
||||
for x in range(40):
|
||||
ret.append([x, "test"])
|
||||
return ret
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
# pass
|
0
Storage/World1.db
Normal file
0
Storage/World1.db
Normal file
@ -1,6 +1,6 @@
|
||||
extends TouchScreenButton
|
||||
|
||||
onready var ShowInventory = get_node("res://Global.gd")
|
||||
onready var ShowInventory = Global.ShowInventory
|
||||
|
||||
func _input(always):
|
||||
ShowInventory = 1;
|
||||
|
21
addons/godot-sqlite/LICENSE.md
Normal file
21
addons/godot-sqlite/LICENSE.md
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019-present Piet Bronders & Jeroen De Geeter
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
19
addons/godot-sqlite/bin/gdsqlite.gdnlib
Normal file
19
addons/godot-sqlite/bin/gdsqlite.gdnlib
Normal file
@ -0,0 +1,19 @@
|
||||
[general]
|
||||
|
||||
singleton=false
|
||||
load_once=true
|
||||
symbol_prefix="godot_"
|
||||
reloadable=false
|
||||
|
||||
[entry]
|
||||
|
||||
X11.64="res://addons/godot-sqlite/bin/x11/libgdsqlite.so"
|
||||
Server="res://addons/godot-sqlite/bin/x11/libgdsqlite.so"
|
||||
Windows.64="res://addons/godot-sqlite/bin/win64/libgdsqlite.dll"
|
||||
OSX.64="res://addons/godot-sqlite/bin/osx/libgdsqlite.dylib"
|
||||
|
||||
[dependencies]
|
||||
X11.64=[ ]
|
||||
Server=[ ]
|
||||
Windows.64=[ ]
|
||||
OSX.64=[ ]
|
8
addons/godot-sqlite/bin/gdsqlite.gdns
Normal file
8
addons/godot-sqlite/bin/gdsqlite.gdns
Normal file
@ -0,0 +1,8 @@
|
||||
[gd_resource type="NativeScript" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/godot-sqlite/bin/gdsqlite.gdnlib" type="GDNativeLibrary" id=1]
|
||||
|
||||
[resource]
|
||||
resource_name = "gdsqlite"
|
||||
class_name = "SQLite"
|
||||
library = ExtResource( 1 )
|
BIN
addons/godot-sqlite/bin/osx/libgdsqlite.dylib
Normal file
BIN
addons/godot-sqlite/bin/osx/libgdsqlite.dylib
Normal file
Binary file not shown.
BIN
addons/godot-sqlite/bin/win64/libgdsqlite.dll
Normal file
BIN
addons/godot-sqlite/bin/win64/libgdsqlite.dll
Normal file
Binary file not shown.
BIN
addons/godot-sqlite/bin/x11/libgdsqlite.so
Normal file
BIN
addons/godot-sqlite/bin/x11/libgdsqlite.so
Normal file
Binary file not shown.
14
addons/godot-sqlite/godot-sqlite.gd
Normal file
14
addons/godot-sqlite/godot-sqlite.gd
Normal file
@ -0,0 +1,14 @@
|
||||
# ############################################################################ #
|
||||
# Copyright © 2019-present Piet Bronders & Jeroen De Geeter <piet.bronders@gmail.com>
|
||||
# Licensed under the MIT License.
|
||||
# See LICENSE in the project root for license information.
|
||||
# ############################################################################ #
|
||||
|
||||
tool
|
||||
extends EditorPlugin
|
||||
|
||||
func _enter_tree():
|
||||
pass
|
||||
|
||||
func _exit_tree():
|
||||
pass
|
7
addons/godot-sqlite/plugin.cfg
Normal file
7
addons/godot-sqlite/plugin.cfg
Normal file
@ -0,0 +1,7 @@
|
||||
[plugin]
|
||||
|
||||
name="Godot SQLite"
|
||||
description="GDNative wrapper for SQLite (Godot 3.1+), making it possible to use SQLite databases as data storage in all your future games."
|
||||
author="Piet Bronders & Jeroen De Geeter"
|
||||
version="1.7"
|
||||
script="godot-sqlite.gd"
|
@ -1,10 +1,10 @@
|
||||
extends TileMap
|
||||
|
||||
|
||||
|
||||
onready var player = get_node("/root/Map1/Player")
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
|
||||
pass # Replace with function body.
|
||||
|
||||
func _get_cell_size():
|
||||
|
@ -21,7 +21,8 @@ config/icon="res://pictures/gui/buttons/delete_ringofraces.png"
|
||||
|
||||
[autoload]
|
||||
|
||||
Global="*res://Global.tscn"
|
||||
Global="*res://Global.gd"
|
||||
Database="*res://Storage/Database.gd"
|
||||
|
||||
[display]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user