Einlander
-
Posts
778 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Posts posted by Einlander
-
-
I've never really thought about that way. I developed that habit in my old qbasic days. I tend to make very nice looking spaghetti code so I like to make sure the scope is super obvious. That and I code at night on low sleep after work. I make all sorts of mistakes. I'm quite sure i have variables that are never used in this script. But I will take it in mind. Now i'm 8 hours overdue from sleep. Now I have 667 posts!
-
I've been doing some coding on a bunch of Left 4 Dead style stuff and this is the latest script I have. A simple use timer. I haven't tested it very hard, but there should not be any glaring bugs. Information about the script:
http://i.imgur.com/ZuzDtap.gifv
--[[ Title: Use Timer Author: Einlander Start Date: 5-22-17 Version: 2 Description: A simple Left 4 Dead style use timer Notes: WHAT IT DOES: Allows player to use a script to force player/user to use an item for a set period of time. Think Left 4 Dead when you need to pour gas or start generators. WHAT IT DOESENT DO: It does not immobilize the player/user. It does not cancel when the player/user looks away or is too far. Changelog: 1 -Initial release 2 -style changes small fix added self.entity:SetKeyValue("type","use_timer") . This will help when trying to figure out what you are using and adjust accordingly. ie:detect you are using the use timer and make it so the player cant move -in Script:Start changed self.completed to true to prevent activating when not targeting entity. 3 -complete rewrite with less code, and smarter time management ]]
The script itself:
--[[ Title: Use Timer Author: Einlander Start Date: 5-22-17 Version: 2 Description: A simple Left 4 Dead style use timer Notes: WHAT IT DOES: Allows player to use a script to force player/user to use an item for a set period of time. Think Left 4 Dead when you need to pour gas or start generators. WHAT IT DOESENT DO: It does not immobilize the player/user. It does not cancel when the player/user looks away or is too far. Changelog: 1 -Initial release 2 -style changes small fix added self.entity:SetKeyValue("type","use_timer") . This will help when trying to figure out what you are using and adjust accordingly. ie:detect you are using the use timer and make it so the player cant move -in Script:Start changed self.completed to true to prevent activating when not targeting entity. 3 -complete rewrite with less code, and smarter time management ]] Script.NullVar = nil --choice "Use Timer" "Version: 3, By: Einlander" Script.enabled = true -- bool "Enabled" Script.HoldTime = 5 -- Float "Hold Time" -- How long the use key needs to be held Script.CumulativeTime = false -- bool "Cumulative Time" -- The timer does not reset when the use key is let go Script.ShowGraphics = true -- bool "Show Graphics" -- Draws the completion bar on screen Script.DisableOnComplete= true -- bool "Stop when Done" -- Disables script on completion function Script:Start() self.totaltime = 0 end --[[ Description: Allows the fpsplayer to use the entity Parameters: none ]] function Script:Use() if self.enabled == false then return end self:Begin() end --[[ Description: enables the script Parameters: none Notes: Has a flowgraph input ]] function Script:Enable() --in self.enabled = true self.component:CallOutputs("_enabled") end --[[ Description: Disables script Parameters: none Notes: Has a flowgraph input ]] function Script:Disable() --in self.enabled = false self.component:CallOutputs("_disabled") end --[[ Description: Starts all timers Parameters: none Notes: Has a flowgraph input, and a output to tell when the script has started ]] function Script:Begin() if self.enabled == false then return end self.started = true self.complete = false --if (self.totaltime >= (self.HoldTime - 1)*1000) then --self.totaltime = 0 --end if (self.CumulativeTime == false) then self.totaltime = 0 end self.component:CallOutputs("started") end --[[ Description: Resets the script to ready it for another use Parameters: none Notes: Has a flowgraph input, and a output to tell when the script has completed ]] function Script:Complete() if self.enabled == false then return end self.complete = true self.totaltime = 0 if (self.DisableOnComplete == true) then self:Disable() end self.component:CallOutputs("complete") --System:Print("complete") end --[[ Description: Keep track of when the use key is pressed, held, and released Parameters: none Notes: Also calculates time left ]] function Script:UpdatePhysics() if self.enabled == false then return end if self.complete == true then return end if ((self.started == true) or (self.held == true) or (self.released == true)) == true then if self.totaltime >= ((self.HoldTime-1) * 1000) then self:Complete() end end if self.started == true then if (window:KeyDown(Key.E) == true) then self.started = false self.held = true self.timestart = Time:GetCurrent() return end end if self.held == true then if (window:KeyDown(Key.E) == true) then self.held = true self.timeend = Time:GetCurrent() self.totaltime = self.totaltime + (self.timeend - self.timestart) self.timestart = Time:GetCurrent() self.component:CallOutputs("running") self.timeend = Time:GetCurrent() else self.held=false self.released = true self.timeend = Time:GetCurrent() self.totaltime = self.totaltime + (self.timeend - self.timestart) self.timestart = Time:GetCurrent() end return end if self.released == true then self.timeend = Time:GetCurrent() self.totaltime = self.totaltime + (self.timeend - self.timestart) self.released = false return end end --[[ Description: Prints stuff to console Parameters: inner as anything Notes: Has a flowgraph input, that will allow an argument ]] function Script:WritePercentage(number) --in System:Print(tostring(number)) end --[[ Description: Calculates Percent Complete Parameters: none Notes: Has a flowgraph ARGUMENT that sends out the percentage completed ]] function Script:Percentage() --arg return math.floor((self.totaltime / ((self.HoldTime-1)*1000))*100) end --[[ Description: Draws the Percentage bar on screen Parameters: context as window context Notes: The display is resolution independant. It will look the same on all screens. ]] function Script:PostRender(context) if self.enabled == false then return end if self.complete == true then return end if ((self.started == true) or (self.held == true) or (self.released == true)) == false then return end context:SetBlendMode(Blend.Alpha) window = Window:GetCurrent() local segment = Vec2(window:GetWidth() *.25,window:GetHeight() *.47) context:SetColor(0,0,0,0.5) context:DrawRect(segment.x, segment.y , window:GetWidth() - (segment.x*2),window:GetHeight() - (segment.y*2)) context:SetColor(1,1,1,0.5) context:DrawRect(segment.x+4, segment.y+4 , (window:GetWidth() - ((segment.x+4)*2))*(self:Percentage()*.01) , window:GetHeight() - ((segment.y+4)*2)) end
-- edit --
added self.entity:SetKeyValue("type","use_timer") . This will help when trying to figure out what you are using and adjust accordingly. ie:detect you are using the use timer and make it so the player cant move.
in Script:Start changed self.completed to true to prevent activating when not targeting entity.
-- edit --
-
On my system any more than four skinned characters causes massive slowdowns.
- 1
-
mySurface = Self.entity:GetSurface(0)
-
I might give it a try this time. I will be needing grenades and and even harder Molotov cocktails in my game. So I might as well make them now.
- 1
-
To go even further, you would need to WORLD PICK from the controllers feet to the ground. This will return a PICKINFO you would be able to get the exact surface. pickinfo.surface:GetMaterial() would get you the material itself. pickinfo.surface:GetMaterial():GetPath() should get the filename itself without going through extra steps.
This will not work on terrains.
Please click on the links.
http://www.leadwerks.com/werkspace/page/api-reference/_/world/worldpick-r502
http://www.leadwerks.com/werkspace/page/api-reference/_/pickinfo/
http://www.leadwerks.com/werkspace/page/api-reference/_/surface/surfacegetmaterial-r212
http://www.leadwerks.com/werkspace/page/api-reference/_/asset/assetgetpath-r41
- 1
-
Amazingly I get the same first number every time even if I use the time as the seed. :/
-
I give up using debug mode after I start populating levels. I just use release mode and lots of print statements.
- 1
-
I would still need to pass arguments to the script though. I want the editor to pass '+fullscreen' when I debug, but I don't want to have the game start as fullscreen the first time it's run. I want to have it start windowed, have the player set the screen resolution and then write it to file. Then the next run it will be fullscreen. But while I debug I want to be able to just say, ignore the games settings and be fullscreen.
-
I am requesting an input box or a separate tab that will allow devs to add command line arguments that will be passed to the game when launched from the editor.
This will allow us to use the System:GetProperty without having to hardcode the values into the game.
- 2
-
It should be viewable now
-
Operating system or device - Leadwerks Version:
- Windows 7 Pro x64
- Leadwerks 4.2 Beta BuildID:1737986
Issue description (what happened, and what was expected):
-
Issue
- Models with physics that drop onto the character controller will bounce higher
[*]What was expected
- The model to hit the top of the character controller then fall off.
- Models with physics that drop onto the character controller will bounce higher
Steps to reproduce
- Load the fps AI and events map
- Pick up any entity
- Look directly up
- Drop it
Link to minimal example project
- No project just a video
-
- 1
- Windows 7 Pro x64
-
The pickbox commands are all undocumented. I have never used them. If I remember correctly there use to be an option in the model viewer to create the hitboxes but they were removed. Send a message to Josh, he may be able to tell you what commands to use in c++.
-
The issue was, I assumed that if you reset the perspective view it would be the same as the front view, which is not the case.
If a person stands at (0,0,0) looking at z+(0,0,1) they would be looking into the screen. I assumed that was front, but that is actually the Back view. Looking at z-(0,0,-1) is that actual back view which matches the perspective view. Which is the opposite of most 3d modeling programs even blender in it's backward ways. Also 3d Level editors are the opposite of what Leadwerks has.
So basically Perspective view is the back view and not the front view. For me it's just a break in convention.
-
I guess that perspective view is the back view. I guess i'm just use to 3d modeling tools where z+ goes out the screen :/
-
If you reset your perspective view, then create something in front view, it will show the reverse placement on the x axis in the perspective view. http://i.imgur.com/iIKJH2H.png
-
In the Leadwerks editor has the front and back Views are reversed.
-
Would this help? http://stackoverflow.com/questions/191842/how-do-i-get-console-output-in-c-with-a-windows-program
And further reading: https://www.gamedev.net/topic/509479-routing-stdout-to-windowconsole/?whichpage=1#3320937
Sadly I am not a c++ guy so I cant be much help here.
-
When GetDebugEntityBoxesMode is enabled without water enabled. The AABB displayed do not stay in place. If water is enabled, and you look up far enough, the AABB displayed begin to drift again.
- 1
-
Its alright as long as you never adjust the textures in leadwerks, or scale them or apply multiple texture's to a brush. Then it all falls apart.
-
The problem with vmf/maps are the uv's are not relative. they are absolute to the texture. so you need the texture to derive the uv's. There is probably some math to convert them without, but i have never seen it done.
-
I found a convoluted way to get it into a editor with the uv's in place. But you will have to add the textures back yourself.
You need 3 things:
Crafty : http://nemesis.thewavelength.net/index.php?p=45
Delgine : http://www.delgine.com/index.php?filename=product_deled
and a Delgine plugin: Map Importer http://www.delgine.com/plugins/viewPluginCategory.php?catid=39&catdesc=Importers
- First you make your map in Leadwerks and export it to vmf.
- Open it in Crafty and export it as Map
- Import it in Delgine and export it as obj.
- Import the Obj in your 3d editor.
- Y is UP and Z is towards you
[*]Scale all uv's to .1
[*]Add your textures back in. It will look exactly how it does in Leadwerks.
- Y is UP and Z is towards you
This is a lot of work though.
- First you make your map in Leadwerks and export it to vmf.
-
Let me know how that works. I would love to be able to export buildings from leadwerks.
-
You can get the material of a specific layer of the terrain, then from what I am seeing, check the current layers alpha. I would assume the lower the alpha the more intense the texture. it can get complicated ...
Terrain.h lua commands:
virtual Texture* GetVegetationMap();//lua virtual int CountVegetationLayers();//lua virtual VegetationLayer* GetVegetationLayer(const int index);//lua virtual void SetTextureStageDistance(float distance, float multiplier);//lua virtual void SetLayerAlpha(const int slot, const int x, const int y, const bool alpha);//lua virtual bool GetLayerAlpha(const int slot, const int x, const int y);//lua virtual int GetLayerAtPoint(const int x, const int y);//lua virtual void SetLayerAlpha(const int slot, const float alpha);//lua virtual void SetElevation(const int x, const int y, const float elevation, const bool update);//lua virtual float GetElevation(const float x, const float z);//lua virtual Vec3 GetNormal(const float x, const float z);//lua virtual float GetSlope(const float x, const float z);//lua virtual void SetLayerAlpha(const int slot, const int x, const int y, const float a0, const float a1, const float a2, const float a3);//lua virtual void SetLayerAlpha(const int slot, const int x, const int y, const float alpha);//lua virtual void SetLayerAlpha(const int slot, const float a0, const float a1, const float a2, const float a3);//lua virtual void SetLayerTexture(const int slot, Texture* texture, const int index=0);//lua virtual void SetLayerScale(const int slot, const float x, const float y);//lua virtual Vec2 GetLayerScale(const int slot);//lua virtual Texture* GetLayerTexture(const int slot=0, const int index=0);//lua virtual bool LoadHeightmap(const std::string& path, const float scale=1.0, const int bpp=0);//lua virtual void SetHeight(const int x, const int y, const float height, const bool update=false);//lua virtual float GetHeight(const int x, const int y);//lua virtual void UpdateNormals();//lua virtual bool Pick(const Vec3& p0, const Vec3& p1, PickInfo& pick, const float radius, const bool closest, const bool recursive, const int collisiontype); virtual void SetLayerSlopeConstraints(const int slot, const float minslope, const float maxslope, const float transition);//lua virtual void SetLayerHeightConstraints(const int slot, const float minheight, const float maxheight, const float transition);//lua virtual Vec3 GetLayerSlopeConstraints(const int slot);//lua virtual Vec3 GetLayerHeightConstraints(const int slot);//lua virtual VegetationLayer* AddVegetationLayer();//lua virtual void SetLayerDisplacement(const int slot, const float displacement);//lua virtual float GetLayerDisplacement(const int slot);//lua virtual void SetLayerTextureLookupMode(const int slot, const int mode);//lua virtual int GetLayerTextureLookupMode(const int slot);//lua virtual void SetLayerTextureMappingMode(const int slot, const int mode);//lua virtual int GetLayerTextureMappingMode(const int slot);//lua static Terrain* Create(const int size, const bool editable=false);//lua
- 1
Adobe make changes to Maximo
in Game Artwork
Posted
If only makehuman made the creation of clothes easier and not require blender.