Page 1 of 4

[Mod] Throwing [0.13] [throwing]

PostPosted: Sun Jan 01, 2012 15:26
by Jeija
Hey!

This mod adds simple bows and arrows to minetest.
There is no good texture for them yet... Send in yours if you want to and I'll add them to my mod.
Crafting Recipes:
Image
Image
Image

And some screenshots...
Image
Image

You can use the code to add your own throwable things...
What about TNT/Grenades/whatever?

I think the scriptapi should have a possibility to get the name of an object, this gave me the possibility to make arrows disappear when they hit a mob. Would be nice if someone added that.

There still seems to be a bug: The bow sometimes disappears when shooting, especially when a game has just started, but this doesn't seem to be a mod issue.

Works from minetest 20111228 and better - you may have to compile this from github!
Download
V 0.1 as .tar.gz
V 0.11 as .tar.gz
V 0.12 as .tar.gz
V 0.13 as .tar.gz

Latest git as .zip
Latest git as .tar.gz

Dependencies: none


Cheers,
Jeija

License: WTFPL

PostPosted: Sun Jan 01, 2012 15:48
by sfan5
+2!! I like it

PostPosted: Sun Jan 01, 2012 17:45
by jordan4ibanez
SEE?! i told you it was possible jeija! :D +9001

PostPosted: Sun Jan 01, 2012 18:01
by sdzen
I ever so slightly altered the textures they might look a bit better
https://www.sugarsync.com/pf/D6068353_8269537_298551

PostPosted: Sun Jan 01, 2012 18:23
by Hackeridze
Jeija, you can get strings from RTMMP's version of ROPE mod. RTMMP's ROPE mod depends on RTMMP's FLOWERS mod.

PostPosted: Sun Jan 01, 2012 18:31
by cosarara97
Good! +5
I've just killed a rat with it xD but it disappeared, so I can't eat it...
Idea: You don't shoot until you release the mouse button, and the velocity depends on how much time have you been pressing it (with a maximum)

PostPosted: Sun Jan 01, 2012 18:34
by Hackeridze
Bad realization.

PostPosted: Sun Jan 01, 2012 18:49
by sfan5
Hackeridze wrote:Bad realization.

It's 75% the best possible realization

PostPosted: Sun Jan 01, 2012 20:11
by Hackeridze
sfan5 wrote:
Hackeridze wrote:Bad realization.

It's 75% the best possible realization

Are you idiot?
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 objs = minetest.env:get_objects_inside_radius({x=playerpos.x,y=playerpos.y,z=playerpos.z}, 2)


He look to objects, but if 2 players shooting? Okay, we need a patch:
minetest.env:add_entity() should return objref to added entity. Just simple patch.

PostPosted: Sun Jan 01, 2012 20:16
by sfan5
Hackeridze wrote:
sfan5 wrote:
Hackeridze wrote:Bad realization.

It's 75% the best possible realization

Are you idiot?

No

PostPosted: Sun Jan 01, 2012 20:21
by sapier
minetest.env:add_entity() should return objref to added entity. Just simple patch.


I agree with that, would need it in animals mod too

But i don't agree with those insultings, don't we all want to improove minetest? It would be strange if we all had the same opinion how to do that.

PostPosted: Sun Jan 01, 2012 20:22
by Hackeridze
sfan5 wrote:
Hackeridze wrote:
sfan5 wrote:It's 75% the best possible realization

Are you idiot?

No

So you just mistaken in suggestion about code-quality?

PostPosted: Sun Jan 01, 2012 20:27
by sapier
Code quality is important, but It doesn't justify calling anybody an idiot.

As well as I assume we do have different opinions on what is code quality too ;-)

PostPosted: Sun Jan 01, 2012 20:34
by Hackeridze
Who I call an idiot?

PostPosted: Sun Jan 01, 2012 20:42
by sapier
Are you idiot?


I appologize if I did translate it wrong but in my country asking this question is almost exactly the same as calling.

PostPosted: Sun Jan 01, 2012 20:43
by Tsumiman
So you just mistaken in suggestion about code-quality?

And how does code-quality associated with calling sombody an idiot? And, it's really looks like good realisation, without modification of actual C++ code.

Who I call an idiot?


Are you idiot?


Вот из-за таких мудрецов как ты, русских и считают упоротыми бананами 95% иностранцев.

Sorry for my bad English and Russian, lol.

PostPosted: Sun Jan 01, 2012 20:44
by Jeija
If you don't like the mod, Hackeridze, just ignore it!
It was, as sfan said, the 75% best possible solution without changing the minetest c++ source.
I don't want to have any dependencies for my mods, that's why I didn't use any other mods or create a custom minetest version...
RTMMMP's things can be added when creating a mod-pack.
Okay, we need a patch:
minetest.env:add_entity() should return objref to added entity.

