Page 1 of 1

Kit Mod

PostPosted: Thu Mar 27, 2014 17:54
by mcfan
I have a small minitest sever and I have a Rank system Ive set up for it using command blocks and pressure plates. But what I'm looking for is a mod where someone can type /kit <rank> and get the items that their rank receives. It would also have a cool-down time of 24 hours and you would need to have a priv for each rank kit. Is this possible? I've tried using the giveme command to help me make a mod like this but I couldn't get it to work.

PostPosted: Thu Mar 27, 2014 18:47
by 4aiman
upload your code somewhere and then it'll be easier to help you to find your errors and to get your mod working.

Anyway, I suggest making a global table:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
ranks = {['user']={}, ['moderator'] = {}}

there you could store player names
then you may have another table with tables of kits:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
kits = (['user']={itemstring1, itemstring2, etc}, ['moderator']={itemstring1, itemstring2, etc})


Then register your command and do smth like this:
(note, that any chat commandhave "name" var that stores invoker's name)
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
for i,group in ipairs(ranks) do
     if group[name] then
          local player = minetest.get_player_by_name(name)
          local inv = player:get_inv()
          for j,item in ipairs(kits[group]) do
               inv:add_item(ItemString(item))
          end
     break
     end
end


Code above is just an example, I'm sure I have syntax errors there.

PostPosted: Thu Mar 27, 2014 19:00
by mcfan
I had some code (I tried 5 times) but I finally deleted it all and worked on other mods that is have. I don't understand exactly what you mean about the global table though.

PostPosted: Thu Mar 27, 2014 21:09
by domtron vox
A global table is where you set a global variable to {} which allows you to store key/value pairs.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local kits = {} --this is NOT a global table
kits = {} --this IS a global table


Are you looking for a mod were you make calls to it from another mod to add ranks and kits or do you want it to have a file for each rank where you can list all items that belong in a kit?

i.e. do you want
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
--mymod/init.lua

kitMod.addRank("user")
kitMod.addRank("moderator")

kitMod.addKit("user", "item1", "item2", "ect")


Or in kitMod/users.kit

item1
item2
ect

PostPosted: Thu Mar 27, 2014 23:54
by mcfan
I want to be able to do - say that my rank is emerald- /kit emerald, and get in my inventory for example, 8 emeralds, 8 diamonds, ect. But if my rank is diamond - I'd be able to do /kit diamond and get my stuff which would be different.

PostPosted: Fri Mar 28, 2014 01:03
by LuxAtheris
Ohh I know what his saying.
Its from that MC game where you type a kind of kit which then you get some items.
I played one of those games which had that.

PostPosted: Fri Mar 28, 2014 12:30
by mcfan
Yes! Is that something you can do? I'm not good at programming commands.

PostPosted: Fri Mar 28, 2014 13:39
by LuxAtheris
mcfan wrote:Yes! Is that something you can do? I'm not good at programming commands.

Sorry to break it to you pal but im still learning to code. :/

PostPosted: Fri Mar 28, 2014 14:03
by mcfan
Oh that is too bad. lol. Anyone else here want to take a stab at it?

PostPosted: Fri Mar 28, 2014 22:31
by domtron vox

PostPosted: Fri Mar 28, 2014 23:41
by mcfan
Thanks domtron vox.

PostPosted: Sat Mar 29, 2014 01:12
by mcfan
Didn't work:(

PostPosted: Sat Mar 29, 2014 17:22
by mcfan
I'm using 0.4.7, Is that a problem?

PostPosted: Sun Mar 30, 2014 07:47
by minermoder27
If you can, update to 0.4.9 regardless of this: 0.4.7 is very old

PostPosted: Sun Mar 30, 2014 08:32
by Krock
mcfan wrote:I'm using 0.4.7, Is that a problem?

It's always good to upgrade your version to support the newest functions/features.

PostPosted: Sun Mar 30, 2014 11:15
by mcfan
The reason why I don't have 0.4.9 is because I installed it and there were a lot of bugs. So I tried to reinstall 0.4.8 but it was gone so I had to settle with 0.4.7.