Advertisement
Kaev

EIFE Example

May 31st, 2024 (edited)
762
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.58 KB | None | 0 0
  1. local story = {
  2.     variables = {
  3.         clickCount = {
  4.             startValue = 0,
  5.             temporary = true -- resets on Gossip Hello
  6.         },
  7.         clickCountWithoutReset = {
  8.             startValue = 0 -- Will stay as long as the story is loaded
  9.         },
  10.         randomChoice = {
  11.             startValue = 0,
  12.             temporary = true
  13.         },
  14.         setFromScript = {
  15.             startValue = 0 -- Temporary would not make sense here
  16.         }
  17.     },
  18.     [1] = {
  19.         text = [[Player name: $N
  20. Player Level: $L
  21. Player Race: $R
  22. Player Class: $C
  23. Player Gender based: $G(Male:Female)
  24. Player Target Name: $T
  25. Player Guild name: $H
  26. Player Guild rank: $I
  27. Player Zone: $Z
  28. Player Area: $A
  29. Creature name: $CN
  30. SetFromScript: $setFromScript]],
  31.         options = {
  32.             {
  33.                 text = [[Option 1]],
  34.                 next = 2
  35.             },
  36.             {
  37.                 text = [[Option 2]],
  38.                 next = 3
  39.             },
  40.             {
  41.                 text = [[This will not progress the story]],
  42.                 next = 4,
  43.                 onSelect = function(story, player, creature)
  44.                     return false; -- Will stop story progress
  45.                 end
  46.             },
  47.             {
  48.                 text = [[Go to Clickcounter]],
  49.                 next = 5
  50.             },
  51.             {
  52.                 text = [[Give NPC Item]],
  53.                 next = 4,
  54.                 onSelect = function(story, player, creature)
  55.                     if player:HasItem(12345, 1) then -- Always recheck, player can e.g. trade the item while Gossip is open
  56.                         player:RemoveItem(12345, 1);
  57.                     else
  58.                         return false;
  59.                     end
  60.                 end,
  61.                 condition = function(story, player, creature)
  62.                     return player:HasItem(12345, 1);
  63.                 end
  64.             },
  65.             {
  66.                 text = [[Get a random choice]],
  67.                 next = 6,
  68.                 onSelect = function(story, player, creature)
  69.                     story.variables.randomChoice.value = math.random(0, 1);
  70.                 end
  71.             },
  72.             {
  73.                 text = [[Unregister Story]],
  74.                 onSelect = function(story, player, creature)
  75.                     UnregisterStory(creature:GetEntry());
  76.                 end
  77.             },
  78.         },
  79.     },
  80.     [2] = {
  81.         text = [[You picked option 1.]],
  82.         options = {
  83.             {
  84.                 text = [[Jump to option 2 anyway]],
  85.                 next = 3
  86.             }
  87.         }
  88.     },
  89.     [3] = {
  90.         text = [[You picked option 2.]],
  91.         options = {
  92.             {
  93.                 text = [[Go to id 4]],
  94.                 next = 4
  95.             }
  96.         }
  97.     },
  98.     [4] = {
  99.         text = [[You reached the end]],
  100.         options = {
  101.             {
  102.                 text = [[Go back to start]],
  103.                 next = 1
  104.             }
  105.         }
  106.     },
  107.     [5] = {
  108.         text = [[Clickcount: $clickCount
  109. Clickcount without reset: $clickCountWithoutReset]],
  110.         options = {
  111.             {
  112.                 text = [[Increase Clickcount]],
  113.                 next = 5,
  114.                 onSelect = function(story, player, creature)
  115.                     story.variables.clickCount.value = story.variables.clickCount.value + 1;
  116.                     story.variables.clickCountWithoutReset.value = story.variables.clickCountWithoutReset.value + 1;
  117.                 end
  118.             },
  119.             {
  120.                 text = [[Clickcounter reached 5!]],
  121.                 next = 5,
  122.                 onSelect = function(story, player, creature)
  123.                     player:SendUnitSay("Clickcounter reached 5!", 0);
  124.                 end,
  125.                 condition = function(story, player, creature)
  126.                     return story.variables.clickCount.value >= 5;
  127.                 end
  128.             },
  129.             {
  130.                 text = [[Reset All Temporary Story Variables]],
  131.                 next = 5,
  132.                 onSelect = function(story, player, creature)
  133.                     story:ResetTemporary();
  134.                 end,
  135.                 condition = function(story, player, creature)
  136.                     return story.variables.clickCount.value >= 5;
  137.                 end
  138.             },
  139.             {
  140.                 text = [[Reset All Story Variables]],
  141.                 next = 5,
  142.                 onSelect = function(story, player, creature)
  143.                     story:Reset();
  144.                 end,
  145.                 condition = function(story, player, creature)
  146.                     return story.variables.clickCount.value >= 5;
  147.                 end
  148.             },
  149.             {
  150.                 text = [[Go Back]],
  151.                 next = 1
  152.             }
  153.         }
  154.     },
  155.     [6] = {
  156.         text = [[Here's your random choice!]],
  157.        options = {
  158.            {
  159.                text = [[Random Choice 1]],
  160.                next = 1,
  161.                condition  = function(story, player, creature)
  162.                    return story.variables.randomChoice.value == 0;
  163.                end
  164.            },
  165.            {
  166.                text = [[Random Choice 2]],
  167.                next = 1,
  168.                condition  = function(story, player, creature)
  169.                    return story.variables.randomChoice.value == 1;
  170.                end
  171.            }
  172.        }
  173.    }
  174. };
  175.  
  176. RegisterStory(3431, story); -- Don't forget to give that creature the gossip npcflag (1) in the database
  177. SetStoryVariableValue(3431, "setFromScript", 1234); -- We set a variable value from outside
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement