Added item resource

This commit is contained in:
gotfishmakesticks 2023-11-06 12:12:22 +03:00
commit 679a3187f7
3 changed files with 50 additions and 22 deletions

15
items/test_item.tres Normal file
View file

@ -0,0 +1,15 @@
[gd_resource type="Resource" script_class="Item" load_steps=4 format=3 uid="uid://bii3yrhoqcket"]
[ext_resource type="Texture2D" uid="uid://c3gei46k8muk3" path="res://sprites/laserbox.png" id="1_e5k7o"]
[ext_resource type="Script" path="res://scripts/item.gd" id="1_s7nhb"]
[ext_resource type="Texture2D" uid="uid://dbwvej0c5bl52" path="res://sprites/ship mk1.png" id="2_l1qse"]
[resource]
script = ExtResource("1_s7nhb")
name = "Test Item"
min_price = 10.0
max_price = 100.0
stack_size = 5
icon = ExtResource("1_e5k7o")
image = ExtResource("2_l1qse")
type = 0

View file

@ -2,11 +2,15 @@ extends Node
class_name Game class_name Game
enum ITEM_TYPE {VALUABLE, WEAPON, MODULE}
static var gameversion = "Ictar 1.1" static var gameversion = "Ictar 1.1"
static func profile_create(profile_name): static func profile_create(profile_name):
var path = "user://"+profile_name+".cosmic" var path = "user://"+profile_name+".cosmic"
if not FileAccess.file_exists(path): if FileAccess.file_exists(path):
profile_save(profile_name, "menu")
return
var profile_meta = { var profile_meta = {
'hash' : {}, 'hash' : {},
'meta' : { 'meta' : {
@ -27,8 +31,6 @@ static func profile_create(profile_name):
var file = FileAccess.open(path, FileAccess.WRITE) var file = FileAccess.open(path, FileAccess.WRITE)
var json_string = JSON.stringify(profile_meta, "\t") var json_string = JSON.stringify(profile_meta, "\t")
file.store_string(json_string) file.store_string(json_string)
else:
profile_save(profile_name, "menu")
static func profile_save(profile_name, _gamestate): static func profile_save(profile_name, _gamestate):
var path = "user://"+profile_name+".cosmic" var path = "user://"+profile_name+".cosmic"

11
scripts/item.gd Normal file
View file

@ -0,0 +1,11 @@
extends Resource
class_name Item
@export var name : String
@export var min_price : float
@export var max_price : float
@export var stack_size : int
@export var icon : Texture
@export var image : Texture
@export var type : Game.ITEM_TYPE