Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Float: How it took me two hours to assign a variable

Ok u might think i'm an idiot right? it took me two hours to assign a variable.

This all wraps around back to the inv system i talked about. if u don't remember/read/or even see that then here's a brief explanation.

u collect an item it add a string to a list.

u place a block it removes that block from the list

if mine a block then it adds that block to that list.

get it? alright good. I had started to develop a fullscreen menu and after two hours it functioned.

there was only one problem, it only had ONE slot!

so i had to fix this.

My first idea looked like this

var randomAssigner = RandomNumberGenerator.new()

func _ready():

var list = []

var randomAssignerReciever = randomAssigner.randf_range(1, 2)

list.append(randomAssignerReciever)

Then comes the problem.

u see i needed to assign the random number to TWO objects, using the same script.

but they both came out the same.

i varied it with similar outcomes

here was this methods successor

extends Button

var inv = []

var storageSpace = []

var selected

var clicked = 0

var value = 0

func _ready():

selected = Global.get_node("Player").selected

inv = Global.get_node("Player").inv

storageSpace.append(round(rand_range(1, 2)))

print(storageSpace)

it had finally worked! the rand_range function had assigned each objects a random number from 1 to 2

thats all the latest

the next devlog tommorow!

Support this post

Did you like this post? Tell us

Leave a comment

Log in with your itch.io account to leave a comment.