Solved Help with script error

Question that is answered or resolved.

kimono

Well-known member
Hi, I'm trying to fix some scripts errors like this:
Code:
@script
	void self = getlocalvar("self");
	float x = getentityproperty(self, "x");
	float z = getentityproperty(self, "z");
	float b = getentityproperty(self, "base");
	changeentityproperty(self, "velocity", 0,0,0);
	changeentityproperty(self, "position", x,z,b);
	changelevelproperty("cameraxoffset", 300);
	@end_script

Function changelevelproperty(prop, value) received invalid value(s).
Dumping values: <VT_EMPTY>  Unitialized,
Script function 'changelevelproperty' returned an exception, check the manual for details.
parameters: 3, <VT_EMPTY>  Unitialized, 

********** An Error Occurred **********
*            Shutting Down            *

There's an exception while executing script 'updateentityscript'

Is it something wrong with this cameraxoffset defining?
 
The problem is not the value since there is nothing wrong with it.  I tested the code as an animationscript and it works. One thing i noticed on your log is that the it say this is an 'updateentityscript', not an animationscript. Can you show as  what ype of script and where is this declared  in the game?
Because if this is declared on an entity main script.c file then it's wrong and it will never work.

 
magggas

i searched in the manual for "cameraxoffset" and it does not find anything

the closest i found is :

cameraoffset {x} {z/y}

    ~This command is used to control point the camera focuses on.
    ~Camera means view of game. You won't see any effect of this unless your levels are wide.
    ~Positive value for {x} shifts camera right, for {z/y} shifts camera up.
    ~Negative value for {x} shifts camera left, for {z/y} shifts camera down.

??
 
oldyz said:
magggas

i searched in the manual for "cameraxoffset" and it does not find anything

the closest i found is :

cameraoffset {x} {z/y}

    ~This command is used to control point the camera focuses on.
    ~Camera means view of game. You won't see any effect of this unless your levels are wide.
    ~Positive value for {x} shifts camera right, for {z/y} shifts camera up.
    ~Negative value for {x} shifts camera left, for {z/y} shifts camera down.

??

This on the manual you are showing here is the hardcoded version of this command and it accepts two values, one for x and one for z. Now the script version of this command is separeted for x and z with their respective names. So for script there is cameraxoffset and camerazoffset separately unlike the hardcoded version of this command.

You can just try the hardcoded command on a level and see what it does. Basicly it is adjusting the screen depending on players position. mostly useful for wide z walkable areas, so the camera will follow you in depth in or out like in the video below.

Edit: Here i have some example videos of cameraoffset command vs cameratype command, you you can get the idea of what it does:

Cameraoffset:
Cameratype 1:
 
Thank you, maybye the error comes from here with "camdef" that is not correctly defined:
Code:
//camera
	if(getglobalvar("camctr")>=1){
		if(vAniID == openborconstant("ANI_FOLLOW2") && !iAttack4){
			if(playerkeys(iPIndex, 0, "movedown") && getglobalvar("camnew")==0){
				setglobalvar("HDtime",time);
				setglobalvar("camdef",getlevelproperty("camerazoffset"));
				setglobalvar("camnew",1);
			}
			if(playerkeys(iPIndex, 0, "movedown") && time>=getglobalvar("HDtime")+300){
				changelevelproperty("camerazoffset", getglobalvar("camdef")+60);
			}
			if(!playerkeys(iPIndex, 0, "movedown")){
				setglobalvar("HDtime",NULL());
				changelevelproperty("camerazoffset", getglobalvar("camdef"));
				setglobalvar("camnew",0);
			}
		}
		if(vAniID == openborconstant("ANI_IDLE") && !iAttack4){
			changeentityproperty(self, "aiflag", "attacking", 0);
			if(playerkeys(iPIndex, 0, "moveup")&& getglobalvar("camnew")==0){
				setglobalvar("HDtime",time);
				setglobalvar("camdef",getlevelproperty("camerazoffset"));
				setglobalvar("camnew",1);
			}
			if(playerkeys(iPIndex, 0, "moveup") && time>=getglobalvar("HDtime")+300){
				changelevelproperty("camerazoffset", getglobalvar("camdef")-60);
				if((vAniPos<32 || vAniPos>39) && vAniPos!=0){
					updateframe(self,59);
				}	
			}
			if(!playerkeys(iPIndex, 0, "moveup")){
				setglobalvar("HDtime",NULL());
				changelevelproperty("camerazoffset", getglobalvar("camdef"));
				setglobalvar("camnew",0);
			}
		}
Edit: It works when I replaced this global variable "camdef" by 0.
 
Back
Top Bottom