Jump to content

Kenneth Nyström

Members
  • Content Count

    12
  • Joined

  • Last visited

Community Reputation

2 Neutral

About Kenneth Nyström

  • Rank
    Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Kenneth Nyström

    Save game feature: where do I put it in?

    Yeah I am thinking as small as possible; I only really need 1: what map was the player on: 2: optional------------(the position) (more then enough with just the normal: map-spawn- in-point) 3: two table values; thats cruicial to the "where in the game progress the player is" 4: save to disk 5 load when game starts. But I am absolutly CLUELESS where to begin. = I cant get anything to even begin make sense without a starting point where the save scripts is to be put. (there are no tutorials to be found) I can (in my mind) see how I only need like 5 or 6 lines of code to make this to be solved ---------------- Something like this: .................. function Script:SaveData() --This is to get the function goin. count1 = (count1 + 1) --This I hope is to name the save files diffrently each time a save is done {currentmap= "self.mapname" } --This line of code should possibly incl, the two table values of "lets call them "mylevel" & "mybuildlevel" local entityTable ={} {mylevel= "self.mylevel" mybuildlevel ="self.mybuildlevel" } return entityTable end ................................................................................................. Let me see if I have gotten the basic idea of what the load script should say: ................................................................................................... function Script:LoadData(data) --This is to have the load scrip going. (Game comes with a first "save" that has the starting values going --the first time it is started up; before the game saves its own save file for the first time) --here I suspect a line of code needs to be put in to identify the latest save; so game knows what file to --load currentmap = "" --the saved value above in save file mylevel = "" --the saved value above in save file mybuildlevel = "" --the saved value above in save file end .................... Any help to move me forward will be very much appreciated.
  2. Kenneth Nyström

    Save game feature: where do I put it in?

    So I have been putting this step off for some time. "the save function." ... I have this basic idea how and where it should be implemented: But the Leadwerks "index" for the save function is to say the least lacking regardng the "SaveData" and "LoadData" so I am actully stuck in my endevours to proceded with my game´s save/load function. Especially the part with how to "save" the map: one is currently on within the game, so when the load funtion is activated. the "correct" map is loaded, I strongly suspect: "SetCurrent" & "GetCurrent" (world) is the way to go. but how should it be implimented? Having the hardest time to figure out what the save part should look like to include the GetCurrent (world) ................................................................................................ function Script:SaveData() count1 = (count1 + 1) prefab = self.entity:GetKeyValue("prefab") pos = self.entity:GetPosition() rot = self.entity:GetRotation() world =????????  --is it? self.entity:GetCurrent (world) local entityTable ={} entityTable.posx = pos.x entityTable.posy = pos.y entityTable.posz = pos.z entityTable.rotx = rot.x entityTable.roty = rot.y entityTable.rotz = rot.z entityTable.prefab = prefab --is it also? entityTable.world =world return entityTable end ................................................................................................. Let me see if I have gotten the basic idea of what the load script should say: ................................................................................................... function Script:LoadData(data) r1 = data.rotx r2 = data.roty r3 = data.rotz p1 = data.posx p2 = data.posy p3 = data.posz world = data.mapname --is this correct? self.entity:SetCurrent (world) self.entity:SetRotation(r1,r2,r3) self.entity:SetPosition(p1,p2,p3) System:Print('Entity Loaded') end .................... Any pointers much appreciated as I am getting back into headspinning mode (again) but something tells me I might be getting closer to what I want to achive with my save/load scripts.
  3. Kenneth Nyström

    Gamecrash; due to kill or respawn script changes something...

    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.
  4. Kenneth Nyström

    Gamecrash; due to kill or respawn script changes something...

    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)
  5. Kenneth Nyström

    Gamecrash; due to kill or respawn script changes something...

    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?
  6. 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
  7. Question 1: How to set a script so if a global value is <= an object "always" stays hidden. (been fiddling around with various alternatives (gettng clearly better as I can debunk to a certian level now) Having it difficult to identify what keywords makes an object "remain" toggled hidden or shown if I map/area swap and then later returns to the same (hub) map ... I suspect it is done with an global value : Say: Deactive = nil ..... later/another "trigger script" changes the value when "triggered" ........ Deactivate = 1 ..... In the Object in question (i want to hide/show) and its script is where it gets tricky for me. ..... How to formulate the script so it turns "hidden" on for the object. when a value is <= (equal to or bigger). .... there is a few thoughts about the above but I suspect its better i get a push in the right direction then speculate to much at this stage in my learning. (Last day I have made (for me good progress) want to keep that "flow going for just a bit longer Thank You for help in advance.
  8. Kenneth Nyström

    Resolved

    Yeah I found it after I posted it Hence why i changed it to resolved in title.
  9. Kenneth Nyström

    Resolved

    Q:time What script code "word" is the one that makes one switch from one map to another?
  10. Kenneth Nyström

    Solved: '=' expected near 'function'

    WOW that was fast...and it worked... TY I never even thought of looking at the word End...ok that was a lesson learned.
  11. Kenneth Nyström

    Solved: '=' expected near 'function'

    So I am moving along with this video tutorial series # 25 checkpoint manager @ around 1143: on YT to get the hang of the basics. but I get a '=' expected near 'function' (on the 6th line from end: function Script:GetCheckpointPosition() I cant figure out why it isnt working. (pretty sure I have followed the instructions right) triple checked the text... ------------------------------------------------- Script.defaultCheckpoint = "" --entity "Default checkpoint" Script.currentCheckpoint = nil function Script:Start() if self.defaultCheckpoint == nil then error ("No default checkpoint") end self.currentCheckpoint = self.defaultCheckpoint End function Script:GetCheckpointPosition() return self.currentCheckpoint:GetPosition(true) end function Script:GetCheckpointRotation() return self.currentCheckpoint:GetRotation(true) end
  12. So I have tried and tried and tried; to change an objects mass thru a script. I basicly want to have an trigger (activate) "change" a mass in a diffrent object thru two scripts I have done and redone this so many times my head is spinning so hard ; I cant figure this out now. (I kid u not spent 20 hours to try solve this on my own) ............. trigger script be like: set the "global" value with getmass=2 ..... object script if getmass=2 then SetMass (5) ........
×