Special Comments - Printable Version +- Save-Point (https://www.save-point.org) +-- Forum: Games Development (https://www.save-point.org/forum-4.html) +--- Forum: Code Support (https://www.save-point.org/forum-20.html) +--- Thread: Special Comments (/thread-2910.html) |
Special Comments - PK8 - 03-16-2009 Okay, need a bit of help on this. You know those totally special comments which would affect the game if it said something in particular? (Like Wora's sprite mover or Kylock's Light Effects) Here's what one of those special comments codes would look like. Snippet of code taken from Kylock's Light Effects and I changed some things up. Code: for a in $game_map.events.values Say, if I wanted to type something, as a special comment for an event, like this: Quote:Something 55 being any number you could put in and that number somehow affecting a particular event, what changes would I have to make in the code? Special Comments - Charlie Fleed - 03-16-2009 You can use the split method for strings: Code: for a in $game_map.events.values [0][0,9] will test the first 9 chars of the first parameter for a match with "Something", split(' ') returns an array of substrings using the space as separator, finally to_i is needed to convert the string, in your example "5", into a number, then do what you want with that... EDIT: mmm there's something wrong with that... FIXED Special Comments - PK8 - 03-17-2009 Ah thanks. Now I want to use it on an event which contains that comment, how would I go about doing that? :o Special Comments - Charlie Fleed - 03-17-2009 Give me a specific example, you're a little too vague and there are at least a couple of ways to access these values in an event. Special Comments - PK8 - 03-17-2009 My apologies. Let's say for example... I want to move an event using comment Something 5 6. The 5 would move the event's x coordinate and the 6 would move the event's Y coordinate. Just an example. (I dunno what I might actually use it for but this comment stuff is so cool.) Special Comments - Charlie Fleed - 03-18-2009 Okay, you could do something like this Code: class Scene_Map and then call it with $scene.move_events_with_comments from an event. Depending on how many events you want to use it for you could consider putting the values in variables, to be used after. For example, if you know that only one event will have the comment, you could have: Code: class Scene_Map |