-
Posts
40 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Posts posted by X54321
-
-
[/size][/font][/color]
You didn't mention specifically at what time it wasn't nil so was just making sure you tried that. I'll be working with fonts here in the next hour or so, so I'll see what comes of it and let you know.
OK, sounds like a plan.
-
And you are sure that in PostRender() self.font is not nil? I just want to make sure you didn't just check it in Start() after it was loaded. Also check it in PostRender() before it renders it. That might at least help figure something out. My guess would be it has to be nil in PostRender() to crash the engine.
Yes, I have already stated it isn't nil. I did both of the things you mentioned, and it was not nil.
-
New Information! SetFont() works perfectly fine if I call it in the Script:Start() function; But why not in Script:PostRender()?
-
I get this error on line 26:
Quote
attempt to perform arithmetic on global 'dx' (a nil value)
That's because I have custom variables for Delta mouse coordinates in App.lua. You can comment that out, it just controls the camera movement. The camera's script also references one of those variables.
-
I'M BACK! I'm trying to load a special font for the health percentage in my game; Loading the font goes by smoothly, but when I actually try to set the font it crashes. I know the font isn't nil (I tested it) and it can't be the font I'm using because it's the default font, except with a different size. Anyways, here's some code:
local window = Window:GetCurrent() local forward = 0 local strafe = 0 local angle = 0 local firing = false local shootTimer = 0 local health = 100 local pickInfo = PickInfo() function Script:Start() self.w1 = Texture:Load("Materials/HUD/gun_overlay.tex") self.w1f = Texture:Load("Materials/HUD/gun_overlay_02.tex") self.ch = Texture:Load("Materials/HUD/crosshair.tex") self.hb = Texture:Load("Materials/HUD/healthbar.tex") self.entity:SetKeyValue("weapon", "blaster") self.entity:SetKeyValue("type", "player") self.font = Font:Load("Materials/Fonts/arial.ttf",36) local material = Material:Create() material:SetBlendMode(5) self.entity:SetMaterial(material) material:Release() end function Script:UpdateWorld() window = Window:GetCurrent() angle = angle - dx * 0.25 local jump = 0 if window:KeyDown(Key.Space) and self.entity:GetAirborne() == false then jump = 10 end if window:MouseHit(1) and firing == false and self.entity:GetKeyValue("weapon") ~= "none" then firing = true local p0 = self.entity:GetChild(0):GetPosition(true) local p1 = Transform:Point(0,0,20,self.entity:GetChild(0),nil) self.entity.world:Pick(p0,p1, pickInfo, 0, true) if pickInfo.entity ~= nil then if pickInfo.entity:GetKeyValue("type") == "enemy" then pickInfo.entity:SetKeyValue("hurt", "true") end end end if firing == true and shootTimer < 24 then shootTimer = shootTimer + 1 elseif firing == true and shootTimer == 24 then shootTimer = 0 firing = false end forward = (window:KeyDown(Key.W) and 1 or 0)*6 - (window:KeyDown(Key.S) and 1 or 0) * 6 strafe = (window:KeyDown(Key.D) and 1 or 0)*6 - (window:KeyDown(Key.A) and 1 or 0) * 6 self.entity:SetInput(angle, forward, strafe, jump, false) onGround = false end function Script:PostRender(context) context:SetBlendMode(Blend.Alpha) context:SetColor(1,1,1,1) context:DrawImage(self.ch, 400 - 16, 300 - 16) --context:DrawImage(self.hb, 0, 600 - 104) context:SetFont(self.font) context:DrawText("Health: "..health.."%", 160, 600 - 72) end
-
You are setting that variable in Script:Create(). Try moving it to Script:Start() which is the function that all entity scripts call on startup. Not sure where you got Create() from.
Thanks, it worked! Not sure why; I'll have to look at the documentation.
-
Set a breakpoint and make sure the image isn't nil.
Yes, the image is nil. I have double-checked and the path is correct and the file is still there. Furthermore, I have tried other textures and got the same result.
-
I'm trying to draw a weapon overlay for my game; I already have the texture for it imported and in the right place, but whenever I actually draw it the game crashes. No errors, nothing. The .tex settings for it is the default except all checkboxes are unchecked and the filter mode is set to 'pixel'.
Here's the part where I draw the image:
local window = Window:GetCurrent() local forward = 0 local strafe = 0 local angle = 0 local weapon = 0 function Script:Create() self.w1 = Texture:Load("Materials/HUD/gun_overlay.tex") end function Script:UpdateWorld() window = Window:GetCurrent() angle = angle - dx * 0.25 forward = (window:KeyDown(Key.W) and 1 or 0)*6 - (window:KeyDown(Key.S) and 1 or 0) * 6 strafe = (window:KeyDown(Key.D) and 1 or 0)*6 - (window:KeyDown(Key.A) and 1 or 0) * 6 self.entity:SetInput(angle, forward, strafe, 0, false) end function Script:EquipBlaster()--in weapon = 1 end function Script:PostRender(context) context:SetBlendMode(Blend.Alpha) context:SetColor(1,1,1,1) if weapon == 1 then context:DrawImage(self.w1, 52, 52) end end
-
OK, here's the project link : https://drive.google.com/file/d/0BzyMN5S2kRTHZjIxd1NUSG9BdzA/edit?usp=sharing
-
Ok, so it turns out that method had a lot of collision bugs. I then came up with a new solution that uses the physics, and it (almost) works, but it is really weird. The physics for the player are so jittery it makes the game virtually unplayable. I don't think it's lag, either, because the frame rate is about 180! I'll put up the project in a moment; It'll take a while to upload.
-
Found a solution. I just had to use SetPosition() instead of PhysicsSetPosition(), and then I could have physics on without the player being moved when I didn't want him to.
- 1
-
I'm not using a character controller, I can't customize the character controller at all. I'm making a 2.5d platformer, and I'm using a rigid body for the player (without mass).
-
ANSWERED
Hi, I just bought this engine a couple of days ago. It's really nice so far, but the physics engine is kind of glitchy. There have been other posts on the physics engine, and so I am aware the developer is working on it. BUT, the game I am looking to make doesn't need any sort of physics; I just need collision. Unfortunately, I can't seem to collide with anything if the mass is set to 0. If I enable physics, I can't seem to get it to not move, and It goes through everything. SO, does anyone have an idea?
*EDIT: I am using a rigid body character, not a character controller.
[Leadwerks 3 Indie Edition] Game crashes when setting font
in Programming
Posted
Hmm, maybe it's just a problem that's fixed in the beta version. I may or may not switch to the beta version later, is there any risk of corrupting my project?