return error fix for coroutines
This commit is contained in:
parent
03b0d2a3dd
commit
5250d6f216
@ -1210,10 +1210,10 @@ end
|
||||
|
||||
local cmd_get_player = function(data,pname) -- return player for further manipulation
|
||||
local player = minetest.get_player_by_name(pname)
|
||||
if not player then return end
|
||||
if not player then error("player does not exist"); return end
|
||||
local spos = data.spawnpos;
|
||||
local ppos = player:getpos();
|
||||
if not is_same_block(ppos,spos) then return end
|
||||
if not is_same_block(ppos,spos) then error("can not get player in another protection zone") return end
|
||||
return player
|
||||
end
|
||||
|
||||
@ -1222,7 +1222,7 @@ local cmd_get_player_inv = function(data,pname)
|
||||
if not player then return end
|
||||
local spos = data.spawnpos;
|
||||
local ppos = player:getpos();
|
||||
if not is_same_block(ppos,spos) then return end
|
||||
if not is_same_block(ppos,spos) then error("can not get player in another protection zone") return end
|
||||
return player:get_inventory();
|
||||
end
|
||||
|
||||
|
4
init.lua
4
init.lua
@ -732,7 +732,7 @@ local function runSandbox( name)
|
||||
local cor = data.cor;
|
||||
if cor then -- coroutine!
|
||||
local err,ret
|
||||
err,ret = coroutine.resume(cor)
|
||||
ret,err = coroutine.resume(cor)
|
||||
if err then return err end
|
||||
return nil
|
||||
end
|
||||
@ -1571,7 +1571,7 @@ minetest.register_on_player_receive_fields(
|
||||
if fields.OK and fields.code then
|
||||
local item = player:get_wielded_item(); --set_wielded_item(item)
|
||||
if string.len(fields.code) > 1000 then
|
||||
minetest.chat_send_player(player,"#ROBOT: text too long") return
|
||||
minetest.chat_send_player(player:get_player_name(),"#ROBOT: text too long") return
|
||||
end
|
||||
item:set_metadata(fields.code);
|
||||
player:set_wielded_item(item);
|
||||
|
@ -1,10 +1,11 @@
|
||||
-- sliding unscramble game by rnd, made in 20 minutes
|
||||
if not init then
|
||||
reward = "default:gold_ingot"
|
||||
size = 3;
|
||||
|
||||
init = true
|
||||
spos = self.spawnpos(); spos.y = spos.y + 1
|
||||
board = {};
|
||||
size = 3;
|
||||
|
||||
local players = find_player(4);
|
||||
if not players then say("#sliding puzzle game: no players") self.remove() end
|
||||
name = players[1];
|
||||
@ -92,7 +93,6 @@ if event and event.y == spos.y then
|
||||
if score >= size*size-2 then
|
||||
minetest.chat_send_player(name, "CONGRATULATIONS! YOU SOLVED PUZZLE. REWARD WAS DROPPED ON TOP OF ROBOT.")
|
||||
pos = self.pos(); pos.y = pos.y+2;
|
||||
reward = "default:gold_ingot"
|
||||
minetest.add_item(pos, _G.ItemStack(reward))
|
||||
self.remove()
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user