diff --git a/mods/story/api.lua b/mods/story/api.lua index 1460235..c9ad99e 100644 --- a/mods/story/api.lua +++ b/mods/story/api.lua @@ -167,9 +167,20 @@ function story.generator.run(part, player, line_pos) if cmd[1] == "$create" then story.generator.show(player, story.generator.players_storys[player:get_player_name()].pos) end - if cmd[1] == "$place" and cmd[2] then - if places.pos[cmd[2]] then - story.generator.players_storys[player:get_player_name()].pos = places.pos[cmd[2]] + if cmd[1] == "$place" and cmd[2] and cmd[3] then + if cmd[2] == "at" then + if places.pos[cmd[3]] then + story.generator.players_storys[player:get_player_name()].pos = places.pos[cmd[3]] + end + elseif cmd[2] == "near" then + if places.pos[cmd[3]] then + local place = places.pos[cmd[3]] + story.generator.players_storys[player:get_player_name()].pos = {x=place.x+math.random(-5, 5), y=place.y, z=place.z+math.random(-5, 5)} + end + else + if places.pos[cmd[3]] then + story.generator.players_storys[player:get_player_name()].pos = places.pos[cmd[3]] + end end end if cmd[1] == "$quest" and cmd[2] and cmd[3] and cmd[4] and cmd[5] and tonumber(cmd[4]) and tonumber(cmd[5]) then @@ -186,7 +197,29 @@ function story.generator.run(part, player, line_pos) story.generator.players_storys[player:get_player_name()].pos = {x=0,y=10,z=0} end if cmd[1] == "$next" and cmd[2] then - out = {part=cmd[2], wait=false} + if cmd[2] == "rnd" then + if cmd[3] and cmd[4] and cmd[5] then + local rnd = math.random(3) + if rnd == 1 then + out = {part=cmd[3], wait=false} + elseif rnd == 2 then + out = {part=cmd[4], wait=false} + else + out = {part=cmd[5], wait=false} + end + elseif cmd[3] and cmd[4] then + local rnd = math.random(2) + if rnd == 1 then + out = {part=cmd[3], wait=false} + else + out = {part=cmd[4], wait=false} + end + else + out = {part=cmd[3], wait=false} + end + else + out = {part=cmd[2], wait=false} + end end if cmd[1] == "$wait" then return {cmd="$wait", param=i, wait=true} diff --git a/mods/story/parts/base.part b/mods/story/parts/base.part index ee9da62..df61170 100644 --- a/mods/story/parts/base.part +++ b/mods/story/parts/base.part @@ -1,5 +1,13 @@ -$dialog test -$place home +$dialog welcome +$place near village_1 $create $wait -$quest dignode default:grass 10 39 +$dialog welcome_1 +$place at village_1 +$create +$wait +$dialog quest_1 +$place near village_1 +$create +$wait +$quest dignode farming:wheat_5 20 10 diff --git a/mods/story/parts/quest_1.dialog b/mods/story/parts/quest_1.dialog new file mode 100644 index 0000000..e097c9f --- /dev/null +++ b/mods/story/parts/quest_1.dialog @@ -0,0 +1,4 @@ +Farmer : Hi :) +Farmer : Could you help me? +You : Yes why not? What should I do? +Farmer : Get 20 wheat for me, please. diff --git a/mods/story/parts/welcome.dialog b/mods/story/parts/welcome.dialog new file mode 100644 index 0000000..4596625 --- /dev/null +++ b/mods/story/parts/welcome.dialog @@ -0,0 +1,4 @@ +cdqwertz : Hello, welcome to RPGtest, a open source sandbox survival mmorpg! +You : hi :) +cdqwertz : Select your class using /class warrior/farmer/thief + diff --git a/mods/story/parts/welcome_1.dialog b/mods/story/parts/welcome_1.dialog new file mode 100644 index 0000000..f897dd7 --- /dev/null +++ b/mods/story/parts/welcome_1.dialog @@ -0,0 +1,3 @@ +cdqwertz : ok, now you can select a kit using /kit basic/hard +You : ok +cdqwertz : and now, have fun :) diff --git a/mods/village/depends.txt b/mods/village/depends.txt new file mode 100644 index 0000000..e69de29 diff --git a/mods/village/init.lua b/mods/village/init.lua index 02628ee..396dbfd 100644 --- a/mods/village/init.lua +++ b/mods/village/init.lua @@ -1,5 +1,6 @@ village = {} village.houses = {} +village.num = 1 function village.facedir_to_text_1(f) local all = {[0]="0",[3]="90",[2]="180",[1]="270",[4]="360"} @@ -77,5 +78,18 @@ minetest.register_abm({ action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name = "air"}) village.gen(pos) + if not places.pos["village_" .. tostring(village.num)] then + places.pos["village_" .. tostring(village.num)] = {x=pos.x, y=pos.y, z=pos.z} + village.num = village.num +1 + places.save_places() + else + -- TODO : save village num + village.num = village.num +10 + if not places.pos["village_" .. tostring(village.num)] then + places.pos["village_" .. tostring(village.num)] = {x=pos.x, y=pos.y, z=pos.z} + village.num = village.num +1 + places.save_places() + end + end end, })