How does a PackedScene work when passed in an exported variable

To my beginner understanding, in order to use a scene saved on the drive, one must first use ResourceLoader.load() to load the scene to acquire a PackedScene, then instantiate it using PackedScene.instance() to acquire the Node that can be finally added as a child.

Following this principle, one can easily export a script String variable and use it to set which scene will be loaded by a node – even with convenient hints like this:

export(String, FILE, "*.tscn") var scene_path 

But that’s not fully descriptive in my opinion. I want to select a scene – an only scene – in that exported variable. Looking around the internet, this Godot Q&A post mentions one can export a PackedScene variable like any other to link to another scene. So I immediately thought of this:

export(PackedScene) var new_scene = null 

This looks much cleaner – especially the ability to initialize it to null, as well as having access to methods like can_instance() to catch any accidental false inputs int the editor… however, this looks like there is one important link of the chain I mentioned at the start missing. In the end, I’m still selecting the PackedScene as a path on disk, so when does the load() happen?

Is this a valid and correct use of the export keyword, or could this come back to haunt me later if I overuse it?

Replace in a Symbolic Derivative doesnt work with Pi/2

I was writing some small functions for GR applications, and I was defining a Function that gives me the Geodesic equations. When testing if those worked with the Schwarzschild Metric I came upon a problem when trying to replace the angle $ \theta$ with $ \frac{\pi}{2}$ this then didn’t properly simplify it when there are derivatives of $ \theta$ .

I have made a simple example to showcase what my problem is:

Sum[D[xx[[i]][\[Tau]], \[Tau]], {i, 4}] /. t -> Pi/2 

This produces the following output:

$ \left(\frac{\pi }{2}\right)'(\tau )+x'(\tau )+y'(\tau )+z'(\tau )$

What can I do to either prevent this from happening or resolve this issue?

OptionValue doesn’t work if a local variable has the same name as the function itself

The following innocent-looking code results in error.

Options[add] = {number -> 1}; add[x_, OptionsPattern[]] := Module[{add},    x + OptionValue[number] ]; add[1] 

The error is

OptionValue::optnf: Option name number not found in defaults for add$  2832. 

What triggers the error is the fact that a local variable declared by Module has the same name as the function, add. (For simplicity, I’ve shown an example where this local variable isn’t actually used in the code, but this doesn’t make a difference.)

Is this a bug in Mathematica, or some known quirk of OptionValue[]?

Post name permalink doesn’t work

I changed the permalink structure of my site from default to postname, but this does not work: trying to access a post returns me the error 404.

Then I tried to try other types of permalinks, and everyone worked (except /%postname%/, of course). So I tried to create a custom permalink: /index.php/%postname%/. This works and I can not understand why.

I tried to change the theme and to set the structure postname and everything works perfectly. From what can be due to the error?

This is my .htaccess file:

BEGIN WordPress

RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]

END WordPress

I also have Module rewrite already enabled and

<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride All Require all granted

Still doesn’t work, any ideea?

Why don’t my keypresses work in Pygame?

I don’t know why my attempt to read keypresses in Pygame is not working.

import pygame  pygame.init()    white = (255, 255, 255) green = (0, 255, 0) blue = (0, 0, 128) black = (0, 0, 0) red = (255, 0, 0)  w = 500 h = 500  x = 15 y = 480 vel = 5 screen = pygame.display.set_mode((w, h))  square = pygame.image.load(r'/Users/lanik2009/Downloads/square.PNG') square = pygame.transform.scale(square, (46, 40)) triangle = pygame.image.load(r'/Users/lanik2009/Downloads/triangle.PNG') triangle = pygame.transform.scale(triangle, (46, 40))  def player():     screen.fill(black)     pygame.draw.circle(screen,white, (15, 480), 10, 500)     screen.blit(triangle, (80, 460))     screen.blit(square, (180, 460))          running = True  while running:            for event in pygame.event.get():         if event.type == pygame.QUIT:             running = False      userInput = pygame.key.get_pressed()     if userInput[pygame.K_LEFT]:         x = -vel     if userInput[pygame.K_RIGHT]:         x = vel          player()     pygame.display.update()  

PostgreSQL connection URI fails, but parameters work

Running postgreSQL 13.2 with ssl on.

I need to connect to a database from a third party application that requires a connection URI, but it is not working. So I tested connecting with psql using two different formats with the same credentials. One worked and one didn’t.

The following command logs me into mydb as user myuser:

# psql -U myuser -d mydb -h 127.0.0.1 -p 5432 -W Password: psql (13.2 (Debian 13.2-1.pgdg100+1)) SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off) Type "help" for help.  mydb=> 

However this command fails:

# psql postgresql://myuser:MYPASSWORD@127.0.0.1:5432/mydb?sslmode=require psql: error: FATAL: password authentication failed for user "myuser" 

I am using exactly the same credentials. I’ve verified it more than 10 times. Removing "sslmode=require" does not fix the problem.

My pg_hba.conf file contains:

host   mydb   myuser   127.0.0.1/32   password 

I made it the first line in my pg_hba.conf file, so it can’t be getting hung up on any other line.

What am I doing wrong?

Applying replacement rules to products doesn’t work as expected

I have the following issue: I’d like to apply some replacement rules, for example

rules:={f[x]/t :> ff[x], g[x]/t :> gg[x]} 

to an expression, e.g. like this:

(f[x]*g[x]/(t^2))/. rules 

Surprisingly, this doesn’t give the expected result

ff[x]*gg[x] 

How do I fix this? Sorry if it’s an easy question, I’m still a beginner with Mathematica.

Loco translated language files in plugin folder don’t work

I created an own plugin wished to make it translatable. So I made a template with loco translate. pot file was put to plugins/my-plugin/lanuages/ folder as desired. Than I made a translation to my language (hungarian) to the same location. Nothing happend. Than I created one more translation on the same language but not to Author (plugins/my-plugin/languages) destination but System (languages/plugins/my-plugin). And it worked that way. I dont’t now why it does not work in plugin folder. Plugin header is set to /languages/ to store the translation files. POT file also got there by default so it has no sense. I want to provide some translation with my plugin but it would work if the translation were in plugin not in system folder. Any idea?