Jump to content

gordonramp

Members
  • Posts

    398
  • Joined

  • Last visited

Posts posted by gordonramp

  1. This is Great. I'm wondering how to turn it on and off. I've included it in a simple scene in which I move around. When I hit the tilde button the console appears but has lots of wwwwwwwwwwwwwwwwws in it. Hence my query. How to turn it on only when the Tilde button is pressed.

  2. I think this is something for Josh to put right. He is often telling potential customers to go the Lua way, so if they do then there needs to be 'seamless compatibility' between the Editor and the Lua Engine. Workarounds can only achieve so much and they often lead to complications. It's great that we have got this far but I don't think it's time to get too confident yet. :lol:

  3. Good point, Internet Explorer 7.

    I just downloaded Google Chrome and copy and paste between code tags formats with it. So I guess I'll be using Google Chrome in the future. Thanks. However don't expect my code to be always indented, I actually prefer it nice and neat against the left hand margin. Easier to read. :)

  4. I'm glad you brought that up. What I find is that code in code tags on this forum doesn't copy and paste with wordwrap ie. it pastes as one long line and takes forever to format, (please explain how to do it if I'm incorrect). So I figure I'm making life easier for people by putting my code in quotes which does paste with wordwrap (formatiing). Also, indentation is not a requirement of coding, it is only a preference by some.

  5. With some adjustments and input from Lumooja's fpcontroller code, this now works in the Editor and outside the Editor.. No Gun but has Flashlight.

     

     

    function round(num, idp)        
    return tonumber(string.format("%." .. (idp or 0) .. "f", num))
    end
    BLEND_NONE=0
    BLEND_ALPHA=1
    --
    if fw==nil then --we are not in Editor        
    RegisterAbstractPath("")        
    Graphics(800,600)        
    fw=CreateFramework()        
    scene=LoadScene("abstract::tunnels.sbx")        
    scene:SetCollisionType(COLLISION_SCENE)        
    TFilter(1)        
    AFilter(4)        
    standalone=1
    end
    require("Scripts/constants/collision_const")
    require("Scripts/constants/engine_const")
    require("Scripts/LinkedList")
    require("Scripts/filesystem")
    require("Scripts/math/math")
    
    dx=0.0
    dy=0.0
    camerapitch=0.0
    camerayaw=0.0
    move=0.0
    strafe=0.0
    
    --Create a player controller
    controller=CreateController(1.8,0.45,0.25,45)
    controller:SetCollisionType(COLLISION_CHARACTER,0)
    controller:SetMass(10)
    if standalone==1 then        
    controller:SetPosition(Vec3(42.0,1,-10))
    else        
    controller:SetPosition(fw.main.camera.position)
    end
    camerapitch=fw.main.camera.rotation.x
    camerayaw=fw.main.camera.rotation.y-90
    HideMouse()
    MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2)
    FlushKeys()
    FlushMouse()
    local pick
    local camera = fw.main.camera
    local remainingtime
    local starttime=AppTime()
    local gameduration=2--length of game in minutes
    local gamemode=0
    
    --Flashlight
    flashlight = {}
    flashlight.light = CreateSpotLight(8)
    flashlight.light:Hide()
    flashlight.sound_switch = LoadSound("abstract::switch.wav")
    flashlight.state=0
    flashlight.light:SetConeAngles(30,35)
    flashlight.light:SetRotation(Vec3(5,0,0))
    flashlight.light:SetShadowmapSize(512)
    flashlight.light:Paint(LoadMaterial("abstract::flashlight.mat"))
    function flashlight:SetState( state )        
    if state~=self.state then                
    self.state=state                
    if state==0 then                        
    self.light:Hide()                
    else                        
    self.light:Show()                
    end                
    if self.sound_switch~=nil then                        
    self.sound_switch:Play()                
    end        
    end
    end
    
    --main function
    while KeyHit(KEY_ESCAPE)==0 do        
    jump=KeyHit(KEY_SPACE)*6.0        
    if controller:IsAirborne()==1 then jump=0 end        
    local time = AppTime()/3200.0        
    local frame = time*(179.0-96.0)+96.0        
    frame=Clamp( frame, 96, 179 )        
    --Camera look        
    gx=Round(GraphicsWidth()/2)        
    gy=Round(GraphicsHeight()/2)        
    dx=Curve((MouseX()-gx)/4.0,dx,3.0/AppSpeed())        
    dy=Curve((MouseY()-gy)/4.0,dy,3.0/AppSpeed())        
    MoveMouse(gx,gy)        
    camerapitch=camerapitch+dy        
    camerayaw=camerayaw-dx        
    camerapitch=math.min(camerapitch,90)        
    camerapitch=math.max(camerapitch,-90)        
    fw.main.camera:SetRotationf(camerapitch,camerayaw,0,1)        
    movespeed=6        
    movesmoothing=10        
    if controller:IsAirborne()==1 then                
    movesmoothing=200        
    end 
    
    --Player movement        
    move=Curve( (KeyDown(KEY_W)-KeyDown(KEY_S))*movespeed,move,movesmoothing)        
    strafe=Curve( (KeyDown(KEY_D)-KeyDown(KEY_A))*movespeed,strafe,movesmoothing)        
    
    
    --Update controller        
    controller:Update(camerayaw,move,strafe,jump,40,10)        
    fw:Update()        
    if KeyHit(KEY_F)==1 then                
    flashlight:SetState(1-flashlight.state)        
    end
    
    --Position camera        
    camera:SetPositionf(controller.position.x,controller.position.y+0.8,controller.position.z,1)        
    time=AppTime()        
    
    
    flashlight.light:SetPosition(fw.main.camera:GetPosition(1))        
    flashlight.light:SetRotationf( CurveAngle( fw.main.camera.rotation.x, flashlight.light.rotation.x, 3.0/AppSpeed() ), CurveAngle( fw.main.camera.rotation.y, flashlight.light.rotation.y, 3.0/AppSpeed() ) )        
    flashlight.light:Movef(-0.07,-0.04,0.02)        
    fw:Render()        
    
    Flip(0)
    end
    controller:Free()
    
    ShowMouse()

  6. As the Framework is now accessible with Lua outside of the editor, I've revisited my fpcontroller code.. I can load a scene and look around with mouselook but am unable to move.. can someone tell me why..

     

    fpcontroller revisited
    
    require("Scripts/constants/collision_const")
    require("Scripts/constants/engine_const")
    require("Scripts/LinkedList")
    require("Scripts/filesystem")
    require("Scripts/math/math")
    
    --Register abstract path
    RegisterAbstractPath("")
    
    --Set graphics mode
    if Graphics(1024,768)==0 then
    Notify("Failed to set graphics mode.",1)
    return
    end
    
    --Create framewerk object and set it to a global object so other scripts can access it
    fw=CreateFramework()
    if fw==nil then
    Notify("Failed to initialize engine.",1)
    return
    end
    SetGlobalObject("framewerk",fw)
    
    camera=fw.main.camera
    camera:SetPositionf(-4,1.2,-4)
    
    --Variables
    dx=0.0
    dy=0.0
    camerapitch=0.0
    camerayaw=0.0
    move=0.0
    strafe=0.0
    
    --Create a player controller
    controller=CreateController(1.8,0.45,0.25,45)
    
    controller:SetPosition(fw.main.camera.position)
    camerapitch=fw.main.camera.rotation.x
    camerayaw=fw.main.camera.rotation.y
    controller:Move(Vec3(0,-0.9,0))
    
    --HideEntity(vwep)
    HideMouse()
    MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2)
    FlushKeys()
    FlushMouse()
    
    local pick
    local camera = fw.main.camera
    local remainingtime
    local starttime=AppTime()
    local gameduration=2--length of game in minutes
    local gamemode=0
    
    scene=LoadScene("abstract::tunnels.sbx")
    
    light=CreateDirectionalLight()
    light:SetRotationf(45,45,45)
    
    while KeyHit(KEY_ESCAPE)==0 do
    jump=KeyHit(KEY_SPACE)*6.0
    if controller:IsAirborne()==1 then jump=0 end
    
    --Camera look
    gx=Round(GraphicsWidth()/2)
    gy=Round(GraphicsHeight()/2)
    dx=Curve((MouseX()-gx)/4.0,dx,3.0/AppSpeed())
    dy=Curve((MouseY()-gy)/4.0,dy,3.0/AppSpeed())
    MoveMouse(gx,gy)
    camerapitch=camerapitch+dy
    camerayaw=camerayaw-dx
    camerapitch=math.min(camerapitch,90)
    camerapitch=math.max(camerapitch,-89.99)
    fw.main.camera:SetRotationf(camerapitch,camerayaw,0,1)
    
    movespeed=6
    movesmoothing=10
    if controller:IsAirborne()==1 then
    movesmoothing=200
    end
    
    --Player movement
    move=Curve( (KeyDown(KEY_W)-KeyDown(KEY_S))*movespeed,move,movesmoothing)
    strafe=Curve( (KeyDown(KEY_D)-KeyDown(KEY_A))*movespeed,strafe,movesmoothing)
    
    --Update controller
    controller:Update(camerayaw,move,strafe,jump,40,10)
    
    if KeyHit(KEY_ESCAPE)==1 then break end
    
    fw:Update()
    fw:Render()
    Flip(0)
    
    end

  7. I've been trying to get mouselook and mousemovment working with the following piece of Lua code. It loads a scene outside of the Leadwerks Editor using the Lua Engine.

     

    require("Scripts/constants/keycodes")

    require("Scripts/constants/collision_const")

    require("Scripts/constants/engine_const")

    require("Scripts/LinkedList")

    require("Scripts/filesystem")

    require("Scripts/math/math")

     

    --Register abstract path

    RegisterAbstractPath("")

     

    --Set graphics mode

    if Graphics(1024,768)==0 then

    Notify("Failed to set graphics mode.",1)

    return

    end

     

    world=CreateWorld()

    if world==nil then

    Notify("Failed to initialize engine.",1)

    return

    end

     

    gbuffer=CreateBuffer(GraphicsWidth(),GraphicsHeight(),1+2+4+8)

     

    camera=CreateCamera()

    camera:SetPosition(Vec3(37,1,-14))

     

    scene=LoadScene("abstract::train.sbx")

     

     

    while AppTerminate()==0 do

     

    UpdateAppTime()

    world:Update(AppSpeed())

     

    SetBuffer(gbuffer)

    world:Render()

    SetBuffer(BackBuffer())

    world:RenderLights(gbuffer)

     

    if KeyHit(KEY_ESCAPE)==1 then break end

     

    if KeyHit(KEY_T)==1 then camera:SetPosition(Vec3(30,1,-14)) end

     

    DrawText(UPS(),0,0)

     

    Flip(0)

    end

     

     

    As soon as I add a controller I get the errors occur..

     

    require("Scripts/constants/keycodes")

    require("Scripts/constants/collision_const")

    require("Scripts/constants/engine_const")

    require("Scripts/LinkedList")

    require("Scripts/filesystem")

    require("Scripts/math/math")

     

     

    --Variables

    dx=0.0

    dy=0.0

    camerapitch=0.0

    camerayaw=0.0

    move=0.0

    strafe=0.0

     

    --Create a player controller

    controller=CreateController(1.8,0.45,0.25,45)

    controller:SetCollisionType(COLLISION_CHARACTER,0)

    controller:SetPositionf(0,2,0,0)

    controller:SetMass(10)

     

    --Register abstract path

    RegisterAbstractPath("")

     

    --Set graphics mode

    if Graphics(1024,768)==0 then

    Notify("Failed to set graphics mode.",1)

    return

    end

     

    world=CreateWorld()

    if world==nil then

    Notify("Failed to initialize engine.",1)

    return

    end

     

    gbuffer=CreateBuffer(GraphicsWidth(),GraphicsHeight(),1+2+4+8)

     

    camera=CreateCamera()

    camera:SetPosition(Vec3(37,1,-14))

     

    scene=LoadScene("abstract::train.sbx")

     

     

    while AppTerminate()==0 do

     

    UpdateAppTime()

    world:Update(AppSpeed())

     

    SetBuffer(gbuffer)

    world:Render()

    SetBuffer(BackBuffer())

    world:RenderLights(gbuffer)

     

    if KeyHit(KEY_ESCAPE)==1 then break end

     

    if KeyHit(KEY_T)==1 then camera:SetPosition(Vec3(30,1,-14)) end

     

    DrawText(UPS(),0,0)

     

    Flip(0)

    end

     

    I know there is more code to add in the loop. But it doesn't even like the variables.

  8. Well, I've spent quite a bit of time trying to get it going outside of the Editor, without success. 'Exception_access_violation' seems to be the most common error.

     

    Lumooja,

    Yes, I spent some time on that bit of code but as you said in that post, there were errors.

  9. Thats it, since the 2.3 editor came out there has been a serious shudder, flicker and disrupted image when looking at the camera's highest point, using the standard fpscontroller.lua script. That's in Editing and game mode. Anyone else noticed this and know how to remedy it? :(

  10. To be fair, he wasn't using a demo. He freely admitted that he stole the software. Let's not romaticize it by calling it pirating. Let's call it for what it is: stealing. But the problem is everyone has this opinion that since software isn't a tangible thing and they are just downloading it from the internet, that its not stealing. But of course it is. Its just harder to police software than a physical object. But I see absolutely no difference in pirating the software and someone stealing $200 out of Josh's wallet. There is no rationalization that is defendable for stealing someone else's property, whether it be a tv, software, or a turkey sandwich. It's stealing pure and simple.

    Just re-read what 'mikedee' actually said and you are right he does indicate that he has an illegal version of the software. Unacceptable. However, the notion of 'stealing $200 out of Josh's wallet' is debatable and an argument I've heard many times in the past about software 'piracy'. It implies that someone would be compelled to purchase the software were they not able to acquire it for nothing. That doesn't stack up. At most Josh has lost a potential customer and even that may not be the case because 'mikedee' has indicated that he will buy the LE. after a suitable evaluation period. There has been no theft of money from Josh's wallet because the money was never put there in the first place.

×
×
  • Create New...