JonSyn Posted May 13, 2014 Share Posted May 13, 2014 i been trying to figure this out for a couple hours to finish my chop up corpse for meat/bury corpse mod, but i cant figure it out .i need to check if its a corpse and if its on a natural tile and if it is have it show the bury corpse menu. it checks if its a corpse and if you have a shovel equiped but when i get to the part to check if its a natural tile i fail.eatNbury.onFillWorldObjectContextMenu = function(player, context, worldobjects) local player = getSpecificPlayer(0); local weapon = player:getPrimaryHandItem(); local tile = getFloor():getSprite():getName(); local itemList = {} for i,v in ipairs(worldobjects) do if v:getSquare() then for n = 0,v:getSquare():getWorldObjects():size()-1 do local item = v:getSquare():getWorldObjects():get(n) local itemName = item:getName() or (item:getItem():getName() or "???") if not itemList[itemName] then itemList[itemName] = {} end table.insert(itemList[itemName], item) end end end if body and weapon:getType() == "Axe" then local itemName = "Corpse"; context:addOption(getText("Chop Up") .." ".. itemName, worldobjects, eatNbury1.buryNeat, body); end if body and weapon:getType() == "Shovel" and tile == "blends_natural" then local itemName = "Corpse"; context:addOption(getText("Bury") .." ".. itemName, worldobjects, eatNbury2.buryNeat, body); endend Link to comment Share on other sites More sharing options...
RoboMat Posted May 13, 2014 Share Posted May 13, 2014 Well that's because you need to get the square before you can do: getFloor():getSprite():getName(); Right now you try to call it from nothing. Link to comment Share on other sites More sharing options...
JonSyn Posted May 13, 2014 Author Share Posted May 13, 2014 iv tried alot beside just what i posted, even looked thru the farming lua and any that would involve ground tiles.local square = getPlayer:getSquare();local tile = square:getFloor():getSprite():getName();local square = getWorld:getSquare();local tile = square:getFloor():getSprite():getName();local square = getSquare();local tile = square:getFloor():getSprite():getName();local square = getSquare();local tile = square:getFloor():getSprite():getTextureName();and a number of others , plus i looked thru the spraypaint mos and erosion mods to see how they get the tile. they dont do it anything alike so i cant figure it out. and this is literally the last part of the mod to finish and its done. can chop up corpses with axe and they delete and drop meat that can be cooked and eaten( custom meat ), or you can bury a corpse with a spade or trowel. Link to comment Share on other sites More sharing options...
RoboMat Posted May 13, 2014 Share Posted May 13, 2014 IsoWorld and co. don't even have a getSquare() function What square do you want to check anyway? Why not use the one from your iterator? Link to comment Share on other sites More sharing options...
JonSyn Posted May 13, 2014 Author Share Posted May 13, 2014 would if i knew how. its why im asking for help. Link to comment Share on other sites More sharing options...
EnigmaGrey Posted May 13, 2014 Share Posted May 13, 2014 Here's a hint: If v:getSquare() returns the square you clicked on . . . Link to comment Share on other sites More sharing options...
JonSyn Posted May 13, 2014 Author Share Posted May 13, 2014 yeah i got that var lol, and im assuming i need to make another tableeatNbury.onFillWorldObjectContextMenu = function(player, context, worldobjects) local player = getSpecificPlayer(0); local weapon = player:getPrimaryHandItem(); local itemList = {} for i,v in ipairs(worldobjects) do if v:getSquare() then for n = 0,v:getSquare():getWorldObjects():size()-1 do local item = v:getSquare():getWorldObjects():get(n) local itemName = item:getName() or (item:getItem():getName() or item:getFloor():getSprite():getName() or "???") if not itemList[itemName] then itemList[itemName] = {} end table.insert(itemList[itemName], item) end end end if body and weapon:getType() == "Axe" then local itemName = "Corpse"; context:addOption(getText("Chop Up") .." ".. itemName, worldobjects, eatNbury1.buryNeat, body); end if body and weapon:getType() == "Shovel" and blends_natural then local itemName = "Corpse"; context:addOption(getText("Bury") .." ".. itemName, worldobjects, eatNbury2.buryNeat, body); endendeatNbury.onFillWorldObjectContextMenu = function(player, context, worldobjects) local player = getSpecificPlayer(0); local weapon = player:getPrimaryHandItem(); local itemList = {} for i,v in ipairs(worldobjects) do if v:getSquare() then for n = 0,v:getSquare():getWorldObjects():size()-1 do local item = v:getSquare():getWorldObjects():get(n) local itemName = item:getName() or (item:getItem():getName() or "???") local tile = item:getFloor():getSprite():getName(); if not itemList[itemName] then itemList[itemName] = {} end table.insert(itemList[itemName], item) end end end if body and weapon:getType() == "Axe" then local itemName = "Corpse"; context:addOption(getText("Chop Up") .." ".. itemName, worldobjects, eatNbury1.buryNeat, body); end if body and weapon:getType() == "Shovel" and blends_natural then local itemName = "Corpse"; context:addOption(getText("Bury") .." ".. itemName, worldobjects, eatNbury2.buryNeat, body); endendi dont know........... Link to comment Share on other sites More sharing options...
RoboMat Posted May 13, 2014 Share Posted May 13, 2014 The big problem here is, that I'm not sure what you are doing here alltogether (lack of comments etc. ) ... e.g.:for i,v in ipairs(worldobjects) do if v:getSquare() then for n = 0,v:getSquare():getWorldObjects():size()-1 do local item = v:getSquare():getWorldObjects():get(n)So you cycle through the world objects, then you get the square of that world object and then you cycle through the square of that world object to get all world objects again? Then you cycle through that and get the world object at position 'n' in the world object table?Anyway - considering you get the correct object from the above code (which I doubt) - then you can try something like this:local tileName = item:getSquare():getFloor():getSprite():getName();Or you can try this:local tileName = v:getSquare():getFloor():getSprite():getName();Also another small tip:You can rewrite if not itemList[itemName] then itemList[itemName] = {} endasitemList[itemName] = itemList[itemName] or {};Also what is "if body and weapon:getType() == "Shovel" and blends_natural then" supposed to do? Unless you have a global variable of the name blends_natural somewhere and it is set to anything other than nil or false this if-statement will always fail. Link to comment Share on other sites More sharing options...
RobertJohnson Posted May 13, 2014 Share Posted May 13, 2014 Didn't read all the post, but erm, you use the fillContextMenu which give you in parameter ALL the world object/object clicked in parameter, so why fetch again all the object on the square ? Just do the for _,v in ipairs(worldobjects) do Then test if it's an instance of IsoDeadBody (if i understood what you want ) Link to comment Share on other sites More sharing options...
harakka Posted May 13, 2014 Share Posted May 13, 2014 Didn't read all the post, but erm, you use the fillContextMenu which give you in parameter ALL the world object/object clicked in parameter, so why fetch again all the object on the square ? Just do the for _,v in ipairs(worldobjects) do Then test if it's an instance of IsoDeadBody (if i understood what you want )The OP didn't provide a lot of info, but I'm guessing he wants to know the type of terrain on the tile to know if a corpse can be buried there. Link to comment Share on other sites More sharing options...
JonSyn Posted May 13, 2014 Author Share Posted May 13, 2014 yeah i have been able to remove the corpse just fine, what i want to do is check if its a exterior tile and if its a natural tile like grass or dirt or sand and if it is bury it. should have it working soon tho. Link to comment Share on other sites More sharing options...
RoboMat Posted May 13, 2014 Share Posted May 13, 2014 Basically I gave you all the information you need to achieve that in my reply above Link to comment Share on other sites More sharing options...
JonSyn Posted May 13, 2014 Author Share Posted May 13, 2014 buries corpses on grass tiles, not in homes,on roads, or on dirt , i used 'blends_natural' . and i see that 'blends_natural_02' is water , and 'blends_street' is streets but is there others? Basically I gave you all the information you need to achieve that in my reply above didnt work, but this did....if body and weapon:getType() == "Shovel" and luautils.stringStarts(v:getSprite():getName(), 'blends_natural_01') or body and weapon:getType() == "Shovel" and luautils.stringStarts(v:getSprite():getName(), 'blends_grassoverlays_01') then local itemName = "Corpse"; context:addOption(getText("Bury") .." ".. itemName, worldobjects, ZambieCleaner1.CleanZambies1, body); thanks for the help so far. Link to comment Share on other sites More sharing options...
JonSyn Posted May 13, 2014 Author Share Posted May 13, 2014 well i cant bury in tall grass....... whats the name for the tall grass does anyone know? Link to comment Share on other sites More sharing options...
RoboMat Posted May 13, 2014 Share Posted May 13, 2014 Simply print() it to the console to find out Link to comment Share on other sites More sharing options...
JonSyn Posted May 13, 2014 Author Share Posted May 13, 2014 dont know how to do that yet lol edit: i mean i know how to use print, just dont know how to make it print info like that. Link to comment Share on other sites More sharing options...
JonSyn Posted May 13, 2014 Author Share Posted May 13, 2014 buries the corps, places a dirt tile where corpse was, works outside on natural tiles but dosnt work inside or on roads (clyde) (clyde) (clyde) 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