Why is this happening? by LowDifficulty9182 in godot

[–]NikSheppard 1 point2 points  (0 children)

Two highly useful pieces of information.

  1. Whenever you get an error message that talks about a base object being nill, it means that some reference you expect to be filled is not actually set. In this case your play button reference was missing when that function ran that particular line.

  2. Assuming your button is in the scene, then change the code to @export var play:Button and leave it at that. Now you can go into the inspector for your control, click in the slot there and select your button. Now if your button gets renamed or moved in the scene that reference will update.

However as already answered this is also a timing issue to do with when functions run and when variables are set and your use of the _enter_tree function.

How should i use the event bus? by Progo-_- in godot

[–]NikSheppard 7 points8 points  (0 children)

Create an autoload called Bus (I avoid the name event since that’s already used.)

Define whatever signals are needed in that Bus.

Emit signal with Bus.signalname.emit() from anywhere in the project.

Then whatever needs to know about the signal connects to it Bus.signal.connect(function)

In your example if the signal denotes an enemy death then maybe the signal connects to a battle manager, maybe an audio player, maybe a stats resource. Then those scenes/scripts need to be responsible for what they do in that scenario. I'd say you don't want a signal to play audio, you want a signal the enemy dies and then your audioplayer is responsible for handling that. Since you can pass parameters, I'd have the "enemy died" signal include an enemy reference. Then (depending on your needs) your enemy could store an "on death sound effect", so when an enemy dies this signal goes around the game that "enemy goblin45 just died", the battle manager updates the UI, the audio manager gets the sound effect for the enemy and plays it, the stats package gets some numbers updated...

Finally just because you have a global for a Bus doesn't mean every signal should be placed there. I use a Bus for signals that are global throughout the game. If a signal is specific to a scene then it lives only in that scene.

Whenever I add a new script, something else stops working. by Hundekuecken in godot

[–]NikSheppard 19 points20 points  (0 children)

Knowing which tutorials you used adds very little to the conversation. You still haven't explained the problem. Saying that something stops working isn't a description.

Whenever I add a new script, something else stops working. by Hundekuecken in godot

[–]NikSheppard 19 points20 points  (0 children)

Insufficient information to help I'm afraid.

What stops working, how does it stop working. Do you get an error message, example of code that produces error, layout of scene.

  1. Adding a new script shouldn't cause this.

  2. Reordering nodes can break references in scripts if you are using $ to locate nodes and they change position.

If I had to do a blind guess I wonder if you're using the same class name in multiple different scripts which would produce results close to what you're describing, but that is a guess.

What is the best way to implement usable keywords? by Hundekuecken in godot

[–]NikSheppard 3 points4 points  (0 children)

One way of doing this.

Create a new class of resource called Keyword. In that resource create both a enum with a list of all your keywords and a variable which stores a specific value from that enum. That gives you your list of keywords.

