Jump to content

Genebris

Members
  • Posts

    517
  • Joined

  • Last visited

Everything posted by Genebris

  1. Does it work? For me it crashes, what values does it receive?
  2. Great question, we need a value that is the same each time you load a map, but is unique for every entity. MAYBE if Start execution order is always the same, then you can assign id yourself, but I doubt. This is probably not reliable. function Script:Start() { if not IDCounter then IDCounter = 0 end self.ID = IDCounter + 1 IDCounter = IDCounter + 1 ... Or just by entities order with world:GetEntity() if it's always the same. I don't think you can do this with new animation commands. Strange, there is SetAnimationFrame but no GetAnimationFrame. But you can do it with old AnimationManager script.
  3. Why can't you make a table of all needed data and loop through it to save each table key and value into file? Remember that these two lines refer to the same variable: myTable.abc myTable["abc"] Try something like this: for k,v in pairs(myTable) do stream:WriteLine(k.."="..v) end This way you will get a file like this: health=35 armor=20 magic=110 To load this data into the game you need to read each string, separate it by "=" symbol and use left part as key and right as value. data={} while (not stream:EOF()) do local s = stream:ReadLine() local i = string.find(s,"=") local k = string.sub(s,1,i-1) local v = string.sub(s,i+1) data[k]=v end I haven't actually tried this code, so there can be mistakes. I believe you won't even need to convert value from string to number, it should be converted automatically if used in calculation. But you can also use tonumber function http://www.lua.org/manual/5.1/manual.html#pdf-tonumber You can also use string value to access global table itself because every global variable is an element of _G table. These two lines also refer to the same variable: myT.a _G["myT"]["a"] So you can make a header in your save file like this: [player] health=10 magic=20 And when you read a string that starts with "[" you can use it as a name of table which you are going to fill with data. if string.sub(s,1,1) == "[" then local tableName = string.sub(s,2,string.len(s)-1) ... _G[tableName][k]=v
  4. Moving objects with SetPosition or Move will break Physics simulation. What if you give it a mass, set collision to Trigger so it doesn't bounce itself and then control it's movement with PhysicsSetPosition?
  5. You didn't include the script. zack57, use default scripts, they have all examples you need.
  6. You should do it in Script:PostRender function, look how default player interface is drawn.
  7. In the last two tournaments I realized how painful it is to use editor when you have more than 10 objects on the map. I think it could be changed with a few improvements: Characters' bones and other child objects take up most of the space in the hierarchy window and 99% of the time you don't need to look at them. And this is just one goblin character. Sure, artist probably shouldn't have included so many child objects, but it shouldn't be a problem anyway. Suggestions: All child objects in the hierarchy should be collapsed when map is opened. When you add new objects, their children should be collapsed by default. It should never uncollapse automatically. It definitely shouldn't uncollapse when object is selected. Again 99% of the time when you select an object you only want to move it, you don't want to check if all those hundreds of bones are still there. There could be a small "Collapse all" button. "Frame Selection" button should scroll the hierarchy to the selected object. Also, there should be a hotkey for it, "F" for example. "Move to folder" button would help avoid a lot of scrolling Search field Prefabs suggestions: When saving altered prefab save dialog should open with a path to prefab's last version. For example, I have a prefab with this path: "prefabs/enemies/goblin1.pfb". I have loaded it, changed and pressed save as prefab. Save window should open with "prefabs/enemies/" path opened and file goblin1.pfb should already be selected. Not only it saves time, but also eliminates the risk of overwriting wrong prefab and loosing your data, which happened to me several times. Prefabs should remember a hierarchy folder that they were saved from and appear in this folder when added to the scene. If I have saved goblin in "Entities" folder then it should appear in this folder next time I add it to the scene (if this folder still exists).
  8. Steam support usually returns your account if you confirm your purchases with keys or credit card info, but they answer very slow, you may need to wait a few weeks.
  9. I have also used material names to determine sound type, for example, material named "my dark_wood 76" will play "wood" sounds. But my script uses footsteps manager like old animation manager. This way you can use it both for player and NPCs and any other objects. Supports several sounds per material type, 3D sound, can be played from many characters at the same time, only need 3 lines of code to add to your script (import, create, update). Main script: https://gitlab.com/Genebris/MSC-Footsteps/blob/master/Scripts/Footsteps.lua Download project (120 MB): https://gitlab.com/Genebris/MSC-Footsteps/repository/archive.zip?ref=master
  10. I'm gettings a material from csg without script or mass. Do you get the surface? tolua.cast(pickinfo.entity, "Model"):GetSurface(0):GetMaterial()
  11. You didn't include textures with a map, but I'll download something else anyway.
  12. Yes, it works now. This should be mentioned here: http://www.leadwerks.com/werkspace/page/api-reference/_/prefab/prefabload-r622
  13. You need two scripts for one object? Add a child pivot and use second script on it.
  14. This returns mousewheel position http://www.leadwerks.com/werkspace/page/api-reference/_/window/windowgetmouseposition-r455
  15. You can remove main.system to make the function global by itself. function CallFunction(entity, func, a,b,c) This fragment simply calls needed function with optional parameters. You don't have to use any parameters, or you can use only two of them because it's Lua. ... func = "Hurt" a = 5 --damage b = "Magic" --damage type --C not used entity.script[func](entity.script,a,b,c) ... You need to pass entity.script as a first parameter because you are calling function via "." instead of ":" I think I wasn't able to call it with ":" this way, so I passed script manually. When you have global function created all you need to do is this: local e = Prefab:Load("prefabs/myprefab.pfb") CallFunction (e, "Start")
  16. I made this function so I can call something on all child objects at any time from any script. function main.system:BroadcastMessage(entity, func, a,b,c) if entity.script and type(entity.script[func])=="function" then entity.script[func](entity.script,a,b,c) end for i=0, entity:CountChildren()-1 do local child = entity:GetChild(i) if child:CountChildren()~=0 then self:BroadcastMessage(child, func, a,b,c) end if child.script and type(child.script[func])=="function" then child.script[func](child.script,a,b,c) end end end
  17. http://www.leadwerks.com/werkspace/page/api-reference/_/math/mathcurve-r602 Use this to slide camera to the second position. When it's almost reached start sliding to the base position. Repeat after 2 seconds.
  18. Why don't you move camera down or to the side for a moment every one or two seconds?
  19. http://www.leadwerks.com/werkspace/page/api-reference/_/entity/entitysetvelocity-r822
  20. Maybe you want to use SetVelocity? Or you could reduce friction to allow smaller forces.
  21. Remember last map you loaded into a variable or have a script on the map that tells you which one it is then this into UpdateWorld: if window:KeyHit(Key.R) then World:GetCurrent():Clear() Map:Load("maps/"..self.map..".map") end
  22. Prefab:Load("prefabs/projectiles/arrow.pfb") Prefab:Load("prefabs/projectiles/arrow.pfb",Map.LoadScripts,Prefab.NoStartCall) First function will load prefab correctly, second one will fail to load it. This will be in the log: Loading prefab "C:/Users/Genebris/Desktop/SotKaal/prefabs/projectiles/arrow.pfb"... .. Loading prefab "prefabs/projectiles/arrow.pfb" [32]... Error: Failed to read file "prefabs/projectiles/arrow.pfb". Error: Failed to load prefab "prefabs/projectiles/arrow.pfb". You can see that second call didn't get a correct file path. This happens ONLY in published game (standalone or launcher). Does NOT matter if you included only used files or not. It doesn't happen in the editor or if you launch exe in your project folder. I'm not sure if this is the correct use of loading flags, but if it's not, it should at least give the same error in the editor because I spent 40 minutes thinking that my prefab doesn't get included into the build.
  23. Why do you need shader? Why don't you use particle emitter?
  24. You need blend mode set to alpha, z sort enabled and change diffuse color to half transparent. There is also default glass material in Materials/Effects in FPS template. But all half transparent materials really don't work well in Leadwerks, they won't receive shadows.
  25. Has this been added? I need it for tournament
×
×
  • Create New...