Vlue

Script Event Page Conditions

Nov 16th, 2012
1,397
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Script Event Page Conditions v1.1
  2. #----------#
  3. #Features: Set conditions for event pages to activate via script calls made with
  4. #           comments. Comment must start with SC: and be the first thing listed
  5. #           on the event page. Note, that's "SC: " with a space and not "SC:".
  6. #
  7. #Usage:   Comment:
  8. #           SC: script_call
  9. #        
  10. #         Example:
  11. #
  12. #           SC: if $game_party.gold >= 100
  13. #
  14. #          ^^ (that page will only activate if players gold is 100 or higher)
  15. #
  16. #           SC: unless $game_party.item_number($data_items[0]) <= 2
  17. #
  18. #          ^^ (that page will only activate if player has less then 3 of item 1)
  19. #
  20. #----------#
  21. #-- Script by: V.M of D.T
  22. #
  23. #- Questions or comments can be:
  24. #    given by email: sumptuaryspade@live.ca
  25. #    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
  26. #   All my other scripts and projects can be found here: http://daimonioustails.weebly.com/
  27. #
  28. #--- Free to use in any project, commercial or non-commercial, with credit given
  29. # - - Though a donation's always a nice way to say thank you~ (I also accept actual thank you's)
  30.  
  31. class Game_Event
  32.   def conditions_met?(page)
  33.     c = page.condition
  34.     if c.switch1_valid
  35.       return false unless $game_switches[c.switch1_id]
  36.     end
  37.     if c.switch2_valid
  38.       return false unless $game_switches[c.switch2_id]
  39.     end
  40.     if c.variable_valid
  41.       return false if $game_variables[c.variable_id] < c.variable_value
  42.     end
  43.     if c.self_switch_valid
  44.       key = [@map_id, @event.id, c.self_switch_ch]
  45.       return false if $game_self_switches[key] != true
  46.     end
  47.     if c.item_valid
  48.       item = $data_items[c.item_id]
  49.       return false unless $game_party.has_item?(item)
  50.     end
  51.     if c.actor_valid
  52.       actor = $game_actors[c.actor_id]
  53.       return false unless $game_party.members.include?(actor)
  54.     end
  55.     if page.list[0].code == 108
  56.       com = page.list[0].parameters[0]
  57.       index = 1
  58.       while page.list[index].code == 408
  59.         com += page.list[index].parameters[0]
  60.         index += 1
  61.       end
  62.       if com.index("SC:") != nil
  63.         string = "return true " + com[3,com.length-3]
  64.         return false unless eval(string)
  65.       elsif com.index("SR:") != nil
  66.         string = com[3,com.length-3]
  67.         eval(string)
  68.       end
  69.     end
  70.     return true
  71.   end
  72. end
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×