1
0
Fork 0
mirror of https://github.com/Oreolek/ink-instead.git synced 2024-04-26 06:09:29 +03:00

trying to make an ink module

This commit is contained in:
Alexander Yakovlev 2018-04-24 15:31:27 +07:00
parent e494c4f855
commit 2ef587bd68
4 changed files with 52 additions and 4 deletions

BIN
lpeg.so Executable file

Binary file not shown.

44
main3.lua Normal file
View file

@ -0,0 +1,44 @@
--$Author:Alexander Yakolev, 2018
--$Version:1.0
local pink = require('pink.pink')
require "noinv"
local story = pink.getStory('test.ink')
--[[
while true do
-- 2) Game content, line by line
while story.canContinue do
pn (story.continue())
end
-- 3) Display story.currentChoices list, allow player to choose one
for i = 1, #story.currentChoices do
print(i .. "> " .. story.currentChoices[i].text)
end
if #story.currentChoices == 0 then break end -- cannot continue and there are no choices
local answer=io.read()
print (story.currentChoices[tonumber(answer)].choiceText)
story.chooseChoiceIndex(answer)
end]]
main = room {
nam = "Ink module",
decor = function()
while story.canContinue do
pn (story.continue())
end
stead.deref('main').obj = {}
for i = 1, #story.currentChoices do
table.insert(main.obj, {
nam = i;
dsc = story.currentChoices[i].text;
choiceText = story.currentChoices[i].choiceText;
index = i;
act = function(this)
story.chooseChoiceIndex(this.index)
walk('main')
return this.choiceText
end
})
end
end
}

View file

@ -1,7 +1,8 @@
-- FIXME clean up
if not arg[1] and not (...) then error("Usage: `require` this file from a script or call `lua pink/pink.lua parse game.ink`") end
local folderOfThisFile = arg[1] and string.sub(..., 1, string.len(arg[1]))==arg[1] and arg[0]:match("(.-)[^/\\]+$") or (...):match("(.-)[^%.]+$")
-- if not arg[1] and not (...) then error("Usage: `require` this file from a script or call `lua pink/pink.lua parse game.ink`") end
-- local folderOfThisFile = arg[1] and string.sub(..., 1, string.len(arg[1]))==arg[1] and arg[0]:match("(.-)[^/\\]+$") or (...):match("(.-)[^%.]+$")
local folderOfThisFile = './pink/'
local getParser = function () return require(folderOfThisFile .. 'parser') end
local runtime = require(folderOfThisFile .. 'runtime')
@ -79,10 +80,10 @@ end
--[[
if arg[1] == 'parse' and arg[2] then
print(dump(parse(arg[2])))
end
]]
return api

3
test.ink Normal file
View file

@ -0,0 +1,3 @@
Hello world!
* [Hello back!]
Nice to hear from you!