Enkanet Posted January 9, 2015 Posted January 9, 2015 Hello everyone. I need to show a picture for my item but I need to show the pictures of the item by the value of the item. I have skin items and ids. So, if the skin item's value is 1 so when I use the item I get a skin with the id of 1. I have a folder for them which is called "img" folder. There're skin pictures inside it and they are ordered from "1.png" to "299.png" (example) I want to show that pictures with my item by using the value. I am using that code and it works. "return ":img/" .. ("%03d"):format(itemValue) .. ".png"" but sometimes I have item value like 120:1 so the game tries to find an image with name of 120:1.png but it can't. Now I want to ignore the numbers after ":" this syntax. So if the item's value is 120:1 the game should show me a picture of 120. Sorry if I made mistakes with my English. I am writing this at 4:30AM and I am so sleepy. So forgive me if I made a mistake. Thanks. Regards.
MTA Team botder Posted January 9, 2015 MTA Team Posted January 9, 2015 value = "120:1" number = tonumber(value:match("%d+")) I don't recommend using that on each render call, but it should work.
Enkanet Posted January 9, 2015 Author Posted January 9, 2015 First of all thanks for your time and comments. I am using that to draw a dximage and value is not given manually. It is but it is given manually in game item by item. So I can't do value = "120:1" All I need is ignore :1 from 120:1. Thanks
MTA Team botder Posted January 9, 2015 MTA Team Posted January 9, 2015 You shouldn't do heavy operations on each frame render. You could save a string with the file path for each item.
Enkanet Posted January 9, 2015 Author Posted January 9, 2015 Still will be same because I can not write it for each skin because it is not only 120:1 whenever you add a new skin like it, it'll make another value like 120:2 and people will continue adding. Anymore way? There should be.
Enkanet Posted January 9, 2015 Author Posted January 9, 2015 Thanks everyone! I solved the problem. I did value:gsub(":" .. "%d", "") and it worked. Thanks to everyone for their time, comments, helps..
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