Jump to content

Tindrone

Members
  • Posts

    7
  • Joined

  • Last visited

Posts posted by Tindrone

  1. 14 hours ago, Rick said:

    If this is your entire script then you can't just do self.camera like that. As the error is saying self.camera is nil. Just curious as to your thinking on why you think it would work as it can help explain why it doesn't better.

    I believed it would work because from what i understand self.camera means I am selecting the object camera which is nested in my player pivot which the script is attached to. Is there a way to do that?

  2. my script now looks like this
     

    Quote

     

    function Script:Start()


        rotateC = 0
    end

     

     

    function Script:UpdateWorld()

    self.entity:SetPosition(self.entity:GetPosition())
    self.entity:SetRotation(0,rotateC,0)
        if window:MouseDown(1) then

            local window = Window:GetCurrent()
            local pickinfo = PickInfo()
            local mpos= window:GetMousePosition()
            if (self.camera:Pick(mpos.x,mpos.y,pickinfo,0,true,2)) then
                pentity= pickinfo.entity
                name= pentity:GetKeyValue("name")
                System:Print( "picked!!!!!")

                System:Print( mpos.x)

                System:Print( mpos.y)

                System:Print( name)
                if name == "ArrowR" then
                    rotateC = rotateC + 90
                end
                if name == "ArrowL" then
                    rotateC = rotateC - 90
                end
            end
            
        end

    end

     

    whenever I click on my arrows i get this

    Quote

     attempt to index field 'camera' (a nil value)

    my camera is named lowercase like in the script and is nested in my player entity.

  3. Thanks! I looked over your code and modified mine, my question now is how do I click on specific objects, Unity has the function

    OnMouseDown()

    which detects when a specific object (IE a key or other item) is clicked, I was wondering how to do this in Leadwerks.

  4. Sorry, I am not that great at getting messages across. I suppose I should give you an idea of what I am trying to do. In my point and click game, two green arrows (represented by cones) are nested within my main camera. Clicking on the arrows changes the rotateC value to 1 and -1 respectively. I want the rotation to be set to multiply 90 by rotateC and would like for it to update constantly and thus want to call the function in UpdateWorld (in order to rotate the camera in 90 degree increments). Perhaps the way I'm going about it is completely out of whack, but I hope you can see what I'm trying to do 

  5. Hi, I'm new to Leadwerks and am attempting to make a point and click game as my first project, however when I use a function I always get the response

    Quote

    '=' expected near 'function'

    I also used the example custom function code in the documentation. Here is my code

    Quote

     

    function Script:Start()
        rotateC = 0
    End

     

     

    function CameraRotate()
        self.entity:SetRotation(0,rotateC*90,0)
    End

    function Script:UpdateWorld()

    End

     

     

    Here is the example code that also returned the same error

    Quote

     

    function SayHello()
        print("Hello!")
    end

    SayHello()

     

     

    I would be grateful if anybody could help me figure this out. I am new to LUA and the syntax is very annoying

    EDIT: I've solve the issue by changing the script, but now I get

    Quote

    attempt to index global 'Script' (a nil value)

    here is my code now
     

    Quote

     

    function Script:Start()
        rotateC = 0
    end


    function Script:CameraRotate()
        self.SetRotation(0,rotateC*90,0)
    end


    function Script:UpdateWorld()
        Script:CameraRotate()
    end

     

     

×
×
  • Create New...