Page 1 of 1

Bigger swords

PostPosted: Tue Jan 10, 2017 19:10
by Kosmos
Hi,
I looked a lot MineCraft videos and i tought why MT have no big swords like Minecraft.
I have a picture for example.

Minecraft Lucky sword:
http://imgur.com/hIRDKCr

-Kosmos

Re: Bigger swords

PostPosted: Tue Jan 10, 2017 22:32
by octacian
IDK, I guess people just haven't make any big swords. It's not that it's not possible in MT, all you have to do is change the wield_scale property of the itemdef. For example:

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
minetest.register_craftitem("swords:big", {
  description = "Big Sword",
  inventory_image = "big_sword_texture.png",
  wield_scale = { x = 2, y = 2, z = 2, },
})


The above should make a sword twice the size as normal swords. I haven't actually tried it, but that's my understanding.

Re: Bigger swords

PostPosted: Thu Jan 12, 2017 04:52
by GreenDimond
Now how to get this to work with weildview/3Darmor? :D

Re: Bigger swords

PostPosted: Thu Jan 12, 2017 20:23
by Kosmos
octacian wrote:IDK, I guess people just haven't make any big swords. It's not that it's not possible in MT, all you have to do is change the wield_scale property of the itemdef. For example:

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
minetest.register_craftitem("swords:big", {
  description = "Big Sword",
  inventory_image = "big_sword_texture.png",
  wield_scale = { x = 2, y = 2, z = 2, },
})


The above should make a sword twice the size as normal swords. I haven't actually tried it, but that's my understanding.

Great. I had test it. But i don't know how i can use it for my mod.-There sometimes to much errors or i haven't the damage what i havw wrote. (I'm a bad programmer). Do you know what's wrong?

-Kosmos

Re: Bigger swords

PostPosted: Fri Jan 13, 2017 00:39
by octacian
Kosmos wrote:The above should make a sword twice the size as normal swords. I haven't actually tried it, but that's my understanding.

Great. I had test it. But i don't know how i can use it for my mod.-There sometimes to much errors or i haven't the damage what i havw wrote. (I'm a bad programmer). Do you know what's wrong?

-Kosmos[/quote]

Sorry, forgot. It's minetest.register_item for tools, not minetest.register_craftitem. I personally think the functions should be put into one, but whatever. Hope it works!

Re: Bigger swords

PostPosted: Fri Jan 13, 2017 18:26
by stu
GreenDimond wrote:Now how to get this to work with weildview/3Darmor? :D

Not possible with wieldview sadly, however, it is with wield3d ;-)

Image

Here is the full code, it has the same properties as the default diamond sword. The last part is not absolutely necessary however it does position the sword better in the hand. Note that the mod 'swords' would need to soft-depend on wield3d for that to work.

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
minetest.register_tool("swords:big_sword", {
   description = "Big Sword",
   inventory_image = "swords_big_sword.png",
   wield_scale = {x=3, y=3, z=2},
   tool_capabilities = {
      full_punch_interval = 0.7,
      max_drop_level=1,
      groupcaps={
         snappy={times={[1]=1.90, [2]=0.90, [3]=0.30}, uses=40, maxlevel=3},
      },
      damage_groups = {fleshy=8},
   },
   sound = {breaks = "default_tool_breaks"},
})

if minetest.global_exists("wield3d") then
   wield3d.location["swords:big_sword"] = {
      "Arm_Right",
      {x=0, y=5.5, z=8},
      {x=-90, y=225, z=90},
      {x=0.25, y=0.25}
   }
end

Re: Bigger swords

PostPosted: Fri Jan 13, 2017 19:55
by Kosmos
How you can get so big swords if you press F7?

Re: Bigger swords

PostPosted: Fri Jan 13, 2017 20:05
by octacian
Wow, wrong yet again. lol

Thanks for correcting me stu and providing the right code :rotfl:

Re: Bigger swords

PostPosted: Fri Jan 13, 2017 20:18
by stu
octacian wrote:Wow, wrong yet again. lol

Thanks for correcting me stu and providing the right code :rotfl:

I was not meaning to 'correct' your code, there was nothing wrong with it other than register_tool which you already pointed out yourself. I was mostly showing how it is possible to see this effect in multiplayer or 3rd person. The code is essentially just a carbon copy of the default diamond sword from MTG ;-)

Re: Bigger swords

PostPosted: Sat Jan 14, 2017 10:54
by Gael de Sailly
Kosmos wrote:Hi,
I looked a lot MineCraft videos and i tought why MT have no big swords like Minecraft.

What is the purpose of such a sword, except imitating Minecraft on principle, and masking the player's view?

Re: Bigger swords

