Giter Club home page Giter Club logo

gd2cs.py's People

Contributors

kiriri avatar sirtobyb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

gd2cs.py's Issues

C# to GDScript

There is a certain plugin which it appears would be a benefit to my project, but unfortunately it is written in C# and I do not have that module implemented in my version of Godot.
Frankly I am not interested in going to that level of hassle for one plugin.
It would be great to have companion application to convert C# code to GDScript to hopefully allow those type plugins to be modified to work in regular Godot.
Since you obviously have the skills you must be the person for the job.
Sleep on it
Thanks
Respectfully

Upgrading the regex conversion to Godot 4

Since Godot 4 has a new type system, among other things, the current conversion don't work well with Godot 4. Many things needed to correct manually, although it is still a help in my opinion.

Here are detailed infos about the python script and the TODOs: #7 (comment) (thanks @kiriri for the infos).

The current branch for this is https://github.com/kiriri/gd2cs.py/tree/godot4 (the ui plugin is already working with Godot 4).

Maybe I'll take the time to do it, but I can't promise.

Add support for a `while` loop

It appears the while loops are not converted by the tool.

Example input:

	#remove invalid values from arr
	var i = 0
	while i < len(arr):
		if not arr[i].is_valid():
			arr.remove( i )
		else:
			i += 1

The tool leaves the while loop alone. Everything else seems to work fine around/in it.

Function brackets put in the wrong spot

In my result file I am getting every function formatted with brackets in the wrong place.
Example of output issue:

using System;
using Godot;
using Dictionary = Godot.Collections.Dictionary;
using Array = Godot.Collections.Array;

[Tool]
public class array : Godot.Object
{
	 
	class_name array_ext
	
	static public Dictionary create_lookup( Array src, String field_name )
	 {   
	 }
	
		var result := new Dictionary(){}
		foreach(var item in src)
		{
			var key = item.get(field_name);
			if(!result.has(key))
				  result[key] = item;
		}
		return result;
	
}

Not sure what is causing the issue. The file has tabs, which I think is the Godot default:

tool
class_name array_ext

static func create_lookup( src :Array, field_name :String ) -> Dictionary:
	var result := {}
	for item in src:
		var key = item.get(field_name)
		if not result.has(key):  result[key] = item
	return result

As a side note, the file doesn't have a extends type. The one added is Godot.Object, but Godot technically has a default of Reference for all non-explicit types.

Good resource, please improve it

I tried this addon with the Godot demo. I shouldn't have expected a quick fix and the results are still useful, however, its still requires effort to further convert the converted python to c# code to be free of errors. For example in player.gd .

extends KinematicBody

const CAMERA_MOUSE_ROTATION_SPEED = 0.001
const CAMERA_CONTROLLER_ROTATION_SPEED = 3.0
const CAMERA_X_ROT_MIN = -40
const CAMERA_X_ROT_MAX = 30

const DIRECTION_INTERPOLATE_SPEED = 1
const MOTION_INTERPOLATE_SPEED = 10
const ROTATION_INTERPOLATE_SPEED = 10

const MIN_AIRBORNE_TIME = 0.1
const JUMP_SPEED = 5

var airborne_time = 100

var orientation = Transform()
var root_motion = Transform()
var motion = Vector2()
var velocity = Vector3()

var aiming = false
var camera_x_rot = 0.0

onready var initial_position = transform.origin
onready var gravity = ProjectSettings.get_setting("physics/3d/default_gravity") * ProjectSettings.get_setting("physics/3d/default_gravity_vector")

onready var animation_tree = $AnimationTree
onready var player_model = $PlayerModel
onready var shoot_from = player_model.get_node(@"Robot_Skeleton/Skeleton/GunBone/ShootFrom")
onready var color_rect = $ColorRect
onready var crosshair = $Crosshair
onready var fire_cooldown = $FireCooldown

onready var camera_base = $CameraBase
onready var camera_animation = camera_base.get_node(@"Animation")
onready var camera_rot = camera_base.get_node(@"CameraRot")
onready var camera_spring_arm = camera_rot.get_node(@"SpringArm")
onready var camera_camera = camera_spring_arm.get_node(@"Camera")

onready var sound_effects = $SoundEffects
onready var sound_effect_jump = sound_effects.get_node(@"Jump")
onready var sound_effect_land = sound_effects.get_node(@"Land")
onready var sound_effect_shoot = sound_effects.get_node(@"Shoot")

turns into

public class player : KinematicBody
{
	 
	public const float CAMERA_MOUSE_ROTATION_SPEED = 0.001f;
	public const float CAMERA_CONTROLLER_ROTATION_SPEED = 3.0f;
	public const int CAMERA_X_ROT_MIN = -40;
	public const int CAMERA_X_ROT_MAX = 30;
	
	public const int DIRECTION_INTERPOLATE_SPEED = 1;
	public const int MOTION_INTERPOLATE_SPEED = 10;
	public const int ROTATION_INTERPOLATE_SPEED = 10;
	
	public const float MIN_AIRBORNE_TIME = 0.1f;
	public const int JUMP_SPEED = 5;
	
	public int airborne_time = 100;
	
	public Transform orientation = new Transform();
	public Transform root_motion = new Transform();
	public Vector2 motion = new Vector2();
	public Vector3 velocity = new Vector3();
	
	public bool aiming = false;
	public float camera_x_rot = 0.0f;
	
	onready var initial_position = transform.origin;
	onready var gravity = ProjectSettings.GetSetting("physics/3d/default_gravity") * ProjectSettings.GetSetting("physics/3d/default_gravity_vector");
	
	onready var animation_tree = $AnimationTree
	onready var player_model = $PlayerModel
	onready var shoot_from = player_model.GetNode(@"Robot_Skeleton/Skeleton/GunBone/ShootFrom");
	onready var color_rect = $ColorRect
	onready var crosshair = $Crosshair
	onready var fire_cooldown = $FireCooldown
	
	onready var camera_base = $CameraBase
	onready var camera_animation = camera_base.GetNode(@"Animation");
	onready var camera_rot = camera_base.GetNode(@"CameraRot");
	onready var camera_spring_arm = camera_rot.GetNode(@"SpringArm");
	onready var camera_camera = camera_spring_arm.GetNode(@"Camera");
	
	onready var sound_effects = $SoundEffects
	onready var sound_effect_jump = sound_effects.GetNode(@"Jump");
	onready var sound_effect_land = sound_effects.GetNode(@"Land");
	onready var sound_effect_shoot = sound_effects.GetNode(@"Shoot");

still much appreciated for the tool.

Doesn't work

Trying to use the addon gives these errors:
Cannot open file 'res://addons/gd2cs.py/scenes/Editor_UI.tscn'.
Failed loading resource: res://addons/gd2cs.py/scenes/Editor_UI.tscn. Make sure resources have been imported by opening the project in the editor at least once.
res://addons/gd2cs.py-9dbce4fd8e96dd55d183fc407b237dc108e0c7be/gd2cs.gd:176 - Attempt to call function 'instance' in base 'null instance' on a null instance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.