lua:scriptenvironments
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
lua:scriptenvironments [2015/10/17 21:01] – [getpc() and getroom()] aethyn | lua:scriptenvironments [2016/02/08 04:45] (current) – [Script Environments] vodur | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Script Environments ====== | ====== Script Environments ====== | ||
- | With the exception of the [[: | + | All prog scripts run in the scripting |
+ | |||
+ | There are a few ways to share values between different script | ||
===== Simple interactions ===== | ===== Simple interactions ===== | ||
Line 95: | Line 97: | ||
end | end | ||
</ | </ | ||
+ | |||
+ | This contrived example is obviously not very useful. In the Cards Against Humanity script we can see how to use getpc() in a more constructive way: | ||
+ | |||
+ | <code lua> | ||
+ | function check_player_num() | ||
+ | for _,v in ipairs(players) do | ||
+ | if not(getpc(v.name)) then | ||
+ | missing_players = {} | ||
+ | table.insert(missing_players, | ||
+ | active_players = #players - # | ||
+ | end | ||
+ | end | ||
+ | if active_players> | ||
+ | start_hand() | ||
+ | else | ||
+ | for _,j in ipairs(players) do | ||
+ | tell(j.name, | ||
+ | tell(j.name, | ||
+ | delay(30, final_check) | ||
+ | end | ||
+ | end | ||
+ | end | ||
+ | </ | ||
+ | |||
+ | In the function the " | ||
+ | |||
+ | getroom() is even more straightforward. Since ROOMs of a certain vnum always exist, using getroom() will always allow you to access that ROOMs properties and methods. For instance, we can turn a " | ||
+ | |||
+ | <code lua> | ||
+ | -- DEATH. Make the exit up from 22000 visible. | ||
+ | getroom(22000).up: | ||
+ | </ | ||
+ | |||
+ | Again, there' | ||
lua/scriptenvironments.1445115666.txt.gz · Last modified: 2015/10/17 21:01 by aethyn