RoboMat Posted August 15, 2013 Author Share Posted August 15, 2013 Yay Robo , thanks for the tutorial In addition to the other tutorial its much easier to start PZ-modding Glad you like 'em. I hope I'll get around updating them soonish. Link to comment Share on other sites More sharing options...
speider Posted August 19, 2013 Share Posted August 19, 2013 one thing i don't understand is what "float" is? example AddGeneralHealth(float) ^ Link to comment Share on other sites More sharing options...
dida55 Posted August 19, 2013 Share Posted August 19, 2013 one thing i don't understand is what "float" is? example AddGeneralHealth(float) ^http://www.techopedia.com/definition/23980/float Link to comment Share on other sites More sharing options...
speider Posted August 19, 2013 Share Posted August 19, 2013 one thing i don't understand is what "float" is? example AddGeneralHealth(float) ^http://www.techopedia.com/definition/23980/float ty kind sir that explained some:)probably know how to do the stuff i want to work now:) Link to comment Share on other sites More sharing options...
RoboMat Posted August 20, 2013 Author Share Posted August 20, 2013 ty kind sir that explained some:)probably know how to do the stuff i want to work now:) Float stands for floating point numbers, but technically speaking, there is no such thing as floats in lua. In java you have different variables that represent different number types. For example a byte type in java will only take numbers from -128 to 127 whereas an int can take numbers from -2,147,483,648 to 2,147,483,647. The difference is of course that a byte will take less memory and should be used if you know that there won't be any larger nummers. Theoretically it should speed up some processes, but in most if not all cases the performance increase should be negligable. Lua doesn't care if you have an integer or an float it treats all numbers the same. Moreover lua doesn't care which type a variable is. A variable can be all kinds of stuff. Functions for example are also variables of type function - that's why you sometimes see declarations as:Package.functionName = function(param1, param2)...endWhich I find pretty ugly personally (though it's just a question about coding style). What should you learn? That lua doesn't care about the type of the number, but java does. As far as I can tell, most of the time when PZ wants a float it wants a real number from 0 to 1 so you can pass it 0,233332 for example. If it takes an int and you pass it a float it should be rounded to an int automatically on conversion. Hope that was understandable.If anything is incorrect, feel free to correct me people. Maybe I'm gonna put that into the tutorial. Link to comment Share on other sites More sharing options...
speider Posted August 20, 2013 Share Posted August 20, 2013 yeah pls put it in the tutorial it's important stuff:) Link to comment Share on other sites More sharing options...
Tombas McCombas Posted August 29, 2013 Share Posted August 29, 2013 Nice post, thanks for that! Link to comment Share on other sites More sharing options...
lemmy101 Posted August 29, 2013 Share Posted August 29, 2013 ty kind sir that explained some:)probably know how to do the stuff i want to work now:) Float stands for floating point numbers, but technically speaking, there is no such thing as floats in lua. In java you have different variables that represent different number types. For example a byte type in java will only take numbers from -128 to 127 whereas an int can take numbers from -2,147,483,648 to 2,147,483,647. The difference is of course that a byte will take less memory and should be used if you know that there won't be any larger nummers. Theoretically it should speed up some processes, but in most if not all cases the performance increase should be negligable. Lua doesn't care if you have an integer or an float it treats all numbers the same. Moreover lua doesn't care which type a variable is. A variable can be all kinds of stuff. Functions for example are also variables of type function - that's why you sometimes see declarations as:Package.functionName = function(param1, param2)...endWhich I find pretty ugly personally (though it's just a question about coding style). What should you learn? That lua doesn't care about the type of the number, but java does. As far as I can tell, most of the time when PZ wants a float it wants a real number from 0 to 1 so you can pass it 0,233332 for example. If it takes an int and you pass it a float it should be rounded to an int automatically on conversion. Hope that was understandable.If anything is incorrect, feel free to correct me people. Maybe I'm gonna put that into the tutorial. More specifically, EVERY number in Kahlua is a double. Bar none. Even ints. But yeah, there's a part between lua and java where it converts those doubles into floats, ints, shorts, whatever the function its trying to call needs. (speider: double is like a float but with 'double' the size of a float, so a higher / lower number is possible) RoboMat 1 Link to comment Share on other sites More sharing options...
speider Posted August 30, 2013 Share Posted August 30, 2013 appriciate the explanations will still take a long time for me to learn the lua:) Link to comment Share on other sites More sharing options...
lemmy101 Posted August 30, 2013 Share Posted August 30, 2013 All you ever really NEED to know is if the java says one of the following: floatdoublelongintshort you can just mentally substitute that with 'number'. That's all you NEED to know. A useful addition is that: floatdouble 0.3443 is possible. Each of these represents a number that can be 1, 2, 3, 4 or any point in between them. 1.3, 2.54345, 4.565634 etc. A character can't just stand on one tile or another, he can stand on the edge of a tile, or 1/4 down it and 1/7 across it. A character in the middle of tile 130, 212 is at 130.5, 212.5 (0.5 of the way through, or 50%) where a character stood on the point between 4 tiles is at 130, 212 (or the very top left of a tile). A character could be 25.543534% hungry, or 13.453534% damp, so again these are 'float' kinda values. longintshort 0.3443 is not possible, since decimal places do not exist. It's like counting on fingers, you count 1, 2, 3, 4 and nothing exists between those values. Integer values (int, long, short) are useful for counting and stuff. You have 10 zombies, or 24 zombies. You never have 12.43 zombies. So passing 123.456 into a java function that wanted an int, it would become 123 and would just chop off the decimal places. It won't round up. Even 12.999999 would become 12. If you try to get tile 213.432, 312.423 it will not return a mythical tile inbetween two tiles. It'll trim off the decimal places and assume you want tile 213, 312. Last thing you maybe need to know is that integers are important, and since lua does not have them sometimes you have to force the issue. If you divide a group of 11 zombies into 2, you don't want 5.5 zombies in each group, you can do this in lua by doing.... totalGroupSize = 11 eachGroupIdealSize = totalGroupSize / 2 -- this is now 5.5groupASize = math.floor(eachGroupIdealSize) -- floor makes 5.5 into 5, cuts of decimal place like intgroupBSize = totalGroupSize - groupASize -- now group A is 5 and group B is 6, instead of them being 5.5 each. Pasty Dude 1 Link to comment Share on other sites More sharing options...
Realmkeeper Posted August 31, 2013 Share Posted August 31, 2013 The only fault I find in your explanation, lemmy, is that math.floor (as you described in your GroupSize example) most likely doesn't truncate (or rather cut off the decimal places).In most languages, the floor function returns the largest integer that is smaller (or equal) than the given number.So although math.floor(5.5) gives you 5, math.floor(-5.5) would give you -6. (you learn that one the hard way usually, most people do assume it truncates) I'm assuming that the floor function works this way in Lua, though without looking it up myself I can't confirm it. Link to comment Share on other sites More sharing options...
RoboMat Posted September 4, 2013 Author Share Posted September 4, 2013 Thanks for the clarification folks. I think I'll add it somewhere in the tutorials. First I got to update it though Link to comment Share on other sites More sharing options...
RoboMat Posted October 1, 2013 Author Share Posted October 1, 2013 Updated the OP. - Added table of content - Easier navigation - Updated most of the tutorial's code - Added new stuff - ... Link to comment Share on other sites More sharing options...
Kidlonewolf Posted October 27, 2013 Share Posted October 27, 2013 Updated the OP.- Added table of content- Easier navigation- Updated most of the tutorial's code- Added new stuff- ...And im glad you did, this is great work Robomat! love your mods as well Link to comment Share on other sites More sharing options...
RoboMat Posted November 7, 2013 Author Share Posted November 7, 2013 UPDATED: Added section that explains how to create new professions ... it is not completely done and some parts might be rough around the edges, but sometimes it is harder to write these things than they sound in my head (especially in a -to me- foreign language). I think I might need to update the section about the modloader stuff too. Will do so post-steam release. Link to comment Share on other sites More sharing options...
RoboMat Posted November 8, 2013 Author Share Posted November 8, 2013 UPDATED: Updated the professions tutorial and updated some of the other sections. Link to comment Share on other sites More sharing options...
Ramibuk Posted November 9, 2013 Share Posted November 9, 2013 Great work man,always when I'm stuck with something i found answer in one of yours guides or mods Also to custom colors of clothes as it was hard to get at first:topCol = { r = 0.1, g = 0.1, b = 0.1, },i read one thread about this and best answer by RobertJohnson was: For the color, it's from 0 to 1, just like 0 to 255, so if I want to do 120 in R, I just need to do 120/255 = 0.47, and if you want to know the color we used, just multiply the numbers by 255 So you can use this simulator http://www.colorschemer.com/online.html to generate your color and then /255 all values Link to comment Share on other sites More sharing options...
RoboMat Posted November 10, 2013 Author Share Posted November 10, 2013 Yeah the profession stuff was a bit rushed. I guess I will try to re-write it so it is a bit easier to understand Thank you Updated:Some small formatting and text changes. Guide is also available directly on steam now. Link to comment Share on other sites More sharing options...
Riplash Posted November 29, 2013 Share Posted November 29, 2013 The apostrophe in the word "can't" causes the remainder of the code to appear commented out in the code shown after:"The complete file should look like this:" Link to comment Share on other sites More sharing options...
tommysticks Posted December 1, 2013 Share Posted December 1, 2013 I tried copying this code word for word and it didn't work. I think it was a problem with the coordinates. This is what I came up with: local function initTraits()TraitFactory.addTrait("rm_Undesireable", "Undesireable", 0, "Allows you to cheat. Shame on you!", true);end local function initProfessions()local cheater = ProfessionFactory.addProfession("cheater", "Cheater", "rm_Cheater"); cheater:addFreeTrait("rm_Undesireable");cheater:addFreeTrait("NightOwl"); local cheater2 = ProfessionFactory.addProfession("cheater2", "Cheater 2", "rm_Cheater"); cheater2:addFreeTrait("rm_Undesireable");cheater2:addFreeTrait("NightOwl");end local function initSpawnPoints()local spawn1;spawn1 = {{worldX = 35,worldY = 31,posX = 112,posY = 16,},}spawn2 = {{worldX = 35,worldY = 34,posX = 127,posY = 223,},} BaseGameCharacterDetails.spawnPoint.MuldraughKY.cheater = spawn1; spawn1 = {{worldX = 35,worldY = 31,posX = 112,posY = 16,},} BaseGameCharacterDetails.spawnPoint.MuldraughKY.cheater2 = spawn2; spawn2 = {{worldX = 35,worldY = 34,posX = 127,posY = 223,},}end local function initClothing()local clothes = {male = {topPal = "Shirt_White",top = "Shirt",bottomPal = "Trousers_White",bottom = "Trousers",topCol = {r = 0.1,g = 0.1,b = 0.1,},bottomCol = {r = 0.1,g = 0.1,b = 0.1,},},female = {topPal = "Shirt_White",top = "Shirt",bottomPal = "Trousers_White",bottom = "Trousers",topCol = {r = 0.1,g = 0.1,b = 0.1,},bottomCol = {r = 0.1,g = 0.1,b = 0.1,},},}ProfessionClothing.cheater = clothesProfessionClothing.cheater2 = clothes;end Events.OnGameBoot.Add(initTraits);Events.OnGameBoot.Add(initProfessions);Events.OnGameBoot.Add(initSpawnPoints);Events.OnGameBoot.Add(initClothing); That has been working for me for debugging purposes. The first Profession spawns you in the warehouse, the second near the police station. Link to comment Share on other sites More sharing options...
elvendertig Posted December 5, 2013 Share Posted December 5, 2013 Edit: I think I may have posted this in the wrong topic. I made a topic of my own in the Modding Help section. If you're interested in helping me out:http://theindiestone.com/forums/index.php/topic/3936-extending-existing-item/ Link to comment Share on other sites More sharing options...
RoboMat Posted December 14, 2013 Author Share Posted December 14, 2013 I tried copying this code word for word and it didn't work. I think it was a problem with the coordinates. This is what I came up with: local function initTraits()TraitFactory.addTrait("rm_Undesireable", "Undesireable", 0, "Allows you to cheat. Shame on you!", true);end local function initProfessions()local cheater = ProfessionFactory.addProfession("cheater", "Cheater", "rm_Cheater"); cheater:addFreeTrait("rm_Undesireable");cheater:addFreeTrait("NightOwl"); local cheater2 = ProfessionFactory.addProfession("cheater2", "Cheater 2", "rm_Cheater"); cheater2:addFreeTrait("rm_Undesireable");cheater2:addFreeTrait("NightOwl");end local function initSpawnPoints()local spawn1;spawn1 = {{worldX = 35,worldY = 31,posX = 112,posY = 16,},}spawn2 = {{worldX = 35,worldY = 34,posX = 127,posY = 223,},} BaseGameCharacterDetails.spawnPoint.MuldraughKY.cheater = spawn1; spawn1 = {{worldX = 35,worldY = 31,posX = 112,posY = 16,},} BaseGameCharacterDetails.spawnPoint.MuldraughKY.cheater2 = spawn2; spawn2 = {{worldX = 35,worldY = 34,posX = 127,posY = 223,},}end local function initClothing()local clothes = {male = {topPal = "Shirt_White",top = "Shirt",bottomPal = "Trousers_White",bottom = "Trousers",topCol = {r = 0.1,g = 0.1,b = 0.1,},bottomCol = {r = 0.1,g = 0.1,b = 0.1,},},female = {topPal = "Shirt_White",top = "Shirt",bottomPal = "Trousers_White",bottom = "Trousers",topCol = {r = 0.1,g = 0.1,b = 0.1,},bottomCol = {r = 0.1,g = 0.1,b = 0.1,},},}ProfessionClothing.cheater = clothesProfessionClothing.cheater2 = clothes;end Events.OnGameBoot.Add(initTraits);Events.OnGameBoot.Add(initProfessions);Events.OnGameBoot.Add(initSpawnPoints);Events.OnGameBoot.Add(initClothing); That has been working for me for debugging purposes. The first Profession spawns you in the warehouse, the second near the police station. Thanks. I think the code in the tutorial still uses the old code for profession spawns which got changed recently. I'll update it soonish The apostrophe in the word "can't" causes the remainder of the code to appear commented out in the code shown after:"The complete file should look like this:" Blame the IPB folks for not finding lua-code-comments Link to comment Share on other sites More sharing options...
Ramibuk Posted December 21, 2013 Share Posted December 21, 2013 I have troubles with custom spawn points. I wrote down coordinates with http://pz-mods.net/other/CoordinateViewer/ but it spawn player in cell +1x or +1y or both or none.I have no idea why,because some spawn points works and all are empty tiles in buildings local function initSpawnPoints() local spawn spawn = { {worldX = 35,worldY = 32,posX = 201,posY = 223},---spawn at {worldX = 36,worldY = 33,posX = 201,posY = 223} {worldX =35,worldY =31,posX =112,posY =9},--- spawn good {worldX = 38,worldY = 36,posX = 16,posY = 190},---spawn at {worldX = 38,worldY = 37,posX = 16,posY = 190} {worldX = 37,worldY = 32,posX = 175,posY = 134},---spawn at{worldX = 38,worldY = 32,posX = 175,posY = 134}, {worldX = 36,worldY = 33,posX = 289,posY =116 },---spawn at {worldX = 37,worldY = 33,posX = 16,posY = 190} {worldX =35 ,worldY =33 ,posX =146 ,posY =229 },---spawn at {worldX =35 ,worldY =34 ,posX =146 ,posY =229 } } BaseGameCharacterDetails.spawnPoint.MuldraughKY.Handyman = spawn Link to comment Share on other sites More sharing options...
RoboMat Posted December 21, 2013 Author Share Posted December 21, 2013 What exactly is the problem with your spawns? I didn't understand The tutorial is a bit outdated ... will try to update tomorrow or next week. Link to comment Share on other sites More sharing options...
Ramibuk Posted December 21, 2013 Share Posted December 21, 2013 (edited) I want to make spawn point with coordinates worldX = 35,worldY = 32,posX = 201,posY = 223 but when i set it as spawnpoint,player is spawned on location {worldX = 36,worldY = 33,posX = 201,posY = 223} what is in next cell x+1 and y+1. Also others coordinates i tried spawn player in next cell x+1 or y+1.I tried 6 diffrent coordinates and only one spawn player in right cell.See code i posted above, in every line there are coordinates i want and then coordinates where player is actualy spawned EDIT so Coordinate Viewer gives me values : {worldX = 36,worldY = 33,posX = 289,posY =116 } i set spawnpoint in lua to cell under it : {worldX = 35,worldY = 33,posX = 289,posY =116 } it spawn me on right spot but Viewer say its {worldX = 36,worldY = 33,posX = 289,posY =116 } Maybe rounding problem in Coordinate viewer? You know sometimes it work good,sometimes change cell x, sometimes cell y , or both. Edit 2 its problem with rounding cells inCoordinate Viewer :Absulte:X: 10 789Y: 10 016 Relative:CellX: 36 !! its 35,9CellY: 33X: 289Y: 116 Edited December 21, 2013 by Ramibuk Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now