Jump to content

bansama

Members
  • Posts

    64
  • Joined

  • Last visited

Everything posted by bansama

  1. If it's not awarded based on post count, I don't think those of us who purchased on Steam can get it, unless Josh can manually add it?
  2. I see there's a demo of Leadwerks on Steam now. Any chance that allows people to download workshop items tagged as games? It would be the perfect solution to being able to have non-Leadwerks owners beta test builds and push out updates without the need to sort out hosting of files.
  3. Thanks! I had looked at Time: but hadn't realised I could use it that way. Silly really, as I used to use similar in PHP years ago (I'm very rusty with coding). But thanks to your help, I now have something to work with! Pressing F11 itself doesn't drop frame rate no, but the default set up in App.lua has any rendering toggled off with F11. I did try to create a new window, etc., to render text to, but that never worked with either Assert failed crashes or other errors. I've since added a section after the F11 toggle which seems to help. So the relevant section in App.lua now looks like this: --Render statistics self.context:SetBlendMode(Blend.Alpha) if DEBUG then self.context:SetColor(1,0,0,1) self.context:DrawText("Debug Mode",2,2) self.context:SetColor(1,1,1,1) self.context:DrawStats(2,22) self.context:SetBlendMode(Blend.Solid) else --Toggle statistics on and off if (self.window:KeyHit(Key.F11)) then self.showstats = not self.showstats end if self.showstats then self.context:SetColor(1,1,1,1) self.context:DrawText("FPS: "..Math:Round(Time:UPS()),2,2) end -- Allows text to be rendered when FPS is toggled off self.context:SetColor(1,1,1,1) self.context:DrawText("", 0, 0) end I do get frame rate drops, but only when outputting with System:Print() which I use from time to time to help with debugging. And that was the cause of my FPS drops I think with the While loop I was testing.
  4. Sorry for another question which probably has a dead easy answer, but we have to learn somewhere right? I'm trying to display text on screen for a specific time. Basically, when I "use" an object, I want to display related text for a seconds. I was hoping some kind of while loop to count down the specified amount of time would work, but it had less than desirable results. FPS drops, text not displaying, etc. Any suggestions on what I should be doing? function Script:Use(context) self.Used = "1" end function Script:PostRender(context) if self.Used == "1" then local font = Font:Load("Fonts/arial.ttf", 12) App.context:SetFont(font) if self.ObjectDescription ~="" then local DisplayTime = 0 while DisplayTime < self.DisplayTimeMax do App.context:SetBlendMode(Blend.Alpha) context:DrawText(self.ObjectDescription, 102, 22) App.context:SetBlendMode(Blend.Solid) DisplayTime = DisplayTime + 1 end end self.Used = "0" end end
  5. I've been messing around with trying to make a light switch, which I've managed to accomplish in a rather rudimentary fashion by using entity:show() and hide(). In doing so, I've noticed that the level of light when no lights are active is a bit too bright. How would I go about making it as near to pitch black as possible?
  6. Thanks all. Hopefully one day Workshop will allow content to be downloaded without owning Leadwerks. It would certainly make beta testing a lot easier too =)
  7. Given that you can specify privacy settings, I see no problem with people sharing builds with friends via workshop. It's also better than dropbox as it doesn't require additional downloads. Besides that, the workshop is set up to make updating easy for all involved, Drop box and similar don't do that. I will add that the FAQ Josh posted mentions Workshop being a good way to get games on Steam without having to go through Greenlight. So surely, people who don't own Leadwerks being able to download items published as "Games" would be good for all anyhow.
  8. Is it possible to use the Steam workshop to publish games to be downloaded by those who don't own Leadwerks? None of my friends own Leadwerks yet I'd like them to be able to test builds of my game as they become ready. Can I use the Steam workshop for this?
  9. I ended up looking into this more and seem to have found a solution that works well enough. First I added this at the start of the SwiningDoor script. The default value is what has worked best for me so far. Script.closeoffset=1.3--float "Close offset" And then making the very simple change of: self.joint:SetAngle(self.closedangle) to self.joint:SetAngle(self.closedangle-self.closeoffset) As shown below: function Script:Close()--in if self.enabled then if self.openstate then self.openstate=false if self.loopsource then self.loopsource:Release() self.loopsource=nil end if self.closesound then self.entity:EmitSound(self.closesound) end self.joint:SetAngle(self.closedangle-self.closeoffset) self.component:CallOutputs("Close") end end end
  10. @Josh Yeah, I've checked and both the door and the door frame prefab I made have their collision type set to Scene. At first I thought it might be because I'm using a prefab, but I get the same thing when I don't too. I think I'll just redesign the door frame so this is less noticeable for now. Thanks.
  11. As a follow on from this topic: http://www.leadwerks.com/werkspace/topic/10226-where-can-i-find-this-example-map/ I now have sliding doors set up. These I can now make without a problem. But in doing so I have noticed something which I think is caused by something in the sliding door script itself, but I have no idea what exactly. The problem is that once a door has been opened (I'm using the manual activate set to true, with closing delay set to 0) when you close it, it always ends up a tiny degree off from its starting point. It's as if the script is ending before the very last degree of movement so it cannot come to rest at its original position. To be honest, I doubt it's something most would notice unless specifically looking for it, but it is a little annoying nonetheless. Any ideas on what's going on and how it could be fixed?
  12. Glad to hear you got it working. I will add though that depending on the size and position of your door, you'll want to mess around with which actual offset to use (x, y, z) and try sizes that are smaller than 1.0. I found that for a door with a width of 128 cm, an offset of 0.7 works rather well.
  13. Here's what I did: 1 - Loaded up the tutorial map 03-Doors and saved it with a new name. That way any mistakes won't render the tutorial map useless should it be needed in the future. 2 - Using the second set of doors, I replaced the sliding door script for both doors with the swinging door one. 3 - Opened up the Flowgraph Editor and made sure the BoXTrigger:CollisionTrigger Collision() option was linked to the slidingdoor_left:SwingingDoor Open() and slidingdoor_right:SwingingDoor Open() options. If those don't exist in the Flowgraph Editor you may need to drag the door objects in to the Flowgraph Editor screen. 4 - Set the values in the script for slidingdoor_left: Offset 0.0, 0.0, 1.0; Pin 0.0, 1.0, 0.0 5 - Set the values in the script for slidingdoor_right: Offset 0.0, 0.0, -1.0; Pin 0.0, -1.0, 0.0 The trick will be getting the right combination of values to have any door opening on the side and in the direction you want. Hope that helps.
  14. @Josh @macklebee Thanks. It took some trial and error with messing around with both the pin and offset numbers (and some rather funny results), but have now worked out how to make traditional doors using that script.
  15. That's a shame. Is there any chance of a new one for Leadwerks 3.1 being made? An working example of how to make such doors would be extremely useful.
  16. I was searching for information on making traditional doors (i.e., those that swing outward) and found this article about the addition of joint motors: http://www.leadwerks.com/werkspace/blog/1/entry-1138-leadwerks-30-updated-with-joint-motors/ In it, it mentions a new example map showing doors that swing open. I cannot find this map anywhere. Does anyone happen to know where it can downloaded from? Thanks
  17. While I am interested in this, I won't be able to make it. 10 am CST is roughly 7 pm in my time zone (JST). And that's always a busy time for my family. It's a great idea though. Perhaps if there's enough demand you could also look into adopting a format that can be accessed at any time regardless of time zone, etc. A written format perhaps?
  18. That did it. Now I see where I was going wrong. As the function appears to be processed without being called I had not thought that calling with self:PlayerPosition(entity) was required. Your comment about globals though is something I'd like to clarify. Using local before the variable name ensures it's not a global, right? If such a variable is passed with self:FunctionName (variable) does it remain non-global?
  19. I've put some of my old code back in for now, which has gotten rid of the errors. However, what I am trying to do is fetch the player on collision. This I've now done. if entity:GetKeyValue("name") == "Player" then System:Print("Found Player") PlayerEnt = entity System:Print(PlayerEnt) return PlayerEnt end The system print shows it's found the player entity. I was hoping the return would allow that to be picked up by another function in the same script. function Script:PlayerPosition(PlayerEnt)--arg System:Print("Testing...") System:Print(PlayerEnt) System:Print("...End testing") end This system print shows that PlayerEnt has not been passed as the output is 0x00000000 and not the address found on collision. I know I don't need to do any of this. I could just handle everything within the function handling collision, but I really would like to know how to pass PlayerEnt from one function to another as I'm sure it will help in the future with other things. Right now this PlayerPosition function is where I'm testing all the coordinate stuff, ie. breaking it down into x, y, and z (which again, I've managed). The only thing holding me back with this current approach is passing that PlayerEnt between the functions. Also, thanks for the offer of helping via the IM function (I assume that's the bar at the bottom of the site, right?) if you're still around in a couple of hours, I'll take you up on that. I just need to get the children in bed first. @YouGroove Yes, I lack the knowledge I need to do what I'm trying to do, hence the topic. I appreciate your examples though they have provided some food for thought.
  20. A good point I will bear in mind. But for now it's the player I am trying to work with. The collision function finds the player, but how do I then pass the player as found by the collision function to a different function in the same script?
  21. In theory, this all makes perfect sense. In practice, I'm still getting the "attempt to index global/local 'entity' (a nil value)" errors. Which again brings me back to the question, how do a I pass variables between scripts and functions? For example if I try adding the following function to the collision script template: function Script:PlayerPosition(entity)--arg if entity:GetKeyValue("name") == "Player" then self.PlayerTarget = entity return self.PlayerTarget:GetPosition():ToString() end end I get an error that makes it clear the function cannot find the entity. As I said when I first made this topic, this is something that was so elementary easy in PHP that I just can't work out why I cannot do it in Lua and it is driving me completely crazy and leaving utterly frustrated. So I would really appreciate some concise help with actual example code so I can work out what is wrong with my own code. As YouGroove said, making errors and learning from them is good. But only if someone can help point out why it's an error and how to fix it. Otherwise, you may just end up in an infinite loop of errors and learning nothing. That's why we need teachers, and why I would really appreciate help with this.
  22. @YouGroove Thanks, I'll have a look at that in a little bit. To recap, I want to be able to reference coordinates and rotation of the player entity so I may use this information when moving the player around on a collision event inspired by the teleport tutorial found on YouTube (which, if I'm not mistaken, was uploaded by yourself?) I would prefer to be able to do this without needing to be dependent on the flow graph editor due to it wiping links. Which, so far, I still have not determined the cause of. And as I mentioned earlier, I don't want to need to loop through entities to find the player each time, when doing that once should theoretically suffice. I did have this working with the code above in App.lua, but based on your previous comments, I'm now trying to to do the same without needing to alter App.lua. So in short, I am currently trying to set up a pivot that will locate the player entity so that I may reference that entity later without having to loop through all entities to find it each time (and without needing to link to player to specific entities in the flow graph editor each time).
  23. Once again, thanks for the replies. I've been busy with work thus have had no time to revisit this for while. But I have some free time again now for a few days and with that time, another question! Am I right in that self.whatever can only be used within a function? If I try it outside of a function, I get the usual error about attempting to index a nil global. If this is so, then I'll need to slightly tweak my current code that I put in App.lua so that it's now a function. I'm also going to try moving that out of App.lua and attaching it to a pivot as its own script. EDIT: So apparently I can't get that to work either. Using the following as a script attached to the pivot: --Set player entity function Script:SetPlayerEntity() -- Locate the player entity for x=0,App.world:CountEntities()-1 do entity = App.world:GetEntity(x) entInfo = entity:GetKeyValue("name") if entity:GetKeyValue("name") == "Player" then self.EntPlayer = App.world:GetEntity(x) System:Print(self.EntPlayer) end end setPlayerEntFlag = true end if setPlayerEntFlag ~= true then Script:SetPlayerEntity() end And then trying to reference it in a different script with: self.PlayerTarget = LocatePlayerEntity.EntPlayer I get the usual "attempt to index global 'LocatePlayerEntity' (a nil value)" error =S EDIT 2: A final edit as this is driving me crazy again. If I modify the end of the above script which is attached to the pivot so that it is: if setPlayerEntFlag ~= true then Script:SetPlayerEntity() end System:Print ("Hello") System:Print(self.EntPlayer) Then the first System: Print works, and I see Hello being output, but the second throws up the same self related error. Which pretty much tells me that self is not doing what I need, or I simply have no clue as to how it's supposed to work (which is very likely). I've tried Googling for information on this and can find nothing helpful that is written in a manner I understand. So I would appreciate some help with understanding why this isn't working. This is both with and without "return self.EntPlayer" being added to the function.
  24. I know it's been a while, but I have another question... While I've made some progress, I'm still not sure how to reference a variable set in one script from another script without using the flow editor or setting it as a global. For example, I know have the following in App.lua: --Set player entity if setPlayerEntFlag ~= true then -- Locate the player entitiy for x=0,App.world:CountEntities()-1 do local entity = App.world:GetEntity(x) local entInfo = entity:GetKeyValue("name") if entity:GetKeyValue("name") == "Player" then EntPlayer = App.world:GetEntity(x) System:Print(EntPlayer) end end setPlayerEntFlag = true end This locates the player entity and as the system:print line shows, it does indeed locate it. This allows me to use the player without having to loop to it each time and allows me to use it without needing to link it in the flow editor (as that still randomly wipes such connections -- I can't work out when or why though, so have yet to report as a bug). So I can then reference the player entity in another script I use: self.PlayerTarget = EntPlayer In the other script. This currently works because EntPlayer is global. But I'd like to know how to interact with it when it's a local variable. I tried App.EntPlayer, script.App.EntPlayer, and variants thereof, but always get the "global is a nil value" error. So my question is, what am I missing?
×
×
  • Create New...