I posted in the correct forum for peripherals but never got a response and the post below me didn't get a single response since oct 4.
Well anyway is there a way to do a code like this as for some reason the : breaks it but the item I'd requires it.
If Id == 227:3 then
Enter code here
end
How can I do this while still having the : in the code?
Here's link to orriginal post
http://www.computerc...462#entry148462
Need Help With If Loop
Started by subzero22, Oct 10 2013 11:23 PM
5 replies to this topic
#1
Posted 10 October 2013 - 11:23 PM
#2
Posted 11 October 2013 - 01:10 AM
Is the ID a string?
#3
Posted 11 October 2013 - 02:41 AM
In MiscPeripherals, any item that has a damage value get encoded in some way, I've wrote a quick little function to decode it.
You would use it like this
So for item id "227:3", your code would look like this...
function mpDecode(nInput) return bit.band(2^15-1, nInput), bit.brshift(nInput, 15) end
You would use it like this
local id, dmg = mpDecode(numberReturnedByMiscPeripheral)
So for item id "227:3", your code would look like this...
local id, dmg = mpEncode(98531) '-- That is the encoded value of 227:3'
if id == 227 and dmg == 3 then
'-- Do stuff'
end
#4
Posted 11 October 2013 - 06:21 AM
In addition to what Anavrins said... There is also a seed in MiscP which can be changed, as such this is a set of helper functions that NeverCast and I have used in the past.
local itemSeed = 0 function setItemSeed( seed ) itemSeed = seed end function getItemFromUUID( uuid ) uuid = bit.bxor(uuid, itemSeed) local meta = math.floor(uuid/32768) local id = uuid % 32768 return id, meta end function getUUIDFromItem( id, meta ) local uuid = (meta or 0) * 32768 + id return bit.bxor(uuid, itemSeed) endThe usage is the same (except different function names of course)
local id, dmg = getItemFromUUID(98531) if id == 227 and dmg == 3 then --# do stuff end
#5
Posted 13 October 2013 - 12:00 AM
Well the items I'm listing aren't damage based. Like for example coal is 263 and charcoal is 263:1.
Thanks for the help and I'm assuming the codes will still work for my purposes. If not can you please give example of one that will?
Thanks for the help and I'm assuming the codes will still work for my purposes. If not can you please give example of one that will?
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users