I agree
And as I already said, there should also be a way to get the name of an object when you have the objref.
@sdzen: Gonna implement your textures. Thx!!

PostPosted: Sun Jan 01, 2012 20:56
by Hackeridze
sapier wrote:
Are you idiot?


I appologize if I did translate it wrong but in my country asking this question is almost exactly the same as calling.

People in your country are wrong.

sapier wrote:If you don't like the mod, Hackeridze, just ignore it!

Im just find bad code and say it for you, so now you know how to fix your mistakes.

sapier wrote:It was, as sfan said, the 75% best possible solution without changing the minetest c++ source.

He said:
sfan5 wrote:It's 75% the best possible realization


sapier wrote:RTMMMP's things can be added when creating a mod-pack.

It will added then minetest.env:add_entity() will return objref of added entity.

Tsumiman, тебя никто не спрашивал. Я же не говорю, кем считаю их?

Tsumiman wrote:And how does code-quality associated with calling sombody an idiot?

Because we can forgive idiot's mistakes.

PostPosted: Sun Jan 01, 2012 21:03
by sapier
Because we can forgive idiot's mistakes.


<ironic> Yes, I think we can do that</ironic>

PostPosted: Sun Jan 01, 2012 21:04
by Hackeridze
sapier wrote:
Because we can forgive idiot's mistakes.


<ironic> Yes, I think we can do that</ironic>

/facepalm

PostPosted: Sun Jan 01, 2012 21:05
by Tsumiman
It's 75% the best possible realization

"possible realization" means realization without changing C++ code, that's quite obviously. If minetest.env:add_entity() behavior would be changed, then there will be better realization.

Also, I should admit, that asking if somebody is an idiot only shows that you are a moron, who don't know how to lead a discussion. In any language and country.

PostPosted: Sun Jan 01, 2012 21:06
by sapier
But this discussion is a little bit off-topic, without changes to minetest a really good solution is impossible so we should ask celeron to add at least the return value to add_entity

PostPosted: Sun Jan 01, 2012 21:07
by sfan5
sapier wrote:As well as I assume we do have different opinions on what is code quality too ;-)

Right

PostPosted: Sun Jan 01, 2012 21:28
by Jeija
But this discussion is a little bit off-topic

Right, let's do something productive:
I added sdzen's textures and changed the code a little... but no new features.
The Download link is in the first post in this topic above.

PostPosted: Sun Jan 01, 2012 21:51
by Tsumiman
Line 81, obj:getpos().y==self.object:getpos().y is checked two times. Seems quite strange. Maybe is should be z-coordinate check in third line?

PostPosted: Sun Jan 01, 2012 21:55
by Jeija
You're right Tsumiman! Thanks for reporting. Anyway, these lines of code are just to make sure that the arrow doesn't remove itself. This bug shouldn't matter.

PostPosted: Mon Jan 02, 2012 00:57
by Jordach
I am going to say this once, celeron and kahrl are doing the C++ and not you. However, this is not the point. Don't fight over code. This mod works, leave it there and, wait for 0.4 to go release. Then the LUA will be done.

PostPosted: Mon Jan 02, 2012 01:00
by Calinou
I like this mod, however the bow item texture should probably be flipped around (it looks weird in hand).

PostPosted: Mon Jan 02, 2012 02:12
by MrThebuilder3
awesome! +9000

PostPosted: Mon Jan 02, 2012 05:26
by xyz
Hackeridze, успокойся, пожалуйста.
Just something to stop everybody arguing:
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
     // EnvRef:add_entity(pos, entityname)
     // pos = {x=num, y=num, z=num}
     static int l_add_entity(lua_State *L)
     {   
         //infostream<<"EnvRef::l_add_entity()"<<std::endl;
         EnvRef *o = checkobject(L, 1);
         ServerEnvironment *env = o->m_env;
         if(env == NULL) return 0;
         // pos
         v3f pos = readFloatPos(L, 2);
         // content
         const char *name = luaL_checkstring(L, 3);
         // Do it
         ServerActiveObject *obj = new LuaEntitySAO(env, pos, name, "");
         env->addActiveObject(obj);
         // Return created entity
         objectref_get_or_create(L, obj);
         return 1;
     }

Replace your l_add_entity in scriptapi.cpp with this and it will return objectref (not entity, but its .object property). I already use it in my seasons mod (latest version that is not published now) and catapults mod. Of course, this should be somehow improved to return entity rather that object.