estriole 326 Posted January 10, 2013 (edited) EST - SIMPLE EVENT PAGES CONTROLLER v.1.2a Author: Estriole License: In my sig also credits: Tsukihime for giving me inspiration to create this script. Version History v.1.0 - 2013-01-13 - finish the script v.1.1 - 2013-01-16 - add ability to change event force page by name using or regexp. example string: set_event_force_page(4,"test 1",3) this will change all event with the name test 1 (not case sensitive) example regexp: set_event_force_page(4,/test (.*)/i,3) this will change all event that contain test x in name. so event with these name will change it's force page: test 1, test 2, test 3, battle test 1, battle test abc, etc this feature only useful for people who generate event ingame using either event spawner, copier, etc. since they won't know the id of that event until generated. v.1.2 - 2013-01-18 - add function to use other event pages by setting the force page to RPG::Event:Page object. also added new game interpreter method to make even beginner able to use it. (hopefully)v.1.2a - 2013-01-18 - fix some error with new method if map/event not exist. also renamed the script (change system to controller) to describe this script better. (i decide to stick with simple word ) Introduction Did you have many pages event and have hard time setting it right. this might be your answer. by default the event page system is like this: from the last page it check for that page condition. if condition met than use that page. Imagine if your event pages is 100. and at start it use page 100. then you want by choosing something in page 100 will make the event goes to page 1. if default system you need to make ALL the event page 2 to 100 condition to NOT met. this could cost you a whole lots of Switches... this script make you able to bypass those. now you can just specify the event pages you want to the event to use. and if not set it still use default event pages system. (so existing event won't break) if you want simpler explanation. just imagine this as label and go to label command. but for pages. and i also add that chosen page also get checked for it's condition. so if that chosen page condition not met it will be no page selected (blank event) example i have these event pages: page 1 - condition switch 1 on - set force page to page 2 page 2 - condition none - do something page 3 - condition none - set force page to page 1 the event will be use page 3 (since you havent interact / turn on /off switch and also because that last page condition is met thus that last page used) then by talking to that event you set force page to page 1. but you haven't turn on the switch 1 so it will be blank event. then when you turn on switch 1. that event will use page 1. and by talking to that event will proceed to page 2. and by talking again to event it will do something note: should i make demo about this? i think it's clear enough. you could also make all the pages without condition and then treat it like go to page. just remember the event will pick your last page at the first time How to use 1) Script call: set_this_event_force_page(page_id) ->this will set current event to that page id 2) Script call: set_event_force_page(map_id,event_id,page_id) ->this will set event id in that map id to that page id you could set the page_id to nil for both method to use default event page system Script http://pastebin.com/iqJGYQCu Screenshot Not needed DemoNot needed Compatibility i think this compatible with most script. and it also don't break existing project. since existing project event don't have force page set for them thus using default event page system. Author Note Another helpful script finished... hope someone understand how helpful this is on setting complex event Edited January 18, 2013 by estriole 4 Share this post Link to post Share on other sites
Bluemith 0 Posted January 11, 2013 My Savior!!! /notworthy you are now my favorite person... Share this post Link to post Share on other sites
Erics 12 Posted January 11, 2013 So with this, you don't need switches at all to go to the next event page? If so, that's genius! Share this post Link to post Share on other sites
estriole 326 Posted January 11, 2013 (edited) @eric: yes you could. if you want it simple it's like label and go to label concept but for pages. some example difference between using this script and using default event pages. default: page 1 > require selfswitch A on page 2 > require selfswitch B on page 3 > require selfswitch C on page 4 > require selfswitch D on page 5 > require selfswitch A on and switch 1 on page 6 > require selfswitch B on and switch 1 on page 7 > no requirement by default it will pick page 7. then... you turn on self switch a... it will go to page 1. then you turn on again self switch b. it will use page 2 then you turn on switch 1. it will use page 6 then you turn off self switch b. it will use page 5 then you want it to go to page 3. you need to turn off selfswitch a, turn off switch 1, then turn on self switch C it could be really confusing. especially if the number of switch/self switch usage and pages increase. using this script: you could use default event page above or set the page like this: page 1 > no requirement page 2 > no requirement page 3 > no requirement page 4 > no requirement page 5 > no requirement page 6 > no requirement page 7 > no requirement by default it will pick page 7. then by using script call to set this event force page to 1. it will use page 1. by using script call to set this event force page to 3. it will use page 3. as SIMPLE as that . and the good thing is. you could still give condition to page 1. example: page 1 > switch 1 on then when you force the event to use page 1. if switch 1 off it will be blank event. else it will use page 1. also you could still make event like default event page above. just don't set the force event page for that event. (default it's not set). you could also set the force event page to nil to make it return to default event page system. Some remainder... if you have 10 page without condition at all. it will use the LAST of that event page. basically because it search from last page and that last page condition is already met. forget to tell... feel free to tell me if there's bug or something. i do test it extensively but who knows. i really would like this script to work flawlessly. so i can use it in my project . Edited January 11, 2013 by estriole Share this post Link to post Share on other sites
Wren 179 Posted January 12, 2013 Okay, I need to check into this when I have time at home. Following thread, and liking your original post. If this can do what I think it can do, then I can make super awesome mega NPC's. Share this post Link to post Share on other sites
estriole 326 Posted January 12, 2013 @wren: thanks. perhaps in future i would add more feature like instead changing other event using id as pointer... i could add feature to also able to use event name. but i guess i will try that first. and i'm going out of town for 1 week so i guess it's not gonna be soon. Share this post Link to post Share on other sites
Aheri 2 Posted January 14, 2013 Ex ce llent. Eternal thanks. You honestly rock. Share this post Link to post Share on other sites
estriole 326 Posted January 16, 2013 (edited) updated the script to v1.1 now can change using event name as base. either using string or even regexp: example string: set_event_force_page(4,"test 1",3) this will change all event with the name test 1 (not case sensitive) example regexp: set_event_force_page(4,/test (.*)/i,3) this will change all event that contain test x in name. so event with these name will change it's force page:test 1, test 2, test 3, battle test 1, battle test abc, etc this features only useful for people who generate event ingame using either event spawner, copier, etc. since they won't know the id of that event until generated. btw in case someone not understand. it still can use id method. the string and regexp function is only 'added' function. not replacing the old method. edit: feel free to tell me if there's any bug . Edited January 16, 2013 by estriole 1 Share this post Link to post Share on other sites
Erics 12 Posted January 16, 2013 From what I read, with a script call, you can force an event to switch to another page, in another event? If that sounded confusing, here is an example. You have event 1 and event 2, In event 2, I can force the page to change in event 1. Is this correct? If so, this script is amazing. Share this post Link to post Share on other sites
estriole 326 Posted January 16, 2013 yes you can. not even that. you can even force event to switch to another page in other map. Share this post Link to post Share on other sites
Kayzee 4,033 Posted January 16, 2013 I am a bit confused as to why you are doing "return [@event.pages[@force_page-1]].find{|page| conditions_met?(page)}" rather then "page = @event.pages[@force_page-1]; return page if conditions_met?(page)". It seems kind of silly to get something from an array, putting it in a array with a single thing, and searching the array... Hehe you know one thing you could do is make an event's @force_page a reference to a page instead of an offset to an array... then you can set an event's page to any other event's page too Share this post Link to post Share on other sites
Tsukihime 1,489 Posted January 16, 2013 (edited) I prefer using reference by index over storing object references directly. References can be difficult to maintain and you might run into strange bugs. Of course if you know exactly what you are doing then it would probably be cleaner to just store the page rather than the index of the page. However with indices, you can get the next page by simply adding or subtracting...because it is not a linked list or anything. Edited January 16, 2013 by Tsukihime Share this post Link to post Share on other sites
estriole 326 Posted January 16, 2013 (edited) hahaha... that line is actually copy paste from original method but i added the index . and about reference to a page... i guess tsuki answer some of it. the other reason is making it user as user friendly as possible. not all people know how access the page. and put it in script call. but i think all people still understand to put number in the script call. perhaps that feature could be added for more advanced scripter. but as separate function. but i have to study it more since as far as i know RPG::Event is not saved. and no $data_events like object either . events is created everytime map transfer. that also why i store the force page information in game map too. and make it load everytime load event occur. so i still have to study how to use other map event page to certain event. is it possible or hard to do . if it's possible i also have to make it as user friendly as possible. i have some concept in my head about how to do that. but i have to test it first. edit: if someone have suggestion feel free to share your knowledge . Edited January 16, 2013 by estriole Share this post Link to post Share on other sites
Kayzee 4,033 Posted January 16, 2013 (edited) How are references difficult to maintain? I kind of think in ruby almost everything resolves to object references anyway. As far as I can tell, even saving and loading games dumps the whole object chain, though storing stuff in the $game_map object probably should use indexes so it doesn't store old versions of event pages. I actually would recommend an array of [page_id, event_id, map_id] for that (though honestly I find forcing pages across maps a bit silly ). Edited January 16, 2013 by KilloZapit Share this post Link to post Share on other sites
estriole 326 Posted January 17, 2013 @killo: i actually kinda agree that in ruby almost everything resolves to object references. but since in default script no object references for RPG::Event... then the story become different. that's why i store it the index only and kinda hijack the game_map setup_event method to do my changes too. if use object references then that means i have to create my own object. then store it in custom database. means more extra steps. (maybe you could call me lazy but to store something in custom database that only used only by this script kinda overkill. if i found something that could use that too than it's worth doing... ) about forcing pages across the map... at first i also limit forcing page only in this event. then increase it to same map. but then i begun to think... what if i want certain thing i've done in this map. make changes in other map. example i recruit certain npc as additional shop keeper and in my palace shop keeper the shop stocks variance increases. in default system we can turn on switches for that event to goes to new pages that sell more goods. and if this new system can't do that... then this new system is only simpler but not better than default system . i'm planning this to both make your job simpler and better than using default event pages system (in reducing switch usage, easier event control, etc). and hopefully help newbie eventer to create good working event at least. and for storing in array... i actually already use hash to store it already... that's why forcing pages already work across another map from the first release. $game_map.force_pages = {map_id =>event_id => page_id} i prefer to use hash for this script because i don't want to deal with indexes and also hash by default prevent duplicate. make me easier to control. if you set $game_map.force_pages[map_id][event_id] = 10 then if there's previous record it will be overwritten. if array we need to do some checking first + then delete if there's duplicate and i don't like that extra steps . of course i agree in some other case array also have better usage than hashes. it's actually depend on the situation. Share this post Link to post Share on other sites
Kayzee 4,033 Posted January 17, 2013 (edited) Most scripts I have seen do this sort of thing by loading the map data and nabbing the RPG::Event from it actually... I was actually sort of inspired to fiddle with this and yanfly's call event script, and I came up with this: class Game_Event < Game_Character # this is for Saba Kan's dungeon compatibility mostly def real_id return (defined? self.event_id) ? self.event_id : self.id end alias_method :find_proper_page_set_base, :find_proper_page def find_proper_page return find_proper_page_set_base unless @force_page return conditions_met?(@force_page) ? @force_page : nil end def get_event_page(page_id, event_id, map_id) if map_id == $game_map.map_id map = $game_map else map = load_data(sprintf("Data/Mapd.rvdata2", map_id)) if map.nil? puts "Map:" + map_id.to_s + " isn't a callable map." return nil end end event = map.events[event_id] event = event.event if event.is_a?(Game_Event) if event.nil? puts "Event:" + event_id.to_s + " isn't a callable event." return nil end page = event.pages[page_id-1] if page.nil? puts "Page:" + page_id.to_s + " isn't a callable page." return nil end return page end def set_page(page_id, event_id = real_id, map_id = $game_map.map_id) return if @erased if page_id == 0 || page_id.nil? @force_page = nil refresh return end page = get_event_page(page_id, event_id, map_id) return unless page @force_page = page refresh end def call_page(page_id = nil, event_id = real_id, map_id = @map_id) return if @erased if page_id == 0 || page_id.nil? page = @page else page = get_event_page(page_id, event_id, map_id) end return unless page @call_depth ||= 0 child = Game_Interpreter.new(@call_depth += 1) child.setup(page.list, real_id) child.run @call_depth = 0 end end Edited January 17, 2013 by KilloZapit Share this post Link to post Share on other sites
estriole 326 Posted January 18, 2013 (edited) yeah i think i will load map like that too when assigning force page that is a page instead of number. edit: i have updated the script to v1.2 now you can use page from another event. script call: event_use_page(map_id,event_id,source_map_id,source_event_id,source_page_id) ex: event_use_page(4,7,4,6,1) will change map 4 event 7 to use map 4 event 6 page 1 as it's force page. if that page condition is met then it will use that else become blank event. @killo: i put you on credits . thx for the idea and example code Edited January 18, 2013 by estriole Share this post Link to post Share on other sites
Kayzee 4,033 Posted January 18, 2013 Hehe, you are welcome, although a lot of the map loading stuff is from yanfly's call event script, so maybe you should thank yanfly instead. Share this post Link to post Share on other sites
estriole 326 Posted January 18, 2013 (edited) Hehe, you are welcome, although a lot of the map loading stuff is from yanfly's call event script, so maybe you should thank yanfly instead. the idea to use page itself already make you in my credit list . for the map loading actually i read mine from game_map from default script. before you post the code. but another reference would always be helpful . edit: like always.. forgetting to tell that bug report always welcome . Edited January 18, 2013 by estriole Share this post Link to post Share on other sites
Kayzee 4,033 Posted January 18, 2013 Oh I see! I am glad I could help! :3 Share this post Link to post Share on other sites
estriole 326 Posted January 18, 2013 another small bugfix update. now v.1.2a update: fix some error with new method if map/event not exist. also renamed the script (change system to controller) describe this script better. Share this post Link to post Share on other sites
Kayzee 4,033 Posted January 18, 2013 I wonder if I should finish up and post my version too... I don't want to step on your toes or anything though. The biggest difference I guess between ours is I don't store the event page numbers for later (I just don't particularly find it useful, mostly because I use a lot of disposable cloned events) and I have a function to call event pages without switching. I donno, I don't want to hurt your feelings about it or anything. Share this post Link to post Share on other sites
Tsukihime 1,489 Posted January 18, 2013 You should release it so that others can look at how you approached the same problem. Maybe you found a way to solve something that the other script was stuck on and had to find a workaround. Share this post Link to post Share on other sites
Kayzee 4,033 Posted January 18, 2013 Maybe I will then... thankies tsuki Share this post Link to post Share on other sites
estriole 326 Posted January 19, 2013 (edited) I wonder if I should finish up and post my version too... I don't want to step on your toes or anything though. The biggest difference I guess between ours is I don't store the event page numbers for later (I just don't particularly find it useful, mostly because I use a lot of disposable cloned events) and I have a function to call event pages without switching. I donno, I don't want to hurt your feelings about it or anything. @killo: i always think that it always better to have alternatives. even it's the same script. who knows there's incompatibility in this script and works in yours (compatibility with some other script the developer has one example). it's like when there's many passive skills script. but some of them have incompatibility with my battle system. finally i found neon black passive skill script that works for my battle system. if he didn't post his because of someone already script that... i won't have working passive skill for my battle . so go ahead and post your version. i would love to see that too . for learning purpose. btw i like some of your script too. like word wrapping, actor accent (yes i found it in your blog. it's so creative), and finally your super cache . it make me learn a lot. Edited January 19, 2013 by estriole Share this post Link to post Share on other sites