lua:scripting:excamples:speechmenu
Differences
This shows you the differences between two versions of the page.
lua:scripting:excamples:speechmenu [2014/12/24 05:42] – created vodur | lua:scripting:excamples:speechmenu [2014/12/24 05:44] (current) – removed vodur | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | Script example using the " | ||
- | <code lua> | ||
- | -- Menu test helper code [320] | ||
- | mt={} | ||
- | mt.list={} | ||
- | |||
- | function mt.menu() | ||
- | say(" | ||
- | say(" | ||
- | say(" | ||
- | end | ||
- | |||
- | function mt.parse(ch, | ||
- | if trigger==" | ||
- | mt.showlist(ch) | ||
- | return | ||
- | end | ||
- | | ||
- | local s, | ||
- | if s==1 then -- if give is the first word | ||
- | mt.give(ch, | ||
- | return | ||
- | end | ||
- | | ||
- | mt.menu() | ||
- | end | ||
- | |||
- | function mt.showlist(ch) | ||
- | if not mt.list[ch.name] then | ||
- | say(" | ||
- | return | ||
- | end | ||
- | | ||
- | if table.getn(mt.list[ch.name])< | ||
- | say("I don't have anything of yours..." | ||
- | return | ||
- | end | ||
- | | ||
- | for _,v in ipairs(mt.list[ch.name]) do | ||
- | say(v.sdesc) | ||
- | end | ||
- | end | ||
- | |||
- | function mt.give(ch, | ||
- | if not mt.list[ch.name] then | ||
- | say(" | ||
- | return | ||
- | end | ||
- | | ||
- | for i,v in ipairs(mt.list[ch.name]) do | ||
- | if string.find(v.name, | ||
- | mt.gave={ name=ch.name, | ||
- | mdo(string.format(" | ||
- | -- mdo(string.format(" | ||
- | -- table.remove(mt.list[ch.name], | ||
- | return | ||
- | end | ||
- | end | ||
- | | ||
- | -- if we're here, didn't find it | ||
- | say(" | ||
- | end | ||
- | |||
- | function mt.checkgive(trigger) | ||
- | if mt.gave==nil then | ||
- | return | ||
- | end | ||
- | if string.find(trigger, | ||
- | table.remove(mt.list[mt.gave.name], | ||
- | say(" | ||
- | else | ||
- | say(" | ||
- | end | ||
- | | ||
- | mt.gave=nil | ||
- | end | ||
- | |||
- | function mt.receive(obj, | ||
- | if not mt.list[ch.name] then | ||
- | mt.list[ch.name]={} | ||
- | end | ||
- | | ||
- | table.insert(mt.list[ch.name], | ||
- | say(" | ||
- | | ||
- | end | ||
- | |||
- | mt.loaded=true | ||
- | -- End Menu test helper code | ||
- | </ | ||
- | |||
- | <code lua> | ||
- | -- Menu test say * [321] | ||
- | if not mt or not mt.loaded then | ||
- | loadprog(320) | ||
- | end | ||
- | |||
- | mt.parse(ch, | ||
- | -- End Menu test say * | ||
- | </ | ||
- | |||
- | |||
- | <code lua> | ||
- | -- Menu test give * [322] | ||
- | if not mt or not mt.loaded then | ||
- | loadprog(320) | ||
- | end | ||
- | |||
- | mt.receive(obj1, | ||
- | -- End Menu test give * | ||
- | </ | ||
- | |||
- | <code lua> | ||
- | -- Menu test act * [323] | ||
- | if not mt or not mt.loaded then | ||
- | loadprog(320) | ||
- | end | ||
- | |||
- | mt.checkgive(trigger) | ||
- | -- End Menu test act * | ||
- | </ | ||
- | |||
- | ----- | ||
- | < | ||
- | You say ' | ||
- | lua test 20 says 'You haven' | ||
- | You give a pile of coal and rocks to lua test 20. | ||
- | lua test 20 says 'Ok, I'll hold onto a pile of coal and rocks for you Vodur.' | ||
- | You give a pile of coal and rocks to lua test 20. | ||
- | lua test 20 says 'Ok, I'll hold onto a pile of coal and rocks for you Vodur.' | ||
- | El Ranglor gives Surf and Turf to lua test 20. | ||
- | lua test 20 says 'Ok, I'll hold onto Surf and Turf for you Ranglor.' | ||
- | El Ranglor says ' | ||
- | lua test 20 says 'Surf and Turf' | ||
- | You say ' | ||
- | lua test 20 says 'a pile of coal and rocks' | ||
- | lua test 20 says 'a pile of coal and rocks' | ||
- | You give a pile of coal and rocks to El Ranglor. | ||
- | El Ranglor has his hands full. | ||
- | El Ranglor says 'give surf' | ||
- | lua test 20 asks 'Hmmm, I couldn' | ||
- | El Ranglor drops a pile of coal and rocks. | ||
- | El Ranglor says ' | ||
- | lua test 20 exclaims 'Just say the word!' | ||
- | lua test 20 says ' | ||
- | lua test 20 says 'give < | ||
- | El Ranglor says 'give surf' | ||
- | lua test 20 says 'There ya go.' | ||
- | Lua test 20 gives Surf and Turf to El Ranglor. | ||
- | El Ranglor says ' | ||
- | lua test 20 says 'I don't have anything of yours...' | ||
- | </ |
lua/scripting/excamples/speechmenu.1419399774.txt.gz · Last modified: 2014/12/24 05:42 by vodur