-
Posts
556 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Downloads
Everything posted by havenphillip
-
Also here's the Radar Effect standalone: Radar Effect.lua
-
Actually this is working pretty good. It's close to perfect. Maybe you can explain why. Instead of x and y I used dotX and dotY which I made in order to get the zoom to work right. Originally the dots were sort of "slipping" over the terrain and that's fixed: --set enemy entities dot color and position local miniMapEnemySize = Vec2(self.miniMapSize.x/25,self.miniMapSize.y/25) --local radarHalf = self.miniMapSize.y/2 * (self.miniMapSize.x), self.miniMapSize.y/2 * (self.miniMapSize.y) local radarHalf = Vec2((self.radar / 2 / self.radar) * (self.miniMapSize.x), (self.radar / 2 / self.radar) * (self.miniMapSize.y)) local dotX = (self.miniMapSize.x / self.cameraRng / self.zoom) local dotY = (self.miniMapSize.y / self.cameraRng / self.zoom) for k, v in pairs(self.enemyEntities) do if self.enemyEntities[k].script.enabled == true then if self.enemyEntities[k].script.mode ~= "dying" and self.enemyEntities[k].script.mode ~= "dead" then enemy = self.enemyEntities[k]:GetPosition() enemyDrawX = dotX * (enemy.x - pos.x) + radarHalf.x enemyDrawY = dotY * (pos.z - enemy.z) + radarHalf.y if enemyDrawX > dotX and enemyDrawX <= self.miniMapSize.x and enemyDrawY <= self.miniMapSize.y and enemyDrawY > dotY then context:SetColor(1,0,0,1) context:DrawRect(x + enemyDrawX, y + enemyDrawY, miniMapEnemySize.x, miniMapEnemySize.y, 0, 1) end end end end Yeah, man. You can check out whatever I got. I don't have a game, per se, but I'll send you my whole project. I'm mostly just learning Leadwerks and getting the basics of making a game. But whatever I got you can check out, but you'll have to explain to me how to send a project through pm. I don't even know where the pm button is lol. One last thing is that the minimap shows my other HUD elements inside the minimap. I don't know of any way to get rid of that but I would love to get rid of it. It's workable as is but it's one of those little annoyances in the back of my mind. Here's the most recent version: Mini Map.lua
-
if enemyDrawX >= x and enemyDrawX <= self.miniMapSize.x and enemyDrawY <= self.miniMapSize.y and enemyDrawY >= y then I'm trying to get this to work but it's eliminating all the dots. Maybe something in my script that I did somewhere that negates it? Or maybe is there a way to say "not greater than"? Like a ~>? I tried but figured probably not. Mini Map.lua
-
Like this? I think I understand. You're saying keep as much info out of the loop so it doesn't have to re-read it all everytime. local miniMapEnemySize = Vec2(self.miniMapSize.x/25,self.miniMapSize.y/25) local radarHalf = Vec2((self.radar / 2 / self.radar) * (self.miniMapSize.x), (self.radar / 2 / self.radar) * (self.miniMapSize.y)) local dotX = (self.miniMapSize.x / self.cameraRng / self.zoom) local dotY = (self.miniMapSize.y / self.cameraRng / self.zoom) for k, v in pairs(self.enemyEntities) do if self.enemyEntities[k].script.enabled == true then if self.enemyEntities[k].script.mode ~= "dying" and self.enemyEntities[k].script.mode ~= "dead" then enemy = self.enemyEntities[k]:GetPosition() enemyDrawX = dotX * (enemy.x - pos.x) + radarHalf.x enemyDrawY = dotY * (pos.z - enemy.z) + radarHalf.y if enemyDrawX < self.miniMapSize.x and enemyDrawY < self.miniMapSize.y then context:SetColor(1,0,0,1) context:DrawRect(x + enemyDrawX, y + enemyDrawY, miniMapEnemySize.x, miniMapEnemySize.y, 0, 1) end end end end The way I have it set up is almost exactly what I want. 60 is too small for the bounding sphere and the map is a little quirky. I'm trying to get the dots to disappear when they are outside of the miniMapSize.x and .y but this only works on the right border and the bottom border. Why is it not doing the same on the top and left? Need to learn Vec4?
-
Actually, this works: for k, v in pairs(self.enemyEntities) do --calculate the position to drawcolor local enemy = self.enemyEntities[k]:GetPosition() --local pos = self.player:GetPosition(true) local enemyDrawX = (enemy.x - pos.x) + (self.radar / 2 / self.radar * self.miniMapSize.x) local enemyDrawY = (pos.z - enemy.z) + (self.radar / 2 / self.radar * self.miniMapSize.y) context:SetColor(1,0,0,1) context:DrawRect(x + enemyDrawX, y + enemyDrawY, self.miniMapSize.x/25, self.miniMapSize.y/25, 0, 1) end I still need to work on trying to adjust the spacing on enemy dots to fit with the adjustable zoom so that they seem more spread out when zoom in and more clustered when zoomed out. Here's the latest with this updated in it. It works! Mini Map.lua
-
Something like this? Script.radar = 60 -- int "Radar Range" Script.miniMapSize = Vec2(200,200) --Vec2 "Minimap Size" for k, v in pairs(self.enemyEntities) do --calculate the position to drawcolor local enemy = self.enemyEntities[k]:GetPosition() local pos = self.player:GetPosition(true) local enemyDrawX = (enemy.x - (pos.x - self.radar/2) /self.radar * self.miniMapSize.x) local enemyDrawY = (enemy.z - (pos.z - self.radar/2) /self.radar * self.miniMapSize.y) context:SetColor(1,0,0,1) context:DrawRect(x + enemyDrawX, y + enemyDrawY, self.miniMapSize.x/25, self.miniMapSize.y/25, 0, 1) end
-
Ah ok, I figured some of it was arbitrary. Nice, art, too, haha. As long as it does the job, right? Here it is currently. I haven't really attempted to establish the relative coordinates, which is what I presume you are trying to explain. I'm slow at math but by all means explain it if you feel up to it.. I'm trying to think of ways to do it. One thing I was thinking was maybe making another box fron the script that is the size of the level and relating the enemies to it that way? Another thing I was trying to work out is this equation : local X2= (x + miniMapSize/2 + (enemy.x * player.z - enemy.z * player.x) /self.zoom...and do the same for Y2, but this gives me a slope, and my math sucks so I don't know how to get past that. Idk if I need some kind of quadratic equation or something. If you already have it figured out I'd be happy to learn it. Seems like I'd have to get the enemyEntity positions at some point. Right now I'm getting a rectangle on the screen for each entity in range but they all show on screen at the same spot, and they don't move yet. Changing the 3d position to 2d position is something I'm trying to get a handle on. But I"m stoked that it''s even this far! Mini Map.lua
-
Ah yes! I got a rectangle on the screen when in range. For some reason when I deleted "self.enemyEntities = {}" from under PostRender() and put it under Start() all of a sudden now I get a rectangle. -150 is way off the map so clearly that's wrong. outerTopY must be 50-30=20, then? I guess the question now is to find an equation that will relate the enemyEntities to the player
-
Ha! Dang! Man, you're so far beyond me, this is embarrassing. I'm still trying to figure out why I'm not getting a rectangle anywhere on the screen at all! I'm starting to feel bad dragging you into this like I should have just gave up and left it to the veterans. I'll give it a shot: Half of 60 is 30 so 50-30 = 20 and 50+30 = 80. If the same law applies then the outerTopY would be 80, and the outerBottomY would be 20. EnemyX is at 35. So 35-80=-45, then - 45/60 = -0.75. 200 * -0.75 = - 150? Or did I get the top and bottom backwards? enemyDrawX = 40 enemyDrawY = -150 context:DrawRect(x + enemyDrawX, y + enemyDrawY, self.miniMapSize.x/25, self.miniMapSize.y/25, 0, 1)
-
Yeah it was telling me "bad argument #1 to 'insert' (table expected, got nil)", but that seems to have resolved it. I think you were right about having to change that "1" to a "2" in the line "local AABB = self.miniMapSphere:GetAABB(1)". I added entity:SetColor(1,0,0) in the callback as a check and they turn red in range with that number set to "2". With "1" I get nothing. Still no PostRender() information showing up anywhere, though. This is what I have in the PostRender function. It seems to me there is a disconnect between the callback and the PostRender? self.enemyEntities = {} for key, value in pairs(self.enemyEntities) do --calculate the position to drawcolor local pos = self.enemyEntities:GetPosition() context:SetColor(1,1,1,1) context:DrawRect(200+pos.x,200+pos.z,20,20,0,1) end
-
Ok that's what I didn't understand. The callback function is not something I'm at all familiar with I didn't know if I had to plug in a list of enemies there or somewhere else or at all. No need to do it by hand if you're telling me that's not necessary. I'm learning but total noob so a lot of the information won't get in my brain and stay there. I'm pretty much hanging on your every word here for now. I watched your vids on tables and I'll watch them again to reduce my obnoxious noob questions to a minimum. Tables, bounding boxes and raycasting definitely seem like invaluable principles to understand and would be cool to learn how to wield them. Right now it's telling me bad argument #1 to 'pairs' (table expected, got nil) but I'll fiddle with it and see if I can get it to work.
-
I'm pretty much at a loss at this point. How do I reference my enemy list so that I can post render a dot to their position? Is it correct as is?
-
OK. So far so good. No errors. I was trying to use GetAABB(1) on the enemies themselves. What does that "1" mean there? I had to resize the sphere for some reason but it isn't giving errors. Here's the current state. I have a bunch of zombies(that I"m probably not supposed to have). I'm not sure that I fully understand arrays and tables yet but I plugged them in at the top. The "tables" documentation is showing something else. Mini Map.lua
-
Ahh ok! I have it working up to that point now. I didn't realize I could just pivot the whole box to the player. Enemies turn red at the distance when they enter the box, which follows the sphere, which is pivoted to the player, so it follows the player. Makes a lot of sense. Now I can also reference them with the GetKeyValue and that's something I've been stuck on for days. I'm not sure what you mean by updating the ForEachEntityInAABBDo. Do you just put it under UpdateWorld()? The next thing is drawing the dots. I've been scratching my head for several days since once I call the loop(is that the right terminology?) for some reason I can't use anything I previously have, like anything that uses "self..." What do I need to do next to get to where I can draw the positions of the enemies? Feels trapped in that "Callback" function. Here's where I'm at: local v = Vec3(1,0,0) sphere = Model:Sphere(8,self.player) sphere:SetScale(50,50,50) sphere:Hide() sphere:SetPosition(self.player:GetPosition()) position = sphere:GetPosition() aabb = AABB(position.x+50,position.y+50,position.z+50,position.x-50,position.y-50,position.z-50) world:ForEachEntityInAABBDo(aabb,"Callback",v) end function Callback(entity,extra) if entity:GetKeyValue("type") == "enemy" then local v = Vec3(0,0,0) v = extra entity:SetColor(v.r,v.g,v.b) end end
-
I tried the right-click on the windows bar but it's weird the option to minimize/maximize window is there but I can't select it.
-
Nothing, but I just remembered I bought that Luawerks thing in the workshop because I thought I needed it. I recall when I downloaded it it resized the window, so maybe that's getting in the way somehow? because nothing works I tried the window key with every button on my computer. Nothing I'm looking for.
-
I almost had it with camera pick but I could only do one at a time and only when the player camera was pointed at an enemy. But I was able to reference the entity with pickInfo.entity. Is there a way to do more than one at a time with the Pick() function? Like world:Pick() or something?
-
Yeah ok. I guessed I would need a bounding box. I've been messing with the bounding box with little success. I found a script in the forum and was able to make a bounding box that is the size of the level and turns enemies red, but I can't from there draw any context. What would I use in the shader to represent the enemy positions? I used parts from your Project Saturn inventory item script to create a 2d box that I can size and position to the minimap, and I had some success using a camera pick but the camera pick only does one at a time and I need to do all of them within a given range. I'm thinking I can just overlay the 2d information on top of the shader rather than dealing with the shader (the shader code looks like complete nonsense to me) if only I can figure out how to get context:DrawRect to follow the bad guys around. I think I'm tracking with you. Here's my script currently. I put exclamation points near the changes I'm working on: Mini Map.lua
-
Those worked for you? I tried everything. I must be missing something somewhere. I eventually just created a new project and imported everything in. The GUI in the .exe window was unreachable at that size. Maybe if someone added a scroll bar to it?
-
I've been messing around with Macklebee's minimap script and I got it working but I want to find a way to get a radar sort of function to it so I can see 2d dots of where enemies are in relation to me on the minimap. I'm a noob and I get the feeling this may be out of my ability range but how can I create a 2d dot that follows a 3d character as it moves around? And also how can I have the pick show more than one enemy on the map? A "for" loop, maybe? What direction do I go from here? I hid the minimap shader that goes with this script at the bottom: Mini Map.lua
-
This is dumb but I shrank the game window too small and now it's too small to hit the "apply" button, which is now off screen. Is there another way to increase the window size back to normal?
-
Ok so my item is a health kit. It has the "enabled" boolean. I tried your advice and added the line: if self.spawn~= nil and self.spawn.script.enabled then But now the spawner is doing nothing. Am I going to have to add a new boolean? I Here's my script (it's got the float up and down script in it from the workshop and it's a bit of a mess): floating.lua
-
I have this item spawner script attached to a pivot but I want to figure out how to make the spawner wait to drop another item until the one it has already dropped has been picked up. How do I reference the spawned item? Script.spawnrate = 3--float Script.spawncount = 1--int Script.item ={} Script.item[0]= "Prefabs/Ammo Prefabs/9 ammo Hover.pfb" --path Script.item[1] = "Prefabs/Ammo Prefabs/Shotgun Shells Hover(3).pfb" --path Script.item[2]= "Prefabs/Ammo Prefabs/mp5 ammo Hover (4).pfb" --path Script.item[3] = "Prefabs/Ammo Prefabs/Combat Rifle Hover (5).pfb" --path Script.item[4]= "Prefabs/Health Kit/Health Kit.pfb" --path function Script:Start() self.spawntime = Time:Millisecs() self.counter = 0 end function Script:UpdateWorld() if Time:Millisecs() > self.spawntime + (self.spawnrate * 1000) then self.counter = self.counter + 1 math.random(Time:GetCurrent()) local rand = math.random(0,4) self:Spawn(rand) self.counter = 0 end --end end function Script:Spawn(rand) self.spawn = Prefab:Load(self.item[rand]) local entpos = self.entity:GetPosition(true) self.spawn:SetPosition(self.entity:GetPosition()) self.spawntime = Time:Millisecs() end
-
Trying to make a health regen code...
havenphillip replied to havenphillip's topic in General Discussion
Sweet. Fixed.