[solved] Can's save a script every now and then

every now and then I encounter this problem that a script wouldn’t save, not by “ctrl+s” or “save all” from the file menu. usually when I close defold and re-open the project I can make changes to that file and it would save normally. does it only happen to me? should I run defold as administrator?

as another seemingly related problem, I added “rendercam” to my project and when I changed something in the camera script, it wouldn’t save, even after closing and re-opening the project. are those files read only? should I make a copy of the camera script to be able to change it?

You can’t make and save changes to library projects (ie those with a little jigsaw puzzle piece next to the in the assets panel). The editor really shouldn’t even allow you to edit those. This will be fixed.

what’s the proper way to do it then? for a beginner of course.

	-- Put all camera data into a table for rendercam module and init camera.
	self.data = {
		active = self.active,
		id = self.id,
		nearZ = self.nearZ,
		farZ = self.farZ,
		abs_nearZ = self.nearZ,
		abs_farZ = self.farZ,
		worldZ = self.wpos.z - self.viewDistance, -- worldZ only used for screen_to_world_2d
		orthographic = self.orthographic,
		fov = self.fov,
		fixedAspectRatio = self.fixedAspectRatio,
		orthoScale = self.orthoScale,
		aspectRatio = self.aspectRatio,
		scaleMode = self.scaleMode,
		useViewArea = self.useViewArea,
		viewArea = self.viewArea,
		halfViewArea = vmath.vector3(self.viewArea) * 0.5,
		wpos = self.wpos,
		wforwardVec = self.wforwardVec, -- for calculating view matrix
		wupVec = self.wupVec, -- for calculating view matrix
		lpos = self.lpos,
		lforwardVec = self.lforwardVec, -- for zooming
		lupVec = self.lupVec, -- or panning
		lrightVec = self.lrightVec, -- for panning
		shakes = {},
		recoils = {},
		follows = {"mc"},
		following = true
	}

this table is in the init section and changing those two last parameters does the job I want, the github documentation points to those two as well, can I access those parameters from another script file? if I can, what the code looks like?

The extension designer (@ross.grams) probably knows. Ross, can you help out please?

The other solution would be to copy the entire script into your project, but that is rarely a good idea since you might run into compatibility problems with the extension if it is updated.

1 Like

I’ve found an example on how to use extensions, from what I understand I make a new script file, add it to a game object and add these lines in it:

local rendercam = require "rendercam.rendercam"

function init(self)
	rendercam.follow(go.get_id("mc"), true)
end

looks like the information exist but for more advanced users, simple things that might look like they don’t need any explanation look like huge gaps that us beginners constantly fall into :slight_smile:

1 Like

Yeah, you’re not meant to edit the Rendercam files, but the example code in your latest post is the correct way to make a camera follow another object.

One caveat though: because the init order of objects is not guaranteed, calling camera functions on init may not work correctly, depending on how you have your project set up. The “2.0 Beta” version of Rendercam lets you send some messages to the camera, which more or less solves this problem. If you want to use it, replace your dependency link with this one:

https://github.com/rgrams/rendercam/archive/2.0Beta.zip

(Sorry it’s a bit confusing, hopefully by the end of this month I will find the time to clean things up and make a proper release out of this . . . )

2 Likes

sure, I’ll give it a try, thanks for the awesome work.

1 Like