PostPosted: Sat Jan 14, 2017 23:01
by GreenDimond
stu wrote:
GreenDimond wrote:Now how to get this to work with weildview/3Darmor? :D

Not possible with wieldview sadly, however, it is with wield3d ;-)



Here is the full code, it has the same properties as the default diamond sword. The last part is not absolutely necessary however it does position the sword better in the hand. Note that the mod 'swords' would need to soft-depend on wield3d for that to work.

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
minetest.register_tool("swords:big_sword", {
   description = "Big Sword",
   inventory_image = "swords_big_sword.png",
   wield_scale = {x=3, y=3, z=2},
   tool_capabilities = {
      full_punch_interval = 0.7,
      max_drop_level=1,
      groupcaps={
         snappy={times={[1]=1.90, [2]=0.90, [3]=0.30}, uses=40, maxlevel=3},
      },
      damage_groups = {fleshy=8},
   },
   sound = {breaks = "default_tool_breaks"},
})

if minetest.global_exists(wield3d) then
   wield3d.location["swords:big_sword"] = {
      "Arm_Right",
      {x=0, y=5.5, z=8},
      {x=-90, y=225, z=90},
      {x=0.25, y=0.25}
   }
end


Tried this, failed to remember to put the last part, and it worked with wrong placement. Added the rest of the code and now it is telling me
2017-01-14 14:58:58: ERROR[Main]: ModError: Failed to load and run script from /home/alex/.minetest/mods/test/init.lua:
2017-01-14 14:58:58: ERROR[Main]: /usr/share/minetest/builtin/common/strict.lua:9: core.global_exists: table: 0x404e1c40 is not a string
2017-01-14 14:58:58: ERROR[Main]: stack traceback:
2017-01-14 14:58:58: ERROR[Main]: [C]: in function 'error'
2017-01-14 14:58:58: ERROR[Main]: /usr/share/minetest/builtin/common/strict.lua:9: in function 'global_exists'
2017-01-14 14:58:58: ERROR[Main]: /home/alex/.minetest/mods/test/init.lua:46: in main chunk
2017-01-14 14:58:58: ERROR[Main]: Check debug.txt for details.

Yes, I added wield3d as soft dependency. Wat do?

Re: Bigger swords

PostPosted: Sun Jan 15, 2017 18:19
by stu
GreenDimond wrote:Tried this, failed to remember to put the last part, and it worked with wrong placement. Added the rest of the code and now it is telling me
2017-01-14 14:58:58: ERROR[Main]: ModError: Failed to load and run script from /home/alex/.minetest/mods/test/init.lua:
2017-01-14 14:58:58: ERROR[Main]: /usr/share/minetest/builtin/common/strict.lua:9: core.global_exists: table: 0x404e1c40 is not a string
2017-01-14 14:58:58: ERROR[Main]: stack traceback:
2017-01-14 14:58:58: ERROR[Main]: [C]: in function 'error'
2017-01-14 14:58:58: ERROR[Main]: /usr/share/minetest/builtin/common/strict.lua:9: in function 'global_exists'
2017-01-14 14:58:58: ERROR[Main]: /home/alex/.minetest/mods/test/init.lua:46: in main chunk
2017-01-14 14:58:58: ERROR[Main]: Check debug.txt for details.

Yes, I added wield3d as soft dependency. Wat do?

Sorry, my bad, `minetest.global_exists` is expecting a string. I have now corrected the code above.

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
if minetest.global_exists("wield3d") then
   wield3d.location["swords:big_sword"] = {
      "Arm_Right",
      {x=0, y=5.5, z=8},
      {x=-90, y=225, z=90},
      {x=0.25, y=0.25}
   }
end

Pro Tip: The value z=8 determines how far forward the object is translated.

Re: Bigger swords

PostPosted: Mon Jan 16, 2017 22:21
by GreenDimond
stu wrote:
GreenDimond wrote:Tried this, failed to remember to put the last part, and it worked with wrong placement. Added the rest of the code and now it is telling me
2017-01-14 14:58:58: ERROR[Main]: ModError: Failed to load and run script from /home/alex/.minetest/mods/test/init.lua:
2017-01-14 14:58:58: ERROR[Main]: /usr/share/minetest/builtin/common/strict.lua:9: core.global_exists: table: 0x404e1c40 is not a string
2017-01-14 14:58:58: ERROR[Main]: stack traceback:
2017-01-14 14:58:58: ERROR[Main]: [C]: in function 'error'
2017-01-14 14:58:58: ERROR[Main]: /usr/share/minetest/builtin/common/strict.lua:9: in function 'global_exists'
2017-01-14 14:58:58: ERROR[Main]: /home/alex/.minetest/mods/test/init.lua:46: in main chunk
2017-01-14 14:58:58: ERROR[Main]: Check debug.txt for details.

