| Time |
Nick |
Message |
| 00:06 |
ExcaliburZero |
I tried the code, but the fireball, when placed, doesn't move. Here is the current code: http://codepad.org/wzZb6Hrt |
| 00:10 |
ExcaliburZero |
From what I can guess, from seeing the results, the entity of the fireball is placed, but it doesn't move. |
| 00:13 |
PilzAdam |
"minetest.env:add_entity(pointed_thing.above, "neoblocks:fireball")" returns on object ref |
| 00:14 |
PilzAdam |
you have to call the setvelocity() function of that objec ref |
| 00:15 |
ExcaliburZero |
Where and how do I do that? |
| 00:22 |
ExcaliburZero |
I think I may have figured it out. I'll try it out now. |
| 00:26 |
PilzAdam |
something like: local obj = minetest.env:add_entity(pointed_thing.above, "neoblocks:fireball") |
| 00:27 |
ExcaliburZero |
When I placed the fireball item it gave me an error. The code is here: http://codepad.org/X1BRZjkx |
| 00:27 |
PilzAdam |
and then obj:setvelocity({x=1,y=0,z=1}) |
| 00:27 |
ExcaliburZero |
"ServerError: LuaError: error: ...st-0.4.6\bin\..\mods\minetest\neoblocks\fireball.lua:54: attempt to index global 'p' (a nil value)" |
| 00:27 |
PilzAdam |
yea, p and s are defined there |
| 00:28 |
PilzAdam |
make something like: local dir = placer:get_look_dir(); local vec = {x=dir.x*3,...} |
| 00:28 |
PilzAdam |
... means do it for y and z too |
| 00:28 |
PilzAdam |
<-- too lazy to type it out ;-) |
| 00:29 |
ExcaliburZero |
Ok, I'll try that. |
| 00:32 |
ExcaliburZero |
It now gave me "ServerError: LuaError: error: ...st-0.4.6\bin\..\mods\minetest\neoblocks\fireball.lua:56: attempt to index global 'obj' (a nil value)" |
| 00:32 |
ExcaliburZero |
Code: http://codepad.org/Zn87U3op |
| 00:33 |
PilzAdam |
put an "local obj =" in front of the add_entity() call |
| 00:34 |
ExcaliburZero |
So, "local obj = "neoblocks:fireball"," ? |
| 00:34 |
PilzAdam |
nope |
| 00:34 |
PilzAdam |
local obj = minetest.env:add_entity(pointed_thing.above, "neoblocks:fireball") |
| 00:35 |
ExcaliburZero |
Ok, I'll try that. |
| 00:38 |
ExcaliburZero |
It now moves, but it won't explode on impact. |
| 00:39 |
PilzAdam |
thats because you are missing the on_step() function like its used in api.lua |
| 00:39 |
PilzAdam |
that is the function that triggeres the hit_player() and hit_node() functions |
| 00:42 |
ExcaliburZero |
Like this? http://codepad.org/WiegzjjZ |
| 00:44 |
PilzAdam |
seems good |
| 00:45 |
ExcaliburZero |
I'll test it out. |
| 00:48 |
ExcaliburZero |
Ok, I ran into one of the already placed fireballs, and got an error. |
| 00:48 |
PilzAdam |
sorry, I got to sleep |
| 00:48 |
PilzAdam |
its way to late already |
| 00:49 |
ExcaliburZero |
Ok. I'll probably be back here tomorrow. |
| 02:49 |
|
NakedFury joined #minetest-mods |
| 03:46 |
|
Miner_48er joined #minetest-mods |
| 05:37 |
|
kaeza joined #minetest-mods |
| 10:08 |
|
kaeza joined #minetest-mods |
| 10:58 |
|
PilzAdam joined #minetest-mods |
| 11:52 |
|
kaeza joined #minetest-mods |
| 12:27 |
|
PilzAdam joined #minetest-mods |
| 13:25 |
|
rubenwardy joined #minetest-mods |
| 15:39 |
|
NakedFury joined #minetest-mods |
| 17:40 |
|
kaeza joined #minetest-mods |
| 18:01 |
|
rubenwardy joined #minetest-mods |
| 19:54 |
|
ecube_ joined #minetest-mods |
| 20:07 |
|
ShadowNinja joined #minetest-mods |
| 20:51 |
|
ExcaliburZero joined #minetest-mods |
| 20:53 |
ExcaliburZero |
I am currently working on a code for a fireball attack that is modified from Simple Mobs, and the fireball currently moves, but doesn't impact. Can someone help me with it |
| 20:53 |
ExcaliburZero |
The code is here: http://codepad.org/gZBrZV7v |
| 20:58 |
ExcaliburZero |
Scratch that, it is currently not working, it gives me an error. |
| 21:00 |
ExcaliburZero |
ServerError: LuaError: error running function 'on_step': ...st-0.4.6\bin\..\mods\minetest\neoblocks/fireball.lua:24: attempt to call method 'getpos' (a nil value) |
| 21:00 |
thexyz |
what's the error? |
| 21:00 |
ExcaliburZero |
The current code is here: http://codepad.org/ceRvy5d8 |
| 21:01 |
thexyz |
it should be hit_player = function(self, player) |
| 21:02 |
ExcaliburZero |
I'll try that. |
| 21:05 |
ExcaliburZero |
The fireballs now explode, however the fireball item doesn't summon fireballs anymore, since I switched it to "on_use". |
| 21:09 |
ExcaliburZero |
Wait, I may have fixed the problem. |
| 21:14 |
ExcaliburZero |
Nope, now it still won't create fireballs unless aimed at a block. |
| 21:15 |
ExcaliburZero |
This is the current code: http://codepad.org/dMW8vHuL |
| 21:15 |
PilzAdam |
on_use is only called when pointing at a node or object |
| 21:16 |
ExcaliburZero |
How can it be called on a normal click? |
| 21:16 |
PilzAdam |
ehm, wait, on_place is only called when pointing at a node; on_use is always called |
| 21:17 |
PilzAdam |
pointed_thing.above only exists if you point at a node |
| 21:17 |
ExcaliburZero |
What should I replace it with? |
| 21:18 |
PilzAdam |
use something like playerpos + (0,2,0) + dir |
| 21:18 |
PilzAdam |
as spawn pos for the object |
| 21:20 |
ExcaliburZero |
Here is what I currently have: http://codepad.org/a5s8ozTC |
| 21:20 |
ExcaliburZero |
But it won't load. |
| 21:20 |
PilzAdam |
ehm, |
| 21:21 |
PilzAdam |
you have to add the coordinates per axis, like: {x=playerpos.x+0+dir.x,...} |
| 21:21 |
ExcaliburZero |
Ok. |
| 21:22 |
PilzAdam |
(0,2,0) is just a short way to write a vector |
| 21:22 |
PilzAdam |
in lua that is {x=0,y=2,z=0} |
| 21:25 |
ExcaliburZero |
I made the changes to the code, it is now here: http://codepad.org/Elgp09ec |
| 21:26 |
ExcaliburZero |
However it only spawns a fireball when pointed at a node, and gives an error. |
| 21:26 |
PilzAdam |
remove the "if pointed_thing.above then" and define playerpos |
| 21:27 |
ExcaliburZero |
ServerError: LuaError: error : ...st-0.4.6\bin\..\mods\minetest\neoblocks/fireball.lua:69: attempt to index global 'playerpos' (a nil value) |
| 21:28 |
PilzAdam |
something like: local playerpos = placer:getpos() |
| 21:28 |
ExcaliburZero |
Ok, I'll try that. |
| 21:31 |
ExcaliburZero |
It works! |
| 21:31 |
ExcaliburZero |
Thanks! |
| 21:32 |
PilzAdam |
I suggest you to read some basic programming tutorial |
| 21:33 |
ExcaliburZero |
Do you know where some good ones for lua are? |
| 21:34 |
PilzAdam |
it doesnt have to be a Lua tutorial |
| 21:34 |
PilzAdam |
any programming language would work to get some basic idea about programming |
| 21:35 |
ExcaliburZero |
I already know some basic Java, and Javascript, as well as a large amount of wikitext. |
| 21:35 |
ExcaliburZero |
So what language would be good to learn that would transfer to lua well? |
| 21:36 |
PilzAdam |
well, Lua is a scripting language |
| 21:36 |
PilzAdam |
so you could choose another scripting language like Javascript |
| 21:37 |
PilzAdam |
although I learned Lua without knowing other scripting languages well before |
| 23:30 |
|
ecube joined #minetest-mods |