Minetest logo

IRC log for #minetest-mods, 2014-01-25

| Channels | #minetest-mods index | Today | | Google Search | Plaintext

All times shown according to UTC.

Time Nick Message
04:10 Miner_48er joined #minetest-mods
07:16 Miner_48er joined #minetest-mods
07:16 Miner_48er joined #minetest-mods
11:02 PilzAdam joined #minetest-mods
16:11 bas080 joined #minetest-mods
16:17 ExcaliburZero joined #minetest-mods
16:18 ExcaliburZero I am currently working on the Fireballs mod, and I am trying to get it so that it can damage mobs from the Simple Mobs mod, and I need some help.
16:18 ExcaliburZero The GitHub repo for the mod is here: https://github.com/rocketslime11/fireballs
16:19 ExcaliburZero I think I understand how to damage a mob, but I don't know how to find mobs who are in the blast radius of the fireball.
16:20 ExcaliburZero In the fireball code there is code to check for players, but I do not know how to do the same for entities. Can someone help me with this?
16:38 Krock joined #minetest-mods
16:39 Krock left #minetest-mods
16:55 ShadowNinja ExcaliburZero: Just remve the is_player check from the minetest.get_objects_in_radius() loop.
16:57 ExcaliburZero Thanks! I'll try that.
16:59 ExcaliburZero I tried that and when I attacka mob it gave me an error.
17:00 ExcaliburZero ERROR: ServerError: LuaError: ...pminetest-0.4.8bin..modsfireballs/thunder sword.lua:59: attempt to index local
17:09 ShadowNinja That's not the full error message. And you can't call methods like get_look_dir on non-player objects. You have to use set_hp(get_hp() - 5).
17:09 ShadowNinja (Or something similar)
17:37 Miner_48er joined #minetest-mods
18:15 ExcaliburZero Can you show me what that would look like in the code? I'm not very fimilliar with coding.
18:16 ExcaliburZero When I put it in I got this error: http://codepad.org/Ud9UcwHR
18:33 ShadowNinja object:set_hp(object:get_hp() - X)  Where X is the amount of damage.
18:34 ShadowNinja You should probably wrap that in math.max to make sure that you don't set a negative HP.
18:34 ShadowNinja object:set_hp(math.max(0, object:get_hp() - X))
18:40 ExcaliburZero I tried that, with decailiring the variable object  with the value of the variable player and I got another error.
18:40 ExcaliburZero http://codepad.org/tHxKTX2Y
18:48 ShadowNinja ExcaliburZero: You can't get the look direction of non-player objects.
18:49 ShadowNinja Add hit_object or the like.  And make it a global inside a namespace so it isn't copied in half a dozen files.
18:56 ExcaliburZero I am trying that, but it gives me an error: http://codepad.org/KLOEQ1Kw
18:57 ExcaliburZero The current code is: http://codepad.org/c7t5L0wg
19:49 bas080 joined #minetest-mods
19:55 ShadowNinja ExcaliburZero: Um, object:set_hp doesn't return anything.
19:55 ShadowNinja And you use player:get_pos() instead of object:get_pos()
19:56 ShadowNinja Remove the punching and return value and fix ^ and it should work.
20:06 ExcaliburZero I tried that and it gave me an error.
20:06 ExcaliburZero http://codepad.org/fusoyVUO
20:06 ExcaliburZero Here is the current code: http://codepad.org/gy6jPoqy
20:12 ShadowNinja ... Look at your code.
20:13 ShadowNinja The object is named player, and you get it's position three times, then generate a vector based on the difference of the objects position, which will alvays be 0.
20:14 ShadowNinja You should use vector.subtract(s, p) BTW.
20:14 ShadowNinja (If that made any sense)
20:16 ShadowNinja You also spawn fire near the player rather than around the actual position of the explosion, and you use a 2x2x2 cube aligned to the +* axis, and a 3x3x3 cube later.
20:25 ExcaliburZero Sorry, I don't fully understand what you are saying.  I adapted the code from PilzAdam's fireball code from the Dungeon Master mob, so I don't have a total understanding of how it works.
20:28 ShadowNinja ExcaliburZero: Read http://www.lua.org/pil/contents.html
20:38 ExcaliburZero I've read a bit of that guide. However I tend to not be able to learn coding well from just reading. I tend to learn it easier by modifying code to see how it works, using it, and then learn exactly what it does.
20:39 ExcaliburZero What exactly is causing the error?
20:41 ExcaliburZero I think I understand (to a degree) what you are saying. Here is the modified code: http://codepad.org/eJUuctnn
20:43 ShadowNinja It failed because the method is called getpos(), and vec is unused.
20:45 ExcaliburZero So Ineed to remove the vec variable and what do I change the "player:getpos()" to?
20:47 ShadowNinja object:getpos().  And change player to object everywhere but in hit_player.
20:51 ExcaliburZero The code is now: http://codepad.org/jgr2MXt5
20:52 ExcaliburZero It doesn't throw any errors, however when the item is used the ball hits the player and explodes, as opposed to being sent in the specified direction.
20:56 ShadowNinja Prevent it from exploding in the first second or so, or spawn it farther away.
20:56 ExcaliburZero Why is it just doing this now? It didn't before.
20:58 ShadowNinja Because it doesn't crash now?  :-D
20:58 ShadowNinja You might have spawned it farther, or if a DM spawned it would have ignored him.
20:58 ExcaliburZero I mean it didn't act like this before I tried modifying the code. It was working before I tried modifiying it today.
20:59 ExcaliburZero From my understanding of it, it would spawn the ball about 1 or so nodes above the player, but I'd guess it is now spawning it on the player for some reason.
21:03 ExcaliburZero I'll try testing increasing the spawning height.
21:04 ExcaliburZero The problem appears to be that it is spawning then immediately exploding.
21:09 ExcaliburZero Ok, I'll put in some print statements to see what exactly it is doing.
21:12 ExcaliburZero It seems that I need to find a way to get it to use something like "is_player()" but for entities.
21:12 ExcaliburZero Do you know how to do that?
21:15 ShadowNinja entitt.object:is_player()
21:15 ShadowNinja entity*
21:17 ExcaliburZero So that will determine if it is an entity?
21:18 ExcaliburZero I tried that and it threw an error.
21:18 ShadowNinja Thet will determine if the enity belongs to a player object.
21:18 ExcaliburZero I meant, something that will determine if it is an entity, just like "is_player()" determines if it is a player.
21:19 ExcaliburZero Is there something like that?
21:33 ShadowNinja No, although you could check if it was a table with a object field.
21:34 ExcaliburZero How would I do that?
21:40 ExcaliburZero Here is what I have right now:http://codepad.org/JulIilMi
22:27 ExcaliburZero_ joined #minetest-mods
22:35 ExcaliburZero joined #minetest-mods

| Channels | #minetest-mods index | Today | | Google Search | Plaintext