Search the Community
Showing results for tags 'method'.
-
While coding my mod I faced with another problem. I'm trying to make a character say a phrase when dressing a certain item. I tried to implement this with Events.OnClothingUpdated.Add(). When this event was called, it was checked whether this item (CI141.KRNDHazmat) was dressed. I did this through a method getBodyLocation() ~= "". But every time it gave an error. I suspect that the problem is that item CI141.KRNDHazmat belongs to a different class, but getBodyLocation() method belongs to the class Clothes. But no matter how hard I tried, I couldn't determine the class of the object CI141.KRNDHazmat. I need help from someone who understands. I paste code below. Script [media/scripts/CI141_items.txt] item KRNDHazmat { DisplayCategory = Clothing, Type = Clothing, DisplayName = KRND Hazmat Suit, ClothingItem = CI141_KRNDHazmat, BodyLocation = FullSuitHead, Icon = KRNDHazmat, BloodLocation = Trousers;Jumper, Icon = Hazmatsuit, RunSpeedModifier = 0.75, ScratchDefense = 25, BiteDefense = 25, Insulation = 0.65, WindResistance = 0.9, WorldStaticModel = Hazmat_Ground, } the .xml file works fine, so I don't see the point in attaching it here LUA [media/lua/client/CI141_maincore.lua] function HazmatvoiceFc(player) local hazmat = "CI141.KRNDHazmat" if player:getInventory():contains(hazmat) then if hazmat:getBodyLocation() ~= nil then <- Error comes from this line player:Say("TESTPHRASE") end end end Events.OnClothingUpdated.Add(HazmatvoiceFc)
-
For future reference, since this was frustrating to calculate. Here is the method for all to use. it calculates the grid square that your mouse is over based on screen size and properly accounts for the Zoom level as well. using the center of the screen as a starting point. local sw = (128 / getCore():getZoom(0)); local sh = (64 / getCore():getZoom(0)); local mapx = getPlayer():getX(); local mapy = getPlayer():getY(); local mousex = ( (getMouseX() - (getCore():getScreenWidth() / 2)) ) ; local mousey = ( (getMouseY() - (getCore():getScreenHeight() / 2)) ) ; local sx = mapx + (mousex / (sw/2) + mousey / (sh/2)) /2; local sy = mapy + (mousey / (sh/2) -(mousex / (sw/2))) /2; local TheSquareYourMouseIsOn = getCell():getGridSquare(sx,sy,getPlayer():getZ());
-
I suggest adding a method that will allow us to load skinned mesh in game! I replaced the original models of clothes, and it looks good. But unfortunately adding them without replacing the original is impossible, since there is no skinned model load method. :(( Class LuaManager.GlobalObject has a method that allows loading a static model, but it does not allow upload skinned model, because it sends boolean true to ModelLoader.instance.Load