Jump to content

Slimwaffle

Members
  • Posts

    245
  • Joined

  • Last visited

Posts posted by Slimwaffle

  1. I am wondering what the correct way to use this Undocumented command is? I am trying to make digging scripts for my game. I will post the code here. If I use SetElevation I get an error saying argument 5 needs to be a boolean and if I use SetHeight nothing changes and the game crashes. Getting the elevation works fine setting it is the issue. I want to be able to raise and lower the ground in game.

    Quote
    
    --Digging Script
    	if window:KeyHit(Key.PageUp) then
    	local ELPOS = self.entity:GetPosition()
    
    	raise = terrain:GetElevation(ELPOS.x,ELPOS.y)
    	terrain:SetElevation(ELPOS.x,ELPOS.y, raise + 10)
    	System:Print(raise)
    	end

     

     

  2. I was wondering if someone could help me out. I will provide the script. But for some reason enemies even when set to team id good and are not in an attack state are causing damage when walking into the collision box of their arms.

    HumanAI.lua

  3. So I have noticed that when I publish my project as standalone it puts everything into a zip folder with all of my scripts, code and assets available to the user.

    When playing other games everything is encrypted into .bin files and what not.

    I want to release this game on steam and then later on, on xbox one. How do I go about encrypting the files? Or is this something steam does after I upload it?

  4. So I was finding that delaying things for x amount of seconds was way harder then it needed to be. And I wanted to be able to make things trigger at set times. So I made a simple script for an in game clock. I am going to post it here for all to use.

    If you can't get it to work just remove the code that loads and draws the clock.tex file to screen.

    hours and minutes are globals. So you will be able to reference them from your other scripts.

    Clock.lua

  5. So I have some odd questions that I feel like might be aimed out the more advanced members of our community. I had some ideas for the project I am working on and just wanted to see if they are do-able.

    First Idea;

    Is there some kind of parameter for detecting if an entity or location is located in shadow? I was thinking it would be cool to make enemies spawn out of shadows.

    Second Idea;

    Pretty much the same thing as number 1 but for detecting if light is being cast on an entity. So I could make it that; If player is in direct sunlight then hunger and thirst reduce at a greater rate and apply heatwaves to the screen.

    Last Idea;

    What is the correct method for getting the terrain height? Is there a way I can set terrain height at location while playing the game? So that the player can hold a button to bring up an overlay to show terrain elevations and then use a second button to raise or lower the terrain. So they can dig raise or flatten ground similar to the way life is feudal does it.

    Note; I tried getting the terrain height using code from other forum posts but kept getting error messages and couldn't figure it out. 

    • Like 1
  6. Thanks mate. I am just going to do bars for now. And re-address this circle thing after getting this game more built. But I will let you know how I go and you were 100% right swapping back to bars fixed the fps drop. Running back at 60 fps now. Got it looking like this for now.

    Test.png

    • Like 2
  7. Hey guys. I need help again. So I rewrote the scripts for my HUD to look a little nicer. Using Circles instead of bars. And for some reason I am getting crazy FPS drop. With bars I was able to sit at 60fps very comfortably but using circles I drop to between 5-10fps. Can someone please help? I have looked over the code and can't figure it out. As usual I will provide the code and a screen shot. This fps drop happens even when only using one of the new scripts.

    Error.jpg

    Hungerbar.lua

    Health.lua

    ThirstBar.lua

    Staminabar.lua

  8. I have two scripts for AI. Doesn't matter which I use I get the same problem with both. No matter how low I set the sight range and hearing range enemies will target me anywhere on the map and move towards me no matter the distance.

    Here is the script I have mainly been using.

    HUD AI.lua

  9. The methods I have been using are; Importing the second script, Making variables global, and using a pick to get the value. The method varies depending on how you want the code to work. If you want the script to attach to multiple entities but the functions to be per entity I find the best way is using a pick. And if I want to add multiple scripts the best method I have seen is using pivots and making them children of the entity.

  10. So I am wanting to know how I go about showing different panels based on the item selected in the tabber widget. So basically if I select the buildings2 tab it shows a different panel that is blank. Because right now it shows the same panel regardless of what I choose.

    I will post the code I have.

      

    	--Create a Crafting panel (CRAFTING SCREEN)
    	widget = Widget:Tabber(indent,indent,craftingpanel:GetClientSize().x-indent*2,craftingpanel:GetClientSize().y-indent*2,craftingpanel)
    	widget:AddItem("Buildings1",false)
    	widget:AddItem("Buildings2",false)
    	craftingpanel:SetObject("backgroundcolor",Vec4(0.15,0.15,0.15,1))
    	
    	GameMenu.tabber = widget
    
    	local indent = 12
    	cpanel = Widget:Panel(indent,indent,widget:GetClientSize().x-indent*2,widget:GetClientSize().y-indent*2-30,widget)
    	cpanel:SetBool("border",false)
    	
    	cpanel2 = Widget:Panel(indent,indent,widget:GetClientSize().x-indent*2,widget:GetClientSize().y-indent*2-30,widget)
    	cpanel2:SetBool("border",false)
    	cpanel2:Hide()
    	GameMenu.cpanel={}
    	GameMenu.cpanel.general=ipanel
    
    	GameMenu.closecrafting = Widget:Button("Close",widget:GetClientSize().x-72-indent,widget:GetClientSize().y-28-5,72,28,widget)
    	
    	local y=20
    	local sep=40
    
    	--CRAFTING TAB START
    	
    Widget:Label("Wood Buildings",20,y,200,16,cpanel)
    	y=y+16
    	
    	GameMenu.wbase = Widget:Button("Foundation",10,y,80,30,cpanel)
    	GameMenu.wwall = Widget:Button("Wall",100,y,80,30,cpanel)
    	GameMenu.wroof = Widget:Button("Roof",190,y,80,30,cpanel)
    	GameMenu.wdoorway = Widget:Button("Doorway",280,y,80,30,cpanel)
    	GameMenu.wwindow = Widget:Button("Window",370,y,80,30,cpanel)
    	y=y+sep

     

  11. One that I think would be a great one to implement. Is a global save and load script. That works similar to WorldUpdate(). To basically get the entire world state on save and then return it when loaded.

    And thanks heaps mate. I will definitely get use out of it. I will most likely continue to use it on new projects until a better system is implemented straight into the engine.

  12. I have this working perfectly now. Soo Frigging Happy :D Thanks so much guys. Now It is setting a unique name each time it calls the save function. 

    Here is what the code looks like in case anyone is wanting to do more with these scripts. You Just need to create a global called count1 somewhere with a value of 0.

    function Script:SaveData()
        count1 = (count1 + 1)
        txt1 = (tostring(count1))
        System:Print(txt1)
        prefab = self.entity:GetKeyValue("prefab")
        self.entity:SetKeyValue("name", txt1)
        name = self.entity:GetKeyValue("name")
        pos = self.entity:GetPosition()
        rot = self.entity:GetRotation()
        
        local entityTable ={}
        entityTable.name = name
        entityTable.posx = pos.x
        entityTable.posy = pos.y
        entityTable.posz = pos.z
        entityTable.rotx = rot.x
        entityTable.roty = rot.y
        entityTable.rotz = rot.z
        entityTable.prefab = prefab

        System:Print(name..' Saved')
        return entityTable
    end
    function Script:LoadData(data)

        r1 = data.rotx
        r2    = data.roty
        r3    = data.rotz
        p1 = data.posx
        p2    = data.posy
        p3    = data.posz
        self.entity:SetRotation(r1,r2,r3)
        self.entity:SetPosition(p1,p2,p3)
        System:Print('Entity Loaded')
    end

    • Like 2
×
×
  • Create New...