Kenneth Nyström Posted October 22, 2018 Share Posted October 22, 2018 Gamecrash; due to kill/respawn script changes/removes??? a value that is used within the default "TriggerChangeMap.Lua" script My suspiscion atm...have had like 20 other ideas before:what it might be (not working); Is that the respawn script is missing something (but My skill isnt yet up to that level yet so i can see what is missing. If that is the case. (yes im suspecting there is missing an "if" statement but not sure) (I have gotten to the point I cant keep track of all my ideas flying around what it might be) = time to ask: --------------------------------------------------------------------------------------- Description: Before dying the game and its Changemap scripts work just fine: But after dying once: Game just hangs it self when entering the TriggerChangeMap script... ::::::::::::::::::::::::::::::::::::::::::Player.Lua "script"::::::::::::::::::::::::::::::::::::::::::::::::: function Script:Kill() self.corpse = Pivot:Create() self.alive = false local shape = Shape:Load("Models/Characters/Generic/corpse.phy") self.corpse:SetShape(shape) if shape~=nil then shape:Release() end self.flashlight:Hide() if self.weapons[self.currentweaponindex]~=nil then self.weapons[self.currentweaponindex]:Hide() end self.corpse:SetMass(5) self.corpse:SetMatrix(self.camera:GetMatrix()) self.camera:SetParent(self.corpse) self.camera:SetPosition(0,0,0) self.camera:SetRotation(0,0,0) self.corpse:SetCollisionType(Collision.Prop) self.corpse:SetSweptCollisionMode(true) self.entity:SetCollisionType(0) self.corpse:SetFriction(10,10) local maxomega=5 self.corpse:SetOmega(Vec3(math.random(-maxomega,maxomega),math.random(-maxomega,maxomega),math.random(-maxomega,maxomega))) local v = self.entity:GetVelocity() if v:Length()>1 then v=v:Normalize() end self.corpse:SetVelocity(Vec3(math.random(-1,1),math.random(-1,1),math.random(-1,1))) self.entity:SetMass(0) self.entity:SetPhysicsMode(Entity.RigidBodyPhysics) end function Script:Respawn() self.alive = true self.health = self.maxHealth self.entity:SetMass(self.originalMass) self.entity:SetCollisionType(Collision.Character) self.entity:SetPhysicsMode(Entity.CharacterPhysics) self.entity:SetPosition(self.checkpointMgr.script:GetCheckpointPosition()) self.camera:SetParent(nil) self.corpse:Release() end ::::::::::::::::::::::::::default "TriggerChangeMap.Lua" script:::::::::::::::::::::::::::::::::::::::::: function Script:Start() self.enabled=true end function Script:Collision(entity, position, normal, speed) changemapname=self.mapname end function Script:Enable()--in if self.enabled==false then self.enabled=true self:CallOutputs("Enable") end end function Script:Disable()--in if self.enabled then self.enabled=false self:CallOutputs("Disable") end end Quote Link to comment Share on other sites More sharing options...
havenphillip Posted October 22, 2018 Share Posted October 22, 2018 I think the line self.entity:SetMass(0) was causing crash problems. Maybe uncomment that. Quote Link to comment Share on other sites More sharing options...
Kenneth Nyström Posted October 22, 2018 Author Share Posted October 22, 2018 29 minutes ago, havenphillip said: I think the line self.entity:SetMass(0) was causing crash problems. Maybe uncomment that. Hmm I tried it -- and several alternatives to SetMass thruout the kill/respawn part of the script. still same result in the game crashing. Only wierd i can see is that the Output says. "process complete" Without having reached the loading bit of the ChangeMap script it usully does... Hmm. I perhaps I need find a "never" version of the respawn bit in the script (using lesson 27 of the LW tutorial) and it has worked great until now when it messes with the changemap script... Hmm. Anyone can point me in a direction for an alternative place/tutorial for a wiew into a diffrent version of a respawn script? Quote Link to comment Share on other sites More sharing options...
Gonan Posted October 23, 2018 Share Posted October 23, 2018 http://www.leadwerks.com/werkspace/topic/11065-monsterailua-function-scriptendattack-bug-fix/ This problem occurs when more than one monster is attacking you. Not sure if it was ever fixed. Quote Link to comment Share on other sites More sharing options...
Slimwaffle Posted October 23, 2018 Share Posted October 23, 2018 What I ended up doing with my game was removing all the code that says what happens if the player dies. Then inserted my own code that says; teleport to respawn location, reset health, reset stamina, reset thirst, reset hunger, empty inventory. Using this method the player technically doesn't die but it simulates death. Then all you have to do is for your enemies is add code that makes thier target nil and tells them to search for new target. But as for your code the only thing I can suggest is set up a trigger value and then breadcrumb. So for example add something like; Script.trigger = 0 Then in your update world add; if self.health <= 0 then self.trigger = 1 end if self.health > 0 then self.trigger = 0 end if self.trigger == 1 then --Add the code here that triggers or references the change map. end Quote Link to comment Share on other sites More sharing options...
Kenneth Nyström Posted October 28, 2018 Author Share Posted October 28, 2018 On 10/23/2018 at 4:55 AM, Wafflesoft said: What I ended up doing with my game was removing all the code that says what happens if the player dies. Then inserted my own code that says; teleport to respawn location, reset health, reset stamina, reset thirst, reset hunger, empty inventory. Using this method the player technically doesn't die but it simulates death. Then all you have to do is for your enemies is add code that makes thier target nil and tells them to search for new target. But as for your code the only thing I can suggest is set up a trigger value and then breadcrumb. So for example add something like; Script.trigger = 0 Then in your update world add; if self.health <= 0 then self.trigger = 1 end if self.health > 0 then self.trigger = 0 end if self.trigger == 1 then --Add the code here that triggers or references the change map. end On 10/23/2018 at 4:15 AM, Gonan said: http://www.leadwerks.com/werkspace/topic/11065-monsterailua-function-scriptendattack-bug-fix/ This problem occurs when more than one monster is attacking you. Not sure if it was ever fixed. Both; Thank you for your inputs. and yeah I thought the same way with working around the problem (acctully a very good thing); taught me alot of useful "stuff" while dealing with the LUA code. I really only have one last issue with the coding I will soon dive into: Hmm I could just ask you guys (without starting yet one more thread): making the code for saving, map/position/rotation/tables is there a good place to begin lookin @? (didnt find the info in the "index" (could be there; this is just me just getting to that stage of/in the programming) Quote Link to comment Share on other sites More sharing options...
Slimwaffle Posted October 28, 2018 Share Posted October 28, 2018 I had this issue a while back and got help finding a fix. I will link the forum for you. Quote Link to comment Share on other sites More sharing options...
Kenneth Nyström Posted October 29, 2018 Author Share Posted October 29, 2018 On 10/28/2018 at 2:54 PM, Wafflesoft said: I had this issue a while back and got help finding a fix. I will link the forum for you. Wonderful, (thank you) now I just need the time (real life makes it a it cramped atm to put in a hard think/analysing session to look into it...=) But pretty soon so. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.