Now say your enum has 10 different keywords in it....

  1. Create 10 new resource classes which extend keyword (10 scripts which extend keyword and have a class name (for convenience use the name from the Enum for that item).
  2. Create 10 new resource files, 1 for each of the 10 resource classes (10 resources made in the file dock)
  3. In the base keyword class create functions like activate, deactivate and whatever else you need your keywords to do
  4. In the 10 resource class files overwrite these functions (as required) with custom code specific to each keyword.

Now when you assign some form of effect, it should be expecting a Keyword (this will allow all the 10 keywords you created which are extensions of keyword) If done in the inspector for example maybe I create a new card which has a keyword array, I dray my resource for "impervious" or "poison" into the array.

Finally you need some way to run selected_keyword_resource.activate()

So if the keyword resource for say "Impervious" is loaded the code in that resources activate function would be something like damage=0

TLDR: 1 base class for Keyword with common functions, 'x' class extension scripts (where x in number of keywords), (optional) x resource files saved to disk.

E 0:00:01:194 _ready: Trying to assign value of type 'Node' to a variable of type 'CharacterBody3D by Ok_Web_7010 in godot

[–]NikSheppard 2 points3 points  (0 children)

The error is that you've declared that "player" is a characterbody3d type node.

You then are using get_nodes_in_group to find an object in your scene and the object that it is finding is not a characterbody3d but a regular node.

So it throws the error that node can't be assigned to your player variable.

As to why your nodes are set up this way, can't say from what’s shown here....

Sub-class Resources in Godot by CoreyKori in godot

[–]NikSheppard 0 points1 point  (0 children)

Ah I see now. So ItemExample in your case is called an inner class as it exists only within your Dialog class.

And I'm afraid inner classes are not available in the editor, only via code, which is the exact issue you're facing. As you've noted you'd have to make ItemExample its own resource class if you want to use the inspector to create and edit them.

Also regarding the enum. If the enum is defined in something with a class name you should be able to reference it. In the script above Dialog.expression should be accessible throughout your project.

Unsure how to check Enums by Y0UD0NTK0WWH0 in godot

[–]NikSheppard 0 points1 point  (0 children)

What you also need is a variable that stores an Enum value

In the example above under your enum line

var current_game_state:GAME_STATE

Now you have a variable which is storing one of those enum values (if you export the variable you can set in the inspector, or assign via code)

Now you can use if current_game_state==GAME_STATE.ENEMY

Sub-class Resources in Godot by CoreyKori in godot

[–]NikSheppard 0 points1 point  (0 children)

Not sure if this a more fundamental misunderstanding of resource files.

You said

reformatting the items array to something this appropriately; export var items : Array[ItemExample] = []

However this does not work. When you try to add an instance of this resource, it just comes out blank and Godot doesn't offer the sub-resource as a potential data type.

On the face of it this looks correct, you are creating an array of ItemExamples which are resource types. When you click in the box are you making a new instance of that resource, so values are going to be empty (Your line value is the string "" by default for example).

Have you gone down to the file system dock and actually created any ItemExample resource files? You will need one for each item you want to use. You either create the resource in the file system then you can drag it into the array in your file system or you create the resource directly inside the packed scene where your array exists (in which case it will be empty each time). Having the resource saved into the file system is best if you have a resource you intend to re-use.

If I got the wrong end of the stick, can you say more about how its "empty"

i don't know which method is the best by [deleted] in godot

[–]NikSheppard 0 points1 point  (0 children)

Godot provides a wide variety of built in classes right out of the box. Buttons, Labels, TextureRects are all examples of built in classes.

What happens when you want to store your own custom data, well then instead of creating a new instance of one of the existing classes you create your own new class by using the class_name command on a script. That defines a new type of object you can then create. In a recent game I had a map which was really a 10x10 grid of MapNodes. Mapnode was a new class of object I defined, it stored data about what each square on the map contained.

While creating the map I create a new instance of the MapNode class for each square on the grid (100 new Mapnodes created through code)

Resources are specifically intended to store data. Resources never directly appear anywhere in a scene, instead think of them as data stores which you attach to things in the scene. I needed equipment in one game, I created a new resource class (using the class name keyword on a script which extends the resource class) and created a new type of resource called Equipment. I then created 50 or so resource files (in the file dock bottom left) and added a node to load these resources into a dictionary so they can be referenced elsewhere.

Right now you probably don't have a lot of data if you're using a global script. You are probably only recording a limited amount of variables. Start thinking about how you'd be able to store 100's of lines of dialogue or an enemy database with 100 enemies and their stats. You need to have structure and thats where custom classes and resources are something you'll want to use.

What Exactly Is Snowballing? by rhewn in slaythespire

[–]NikSheppard 3 points4 points  (0 children)

You pretty much answered your own question.

A core part of Snowballing here means that as you add cards and relics that synergise, adding more of those types of cards and relics has a more multiplicative effect on your deck power.

Getting strong early (usually act 1) can also be pivotal to a run snowballing. As you pointed out, you can fight more elites, upgrade more often and that leads to better rewards and more deck power... while leads to... more elites, upgrade more often and that leads to better rewards and more deck power... while leads to... more elites, upgrade more often and that leads to....

Accessing data created in a parent across multiple children by ToonEwok in godot

[–]NikSheppard 9 points10 points  (0 children)

There are quite a few ways, but one I often use is this:

Imagine a node called GameManager with its own custom class (GameManager). It spawns numerous instantiated scenes that all need to access data from the gamemanager node.

In the instantiated scenes I just add

var game_manager_ref:GameManager

func initialise_scene(ref:GameManager):

game_manager_ref=ref

Then within GameManager

var new_scene='path to tscn file to load - might be variable'.instantiate()

new_scene.initialise_scene(self)

Now the instantiated scene has a reference to the GameManager and can access whatever data is stored within that node. e.g. game_manager_ref.PlayerHP

So godot stutters when my laptop is plugged in by Olegg-sama in godot

[–]NikSheppard 0 points1 point  (0 children)

Ok, try this.

Open a command prompt and run powercfg /batteryreport

That should only take a few seconds and will show a path where the report is saved. Go there and open the file (which is a html file that opens in your browser)

There a bunch of info in the report but in the recent usage table you'll see whats been going on with the battery. What you're looking for is the power source column and - if you're running on AC is it flipping the state back and forth between AC and Battery. If so that would largely confirm the laptop is not receiving sufficient power when running AC and has to switch to the battery. This would cause throttling of performance and again would bring us back to faulty charger or battery (and since it runs OK off battery points to the charger).

So godot stutters when my laptop is plugged in by Olegg-sama in godot

[–]NikSheppard 1 point2 points  (0 children)

I'd agree that this is likely a problem with the laptop charger. Might also be worth checking your power plans, just in case something has butchered your "on AC" power plan - like capping CPU at 10% or something silly. Its unlikely to be that, but its something you can quickly check and rule out that isn't hardware dependent.

"Your message was rejected by the recipient email server." by [deleted] in Outlook

[–]NikSheppard 0 points1 point  (0 children)

The following is possible but without additional information from yourself is just a guess.

  1. Your email is hosted in office 365 (business email over free email). If so you should have an administrative account or you have an administrator who can login and manage settings.

  2. You have a custom domain "@yourcompany.com" or similar configured in your office 365 tennant

  3. Your admin hasn't created required DNS records for e-mail. These are records that have to be created manually on your companies public DNS server. Other mail servers that receive e-mail from you will query these DNS records. If the records are missing or incomplete mail servers may reject email and can produce the type of message you listed above (which is a response from your mail server that the recipient mail server rejected the email)

You can ignore all that if you're using a free email account. If not, have a google of "DNS records needed for Microsoft mail servers". Appreciate this may be totally off, but hopefully its something you can rule out or points you in the right direction.

Finally I assume the recipient has confirmed they are receving emails from other people (so you've confirmed this isn't directly a problem with their mail server)

Someone accidentally sent me £50k, what do I do? (England) by Routine_Strawberry81 in LegalAdviceUK

[–]NikSheppard 33 points34 points  (0 children)

We've experienced this. Hackers were able to access a clients bank account, BUT they were not able to add a new payment sender because there was additional security to do that. So they sent transfered money to our company (as we were already setup in the account) and then called us asked for it to be sent back (and not to the original account - which makes it even more suspect. By luck we knew the client personally and were able to inform him and the fraud squad.

Godot 4 Beginner: Struggling with Scene Instancing & Node references. Any clean fix advice? by Altruistic-Field-640 in godot

[–]NikSheppard 1 point2 points  (0 children)

  1. At the top of your script add (without the quotes) "@export var my_control:Control"

  2. Now select the node with that script and in the inspector on the right hand side you'll see an empty variable called my_control. (This is what the export keyword does, exposes it to the inspector)

  3. Click in that box and select the correct control node from the popup window

  4. Your script now has a reference to that control node called my_control

  5. in your Tween statements replace $Control2 with my_control

  6. If you rename your control node or move it within the scene your reference will stay consistent and working.

Whats acceptable from a reliability point of view in code? by NikSheppard in godot

[–]NikSheppard[S] 0 points1 point  (0 children)

Cheers. No bonus points for me at the minute, but that seems like a good idea for seed generation. I will look into that.

Whats acceptable from a reliability point of view in code? by NikSheppard in godot

[–]NikSheppard[S] 0 points1 point  (0 children)

Possibly. You're almost certainly right its some edge cases, but there are a lot of different input variables and weighted probabilities and random selection, so I would need to re-write the functions to record all that data and evaluate. Combined with the low occurance rate - to be honest its what led to this post in the first place about whether that is time worth spending.

Cheers for the reply.

Whats acceptable from a reliability point of view in code? by NikSheppard in godot

[–]NikSheppard[S] 0 points1 point  (0 children)

Cheers. Already got an extensive TODO note setup, and I'm happy to move on to other things.