metaldc4life Posted September 12, 2014 Share Posted September 12, 2014 Hi, I was needing help with this script for godrays please.. camera->SetKeyValue("godray_pos", std::string(Vec3(-x, -y, -z))); I get the error below: "C:/Users/Gaming Rig/Documents/Leadwerks/Projects/MyGame/scripts/godrays.lua" : 1 : '=' expected near '-' Quote Link to comment Share on other sites More sharing options...
whiterabbit Posted September 12, 2014 Share Posted September 12, 2014 That is C++ code, you are using Lua. Changing -> to : fixes your initial error, but you'll get another error once it gets to std::string I haven't seen the god ray script but I think this is what you need: camera:SetKeyValue("godray_pos", Vec3(-x, -y, -z)); Quote Link to comment Share on other sites More sharing options...
metaldc4life Posted September 12, 2014 Author Share Posted September 12, 2014 oh...lol i'm new to all this but LOVE it. anyways, thank you i'll try it out! =) Quote Link to comment Share on other sites More sharing options...
metaldc4life Posted September 12, 2014 Author Share Posted September 12, 2014 well, I tried it and I got this: "C:/Users/Gaming Rig/Documents/Leadwerks/Projects/MyGame/scripts/godrays.lua" : 1 : attempt to index global 'camera' (a nil value) Quote Link to comment Share on other sites More sharing options...
Guppy Posted September 12, 2014 Share Posted September 12, 2014 Self.camera or where ever you store the camera reference Quote System: Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k Link to comment Share on other sites More sharing options...
metaldc4life Posted September 12, 2014 Author Share Posted September 12, 2014 Hi Thanks for the reply but what do you mean by where I store it I don't understand? Quote Link to comment Share on other sites More sharing options...
metaldc4life Posted September 12, 2014 Author Share Posted September 12, 2014 I think I'm starting to understand a little now and if my theory is correct, the reference would be in the player script and I would use this line somehow: self.camera = self.Camera but how would I implement it into this script properly? camera:SetKeyValue("godray_pos", Vec3(-x, -y, -z)); Quote Link to comment Share on other sites More sharing options...
shadmar Posted September 12, 2014 Share Posted September 12, 2014 You can attach this to your directional light as a script to get the correct calculations : function Script:Start() self.world=World:GetCurrent() if self.camera==nil then for i=0,self.world:CountEntities()-1 do if self.world:GetEntity(i):GetClass()==Object.CameraClass then self.camera=self.world:GetEntity(i) tolua.cast(self.camera,"Camera") System:Print(self.world:GetEntity(i):GetClassName()) break end end end if self.camera then local light=self.entity self.dir = Vec3(light.mat.k.x,light.mat.k.y,light.mat.k.z):Normalize() --sun raw position is then: self.sunrawpos=Vec3(-self.dir.x,-self.dir.y,-self.dir.z) self.camera:SetKeyValue("godray_pos",self.sunrawpos:ToString()) end end 2 Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
metaldc4life Posted September 12, 2014 Author Share Posted September 12, 2014 got it working! thanks! do you happen to know how to adjust the x, y axis on the mouse because I have this water script that I downloaded from klepto that I attached to the player but it won't let me look up or down.. it prevents me from looking up or down... Thanks again! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.