Jump to content

Phodex Games

Members
  • Posts

    275
  • Joined

  • Last visited

Posts posted by Phodex Games

  1. Hi,

    no I am just calling it once. I am currently building my options menu and therefore have a class handling the options the function looks like this:

    function SysControl:SetLightingQuality(quality)
      	--this is exactly the same as I found in the fps demo level code, to set light quality
    	world:SetLightQuality(quality)
    	System:SetProperty("lightquality",quality)
    end

    But what I found out is that it seems to work if I set the light quality in the main.lua before the main loop starts. But actually I see no diffrence between the diffrent lightning levels, but I dont think that it is not working, I just think the quality difference is minimal, therefore it would be best to keep it on 0, isn't it? Maybe it has some more drastical effect if you have volumeric lighting and enviorment probes, but I havent tried that yet. I mean if this option does not affect the visuals of my scene then I am thinking about keeping it away anyway. I should also mention, that I have just a point light and NO directional light in my scene.

     

    EDIT: I did some closer research, and yes it actually works if I set the light quality before the main loop starts. But on runtime the lights still go off. I also works for the FPS level, I just did not notice as the difference on the shadows is not that huge...

  2. 21 hours ago, Gonan said:

    If so are you making the same calls in the loop in your original code, esp. World update and render.

    Yeah I changed some stuff in the main lua, but the rendering & update stuff is untouched and default. If I start the Leadwerks FPS level it works, although i cannot really see a quality difference, but lights don't go off if I change the light quality in the game menu.

    @Josh In the editor it works just fine...

  3. 1 hour ago, GorzenDev said:

    you might want to look into uv scaling/animation

    Hmm yeah that is what I am searching for, but does LW support this and if so where is the syntax for it? Is it documented somewhere?

    1 hour ago, GorzenDev said:

    some references for circular shapes

    By circular I meant something diffrent, but still interesting.

    I mean I can work around my problem myself, but this just works for uncomplex rectangular healthbars. I would like to be able to implement something like this:

    2-G_filled.png.6abdc210fd0943393a4d5a23f443e822.png

    And as you can imagine if I just scale the fill of the bar on the x-axis the whole structure gets malformed and does not fit info the bar anymore. I would need something like a mask moving from left to right hiding parts of the fill texture. I also though of kind of an animation, but then I would need like 100 images of the diffrent fill states, which I consider to be not optimal, I would like to do this via code...

  4. @GrozenDev Thanks for the answer :). Hmm, I do not use the LW GUI, but if I draw a rectangle its a single color area isnt it? Because I want a textured fill for my progress bar. I cant find DrawCircle or DrawPolygon in the Documentation where can I find that and how to use?

  5. Hi,

    I wonder how it is possible to create a more complex progress bar. Currently I do it with 2 images (one bar image & one fill image) and scale the fill image down propotionally to the fill status of the bar. But what if want a circular status bar for example, or if the structure of my fill texture gets malformed due to the scaling? How would I achieve something that overcomes that problem? Maybe you can help :)

  6. 47 minutes ago, Josh said:

    Any game that uses this method will display the same behavior.

    Hmm ok so I guess this means I cannot disable it right? Because in my actually scene (a dungeon) I personally noticed this behavior when playing. Any techniques to hide this from the user as good as possible? Maybe a normal user does not even notice, but I did as it sometimes appears even if I just turn around relatively slow...

     

  7. 26 minutes ago, Rick said:

    I know what you have is just an example an maybe you have some bigger system behind the scenes here

    Exactly, I have multiple systems which would have an advantage of this. For example I have a global character commands class giving my player & my AI access to all actions they need. This makes sense so as I want to change a mechanic I do not have to maintain this for both the AI & the player. As it is global (and I want it to be global so that you do not need to initiate it for any script (I initiate it in the main) and can call it from everywhere) I created a client management system that allows my command class to exectue its actions on as many entites as I desire, but I need to send the self "table" as an argument for every command, so the commands class knows on which entity the command should be executed, and this is what I would like to overcome.

    Eitherway I think having the functionality I explained would be a cool tool for creating systems...

  8. First of all thanks for your input. 

    1 hour ago, Rick said:

    The deeper question is why are you thinking you need this?

    Well actually its just to make my code more error proof & simple. I would like to turn something like this:

    --Example Case
    --Script1
    Script.health = 100
    function Script:SomeFunction()
    	Script2:IncreaseHealth(self, 10)
    end
    
    --Script2
    function Script:ChangeMyVariable(target, healthAdd)
    	target.health = callerSelf.health + healthAdd
    end

    Into this:

    --Example Case
    --Script1
    Script.health = 100
    function Script:SomeFunction()
    	Script2:IncreaseHealth(10)
    end
    
    --Script2
    function Script:ChangeMyVariable(healthAdd)
    	--automatically get callerSelf here
    	callerSelf.health = callerSelf.health + healthAdd
    end

    I am just asking because I though there may be an easy way of doing this, as debug.getinfo(2).name for example does print the function callers name. So can't you access the self of the caller function with this? All this is just for the sake of improving my code, it is not nessecary in the way of building a mechanic out of it.

    @Rick I already have such a Get/Set mechanic, for checking if an variable got changed since the last check, but I would not like to move all my variable management over to this system, I just use it for specific variables. However I guess I would be a good idea to do this longterm...

  9. Hmm ok thats not a bad idea to store this data directly inside the variable, but to make this work for every variable I would have to change the whole variable management, short, would need to change all variables, which would be a damn lot of work :D. Yeah I am not much into metatable as well, but I guess it would be a good idea to learn more...

    Thanks anyway, so for the moment I need to send this data as an argument, just searched for a way to do this automated.

  10. Hi Leadwerkers :),

    I am wondering for quiet a while now, if and how the two things, I will explain in a second, are possible.

    First can I grab the "self" value of an function caller WITHOUT using arguments? I would expect this to work with the lua debug.getinfo() functionality? Maybe I better explain it with pseudo code:

    --Script 1:
    function Script:Test()
      Script2:CallingThis()
    end
    
    --Script 2:
    function Script:CallingThis()
    	--get self of caller
    end

    Btw I have no idea how you offically call a "caller" maybe its calle? I dont know :D

    Second how to grab an arguments root variable. What I am already aware of is accessing variables like this self["myVariable"] so I could send self as argument 1 and "myVariable" as string in argument 2, but I am looking for a way to prevent this to optimize the code and lower the error rate. Again some pseudo code:

    --Script 1:
    Script.myVariable = 10
    
    function Script:Test()
      Script2:CallingWithArgument(self.myVariable)
    end
    
    --Script 2:
    function Script:CallingThis(argument)
    	--if I do anything with the variable argument here it only changes the local "argument" variable of course
      	--this is stupid but I guess it will explain what I mean:
      	local rootVariable = argument:GetRoot()
      	rootVariable = 20 --> myVariable is changed to 20 within the Script 1
    end

    You would do me a great favor if you would give me some input on this. I would be able to improve my code even more :)

    Thanks in advance for answering and have a nice day :)

  11. EDIT: Well seems like we both answered at the same time xD haha

    To make the game turn off you need to access the main loop, you find within the main.lua (find it in: "Scripts/main.lua"). By default Leadwerks has a build in game menu where you can quit the game, so normally there is already code inside which gives you the ability to break the main loop (which makes your game quit). You have to try around your self a bit. This is how my main loop looks:

     

    while window:Closed()==false and RunGame do 
    --this is the main loop "RunGame" is a global variable I created to handle whether the main loop is called or not
    --here is some code
    end
    
    --Now example code for exiting the game (script for any kind of entity)
    function Script:UpdateWorld()
    	if window:KeyHit(Key.Escape) then RunGame = false end
      	--Now the game exits if you press escape
    end
    
    
    --if you want to do any actions before quitting do this
    function Script:UpdateWorld()
    	if window:KeyHit(Key.Escape) then self:ExitGame() end
      	--Now it calls a function (not nessecarily needed but recommended) and this function does stuff before setting RunGame false
    end
    
    function Script:ExitGame()
      --Any code you want to apply before ending here
      System:Print("Game Quits NOW!")
      RunGame = false
     end

     

  12. 8 hours ago, macklebee said:

    What "model settings" are you referring to? Are you referring to the model's material settings? Are you talking about physics shape? Or are you talking about the appearance/physics settings that can be saved for a model once placed in the scene or saved as a prefab? Need more information or we are just guessing.

    Ah sorry, well I mean settings like normals calculation, physicsshape and scale, what you can set within the leadwerks model "editor".

  13. Hi :)

    I am currently working on a relativly huge project including about 1000 models and you can image that I dont want to adjust the model settings (like normal calculation, scale & physics shape) for every single one by hand, especially as they all need the same settings. It is very time consuming repetitive work. I know Leadwerks does not support such a thing, but maybe you have an idea or can help me working out something to do this.

    The only idea I had so far is copying the .meta file of a model I set up already and then overwrite all the other .meta files with this file, but this does not work unforunately.

  14. 3 minutes ago, Rick said:

    I do the same thing in my UI system. I don't give a real font number in my UI. Instead I just do ex_small, small, medium, large, ex_large, and fill. Each "label" is a ui widget that is basically a rectangle area and I load the font for all various sizes and then I use the text functions to figure out which size is best given the ui widget area which scales by screen resolution. This way the font always "scales" as well. Yes, it's a pain, and yes you have to load various sizes (I go by 2's) but I couldn't find any way around it to get scaling fonts that don't look all stretched if you wrote to a texture and scaled the texture.

    Hi Rick thanks for your answer, you got me an idea. I do it very similar within my system, but I could implement something so my UI system calculates all needed font sizes and then I only load those font sizes, instead of loading all fontsizes at once. But then, if you ever resize during runtime, you may need to load a new font, which I would like to prevent if happening during runtime, but that is not such a big deal, I guess I am just a little bit too perfectionist :D. Either way thanks for your input. Have a nice day!

    • Upvote 1
  15. Hi :)

    I am heavily working on my own user interface system at them moment and I wonder if there is a easy way to resize a loaded font. Example pseudo code for the functionality I am searching for:

    --Pseudo Code
    self.font = Font:Load("Arial", 6, Font.Smooth) --Load Font
    self.font:SetSize(10) --Change size during runtime

    I have a solution for this by preloading the font in all sizes and then change the rendered font. But this isn't memory efficient, or are Fonts so small that it makes no diffrence, either way it does create a lot of code :( Thanks for ideas in advance

    Markus from Phodex

  16. 1 hour ago, Josh said:

    In that situation I would either keep the object in memory and add a value like "health" or "state" that indicates it is no longer valid/alive

    I just set up a simple scenario like this. Entity 1 with script:

    Script.target = nil --entity "Target"
    Script.name = "Test"
    
    function Script:Start()
    	self.target.script:Insert(self.entity)
    end
    
    function Script:UpdateWorld()
    	if keyHit.Z then self.entity:Release() end
    end

    And entity 2 with script:

    function Script:UpdateWorld()
    	if self.target ~= nil then
    		self.target:GetPosition(true)
    	end
    end
    
    function Script:Insert(entity)
    	self.target = entity
    end

    Entity 1 has Entity 2 as target, but if I press Z now, it crashes. So now I tried the "AddRef" function (most likely used it wrong though :D)

    Entity 2 script now looks like this and gives me a object reference count error:

    function Script:UpdateWorld()
    	if self.target ~= nil then
    		self.target:AddRef()
    		self.target:GetPosition(true)
    	end
    	if self.target ~= nil then self.target:Release() end --so the target can only be released from here
    end
    
    function Script:Insert(entity)
    	self.target = entity
    end

    However the following code fixes the problem, for some reason without using AddRef:

    function Script:UpdateWorld()
    	if self.target ~= nil and self.target.script ~= nil then
    		self.target:GetPosition(true)
    	end
    end
    
    function Script:Insert(entity)
    	self.target = entity
    end

    Don't ask my how that came in my mind ^^ but why does it actually fix the crashing...

  17. 59 minutes ago, Rick said:

    He really just wants something to know if something else still exists in the world or not.

    Yes thats the point, or simpler I want my game not to crash when my player grabs an item, which is referenced somewhere else. However I was not aware of the "AddRef" function and I guess it helps me overcome some problems. I am pretty sure I can come up with a system that handels that problem, just did not know, releasing an entity can be such a complex thing.  

    I will play around with the new knowledge doing some tests. It just some very awful work to find the error source now, as I get no error message and it just crashes :(

×
×
  • Create New...