Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / User function must return a value if used in an expression? HELP!

Author
Message
SolaraV
3
Years of Service
User Offline
Joined: 6th Dec 2019
Location:
Posted: 3rd Dec 2021 06:29 Edited at: 3rd Dec 2021 06:37
User function 'roll camera right' must return a value if used in an expression at line 38364.


i'm trying to make it so that when I strafe the camera rolls, like in assaultcube, and in quake. roll camera is the only command that is free of the global axis.
What is the value that it's asking for and where do i put it? I don't understand? Do I need to specify z? I wouldn't think so considering that it's free of the Z and should roll itself independently. Do I have to specify whate roll camera right means? It should already know. ..
Do I need to store roll camera right as a local variable?
Actress/model/musician/ & now a game dev

Bored of the Rings
17
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 3rd Dec 2021 08:04
roll camera is an action command to tell the camera to do something, it's not a function that returns a value, see example below:


Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
SolaraV
3
Years of Service
User Offline
Joined: 6th Dec 2019
Location:
Posted: 3rd Dec 2021 18:21
Quote: "roll camera is an action command to tell the camera to do something, it's not a function that returns a value"


Thank you for the example. I'll see what I can do with it.

Why is the engine trying to use it as a function when I put it as an action alongside other actions?
What about this stripped down code? Will this work?


Why am I using ifinkey$()=a instead of if keystate(30)=1?
Actress/model/musician/ & now a game dev

SolaraV
3
Years of Service
User Offline
Joined: 6th Dec 2019
Location:
Posted: 3rd Dec 2021 19:21 Edited at: 3rd Dec 2021 19:42
and what if i want the camera to stop at 5 &-5? i have the same problem as with using plroffsetanglez#... the only command that stops at 5 is $CAZ but that is global instead of local to the player

I fixed it to A&D but camera keeps spinning until the key is released, it doesnt stop at 5 degrees


I believe I need to use SET CAMERA RANGE but i tried multiple versions of this and I keep getting errors


Actress/model/musician/ & now a game dev

Bored of the Rings
17
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 3rd Dec 2021 19:39
No problem with using keystate, I use it if I want to detect multiple keys at once e.g. ctrl+shift+<any key>

Good to see another fellow musician/actor on the forums
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
SolaraV
3
Years of Service
User Offline
Joined: 6th Dec 2019
Location:
Posted: 3rd Dec 2021 19:45 Edited at: 4th Dec 2021 00:32
OH cool, you play? Very nice to see another musician indeed.
BTW after using inkey i think i prefer it, if i can just set the camera range now i'll be thrilled

EDIT:
SET CAMERA RANGE was not what i thought, so i found this:


but adding it to the above code didnt stop the camera

and if I add these conditions i get either "command line out of place" on endwhile, or if i remove endwhile I get" could not close nest during the compile"




Please help I'm a NEWB to dark basic pro and I'm doing my best with my limited experience from the commodore 64. Also I dont even think my code would work because there are no if's ands or thens, but if i try to set the condition of already at 5 degrees do nothing i get parameter errors of can only have 1 parameter.


And this doesn't work either, i still get command out of place on the line with endwhile



i understand that this is basically a free flight control, but even if i were making a flight sim I would still have to limit the roll based on what type of aircraft i was flying, like for instance a 747 can't do barrel rolls, it's impossible. so maybe i need to attach some type of physics to the camera? But i've been at this almost every day for weeks. this is a lot of work for a simple camera tilt while strafing
Actress/model/musician/ & now a game dev

Scorpyo
20
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 4th Dec 2021 08:29 Edited at: 4th Dec 2021 08:44
try this to limit the roll:

if inkey$()="d" and rollvalue#<5 then rollvalue#=5:roll camera left 0,rollvalue#
if inkey$()="a" and rollvalue#>-5 then rollvalue#=-5:roll camera left 0,rollvalue#
if inkey$()="" then rollvalue#=0:roll camera left 0,rollvalue#


chafari
Valued Member
16
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 4th Dec 2021 11:07
Hi there. @SolaraV if you want the camera stop in any angle , you could use this update of BotR`s code



Cheers.
I'm not a grumpy grandpa
SolaraV
3
Years of Service
User Offline
Joined: 6th Dec 2019
Location:
Posted: 5th Dec 2021 16:27 Edited at: 6th Dec 2021 04:57
Awesome! Thanks Ya'll!

Ok so that does pretty much exactly what I want, but for some reason attaching the relevant parts to my control camera movement code doesn't work... It compiles, just no camera roll. I think it's because there's no autocam in my script???
Also, all this has me thinking ?...
Binary Space Partioning...
I saw that there was a built in command for Set Bsp Camera. How does one utilize this on an already made camera? Curious because I have a low end system, and this could make things a lot better for me if a Bsp Camera will work properly in a .dbo universe
Actress/model/musician/ & now a game dev

Login to post a reply

Server time is: 2023-01-28 06:11:55
Your offset time is: 2023-01-28 06:11:55