Loading

Paste #pnkv5jdfg

  1. function UIFax:choice(choice,additionalInfo)
  2.  
  3.   .......
  4.  
  5.   -- VIP may choose to visit anyway if he is refused too often
  6.   elseif (self.ui.hospital.vip_declined > 2 and vip_ignores_refusal == 2) and choice == "refuse_vip" then
  7.     self.ui.hospital.num_vips = self.ui.hospital.num_vips + 1
  8.     self.ui.app.world:spawnVIP(additionalInfo.name)    <------------ CRASH
  9.     self.ui.hospital.vip_declined = 0
  10.   elseif choice == "refuse_vip" then
  11.     self.ui.app.world:nextVip() -- don't start an inspection
  12.     self.ui.hospital.vip_declined = self.ui.hospital.vip_declined + 1
  13.   elseif choice == "accept_vip" then
  14.     self.ui.hospital.num_vips = self.ui.hospital.num_vips + 1
  15.     self.ui.app.world:spawnVIP(additionalInfo.name)          <------------- but this is the same call for accepting
  16.  
  17.  
  18. -- Removes the Message, executing a choice if given, else just deletes it
  19. --!param choice_number (number) if given, removes the message by executing this choice.
  20. function UIMessage:removeMessage(choice_number)
  21.   if choice_number then
  22.     if not self.fax then
  23.       self.fax = UIFax(self.ui, self) -- NB: just create, don't add to ui
  24.     end
  25.     self.fax:choice(self.message.choices[choice_number].choice)     <---- Caller of the CRASH
  26.   else
  27.  
  28.  
  29.  
  30. Function creating the invitation
  31. Both choices have the "additionalInfo" field.
  32.  
  33. -- Creates VIP and sends a FAX to query the user.
  34. function Hospital:createVip()
  35.   local vipName =  _S.vip_names[math.random(1,10)]
  36.   local message = {
  37.     {text = _S.fax.vip_visit_query.vip_name:format(vipName)},
  38.     choices = {{text = _S.fax.vip_visit_query.choices.invite, choice = "accept_vip", additionalInfo = {name=vipName}},
  39.                {text = _S.fax.vip_visit_query.choices.refuse, choice = "refuse_vip", additionalInfo = {name=vipName}}}
  40.   }
  41.   -- auto-refuse after 20 days
  42.   self.world.ui.bottom_panel:queueMessage("personality", message, nil, 24*20, 2)
  43. end

Comments