Ok, first, i need to say, that we have a lot of different modules, including parser (with standard library like inform 6), but we will write simple variant (classic one) like in tutorial game. To start: ``` —-$Name: The Mystery of Bulb$ —-$Author: Anonymous$ —-$Info: Extra info$ —-$Version: 0.1$ require "fmt" obj { nam = 'broken bulb'; dsc = [[The {bulb} is flickering constantly.]]; act = [[I need change it!]]; } obj { nam = 'table'; dsc = [[Here is the kitchen {table}]]; act = [[There is nothing to explore.]]; }: with { 'drawer' }; function content(s, txt) -- handful function if #s.obj == 0 then return end p(txt) for k, v in ipairs(s.obj) do pr("{",v.nam,"|", v.nam,"}") -- pr does not add ' ' to the output —- we make links like {flashlight|flashlight} if k < #s.obj - 1 then pr ", " elseif k == #s.obj - 1 then pr " and " end end pr "." end obj { nam = 'flashlight'; batteries = false; tak = "You take flashlight."; inv = function(s) if not s.batteries then p [[No batteries.]] else p [[Functional!]]; end end; } obj { nam = 'screwdriver'; tak = "You take screwdriver"; } obj { nam = 'drawer'; dsc = function(s) pr [[with {drawer}]]; if not s:closed() then p"(opened)." content(s, "You can see:") else pr "." end end; act = function(s) if s:closed() then p [[You open drawer.]] s:open() else p [[You close drawer.]] s:close() end end; obj = { 'flashlight', 'screwdriver' }; }:close() room { title = 'In the kitchen'; nam = 'kitchen'; dsc = function(s) p [[You are in the kitchen.]]; if not seen 'broken bulb' and not seen 'new bulb' then p [[There is no light.]] end end; obj = { 'broken bulb', 'table' }; way = { 'pantry' }; } room { nam = 'pantry'; way = { 'kitchen' }; } function init() pl.room = 'kitchen' end ``` If you have any questions, write me...
Ссылка:
http://instead-games.ru/forum/index.php?p=/discussion/comment/12153/#Comment_12153