Yes, I added wield3d as soft dependency. Wat do?

Sorry, my bad, `minetest.global_exists` is expecting a string. I have now corrected the code above.

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
if minetest.global_exists("wield3d") then
   wield3d.location["swords:big_sword"] = {
      "Arm_Right",
      {x=0, y=5.5, z=8},
      {x=-90, y=225, z=90},
      {x=0.25, y=0.25}
   }
end

Pro Tip: The value z=8 determines how far forward the object is translated.

Now the game loads but it doesn't affect object position. I am still holding it by the blade in front of the handguard. Changing z= doesnt do a single thing.

Re: Bigger swords

PostPosted: Wed Jan 18, 2017 14:53
by Kosmos
Gael de Sailly wrote:
Kosmos wrote:Hi,
I looked a lot MineCraft videos and i tought why MT have no big swords like Minecraft.

What is the purpose of such a sword, except imitating Minecraft on principle, and masking the player's view?

You look dangerouser in PvP.

-Kosmos

Re: Bigger swords

PostPosted: Wed Jan 18, 2017 18:20
by stu
GreenDimond wrote:Now the game loads but it doesn't affect object position. I am still holding it by the blade in front of the handguard. Changing z= doesnt do a single thing.

Well you must have done something wrong as the code works fine for me as you can see. I have attached a minimal working test mod, I hope this helps.

Re: Bigger swords

PostPosted: Thu Jan 19, 2017 08:31
by Dragonop
I made some big swords some time ago
viewtopic.php?f=11&t=14236

Re: Bigger swords

PostPosted: Thu Jan 19, 2017 15:55
by GreenDimond
stu wrote:
GreenDimond wrote:Now the game loads but it doesn't affect object position. I am still holding it by the blade in front of the handguard. Changing z= doesnt do a single thing.

Well you must have done something wrong as the code works fine for me as you can see. I have attached a minimal working test mod, I hope this helps.

I̶n̶ ̶y̶o̶u̶r̶ ̶m̶o̶d̶,̶ ̶t̶h̶e̶ ̶s̶w̶o̶r̶d̶ ̶i̶s̶ ̶f̶l̶o̶a̶t̶i̶n̶g̶ ̶n̶e̶a̶r̶ ̶m̶y̶ ̶f̶e̶e̶t̶.̶ ̶I̶f̶ ̶i̶t̶ ̶w̶e̶r̶e̶ ̶u̶p̶ ̶m̶o̶r̶e̶,̶ ̶i̶t̶ ̶w̶o̶u̶l̶d̶ ̶b̶e̶ ̶p̶e̶r̶f̶e̶c̶t̶.̶
EDIT: See next post.

Re: Bigger swords

PostPosted: Thu Jan 19, 2017 16:07
by GreenDimond
A̶l̶s̶o̶,̶ ̶n̶o̶ ̶m̶a̶t̶t̶e̶r̶ ̶h̶o̶w̶ ̶I̶ ̶c̶h̶a̶n̶g̶e̶ ̶t̶h̶e̶ ̶x̶/̶y̶/̶z̶ ̶=̶ ̶s̶t̶u̶f̶f̶,̶ ̶i̶t̶ ̶s̶t̶a̶y̶s̶ ̶t̶h̶e̶ ̶s̶a̶m̶e̶.̶ ̶I̶ ̶c̶h̶a̶n̶g̶e̶d̶ ̶i̶t̶ ̶t̶o̶ ̶t̶h̶i̶s̶ ̶j̶u̶s̶t̶ ̶t̶o̶ ̶s̶e̶e̶ ̶w̶h̶a̶t̶ ̶c̶h̶a̶n̶g̶e̶d̶ ̶w̶h̶a̶t̶ ̶a̶n̶d̶ ̶i̶t̶ ̶d̶i̶d̶ ̶n̶o̶t̶h̶i̶n̶g̶.̶
{̶x̶=̶0̶,̶ ̶y̶=̶5̶0̶0̶0̶,̶ ̶z̶=̶1̶0̶0̶0̶}̶,̶ ̶-̶-̶ ̶0̶ ̶5̶.̶5̶ ̶8̶
{̶x̶=̶1̶0̶0̶0̶,̶ ̶y̶=̶1̶1̶0̶0̶,̶ ̶z̶=̶1̶1̶2̶0̶}̶,̶ ̶-̶-̶ ̶-̶9̶0̶ ̶2̶2̶5̶ ̶9̶0̶
{̶x̶=̶5̶0̶,̶ ̶y̶=̶5̶0̶}̶ ̶-̶-̶ ̶0̶.̶2̶5̶ ̶0̶.̶2̶5̶
EDIT: Apparently I had a mod enabled that messed with the positioning. I dunno which one though. Will figure out later. It works!