Home | Tutorial Home | Sourceforge Home | Downloads | Contributions |
Scripting begin The TP-1 script actions or commands are some words reserved to "talk" with the engine. The engine read that word and if it is a TP-1 script action, the engine or the program will do something. The actions follow the structure below: TOP action_name(action_argument1, action_argument2...) The arguments are some info to send to the engine, some actions dont have arguments, them the structure is action_name(). And the engine have some definitions, the definitions dont need argument or "()" symbols. Basic definitions and arguments \ this definition will display a line, and if a line of the script end with \, it can continue in the next line. "string" this is one string argument. "/-string-/" the symbols '/-' and '-/' will be changed to quotes '"' in some actions. Useful if the string argument is a action command. 3 this is one number argument. -5 this is one number below zero argument. :t2 this is a tile definition t2 this is a tile for the tiled map area definition. It can be letters and numbers. attribute=value this is a attribute definition, very used in items, maps, settings and other data files. "~variable~" this is a string with a variable definition, the name between '~' symbols will be changed by the value of the variable with the same name. info(calendar()) the action info have another action as a argument, the calendar action. It works perfectly. TOP battle_bg=filename battle_bg=underground.png Note that this only goes between :def and the first tile definition. It specifies which picture to use for the background when in battle. Subdirectories should work, in the same way as tiles. All filenames are relative to images/backgrounds/. TOP hero_bg=String hero_bg=_raft Note that this only goes between :def and the first tile definition. If given, then instead of using people/hero_n.png (for example) as the hero picture, people/hero_nString.png will be used. In the _raft example, the file people/hero_n_raft.png would be used whenever the hero moves north. TOP level_under=String level_under=town1.txt Note that this only goes between :def and the first tile definition. It specifies the level that is "underneath" the current level. Basically, the game will draw the given level, then draw the current level on top of it, as if you specified the given level as the appropriate pix() commands, then the pix() commands of the current level as addpix() commands. For this to be useful, some of the tiles in the current level need to be transparent. Either not including a pix command, or setting the pix command to be a completely transparent tile (null.png is included for this) will make the level given here show through that tile. Also, note that there is a refresh problem when the player moves onto a square that has transparent areas in the current level. (This occurs when changing direction without moving.) TOP level_*=String level_down=level2.txt Note that this only goes between :def and the first tile definition. It specifies the level that will be to the North, Northwest, West, Southwest... of the current level. You can use level_up, level_down, level_left, level_right, level_upleft, level_upright, level_downleft, level_downright. The bordering levels that are specified using this method will replace the normal off-map areas, (which are a repeat of the closest tile) and will actually appear on the appropriate border of the level, just as if the two levels were one. The intended purpose for this command(s) is to allow the creation of worldmaps; areas that must function as a single map, but are too large to be held comfortably in memory. Note that scripting on the very edge of levels will not run using this method. Make sure not to put anything important on the borders of maps using this. TOP monster=String monster=Cave Bear Note that this only goes between :def and the first tile definition. It specifies the monsters available on the map. Use a monster more than once to weight the listings. (ie, Ant, Ant, and Spider will give Ants twice as often as Spiders.) TOP Action Action Switch to defining the action scripting, which is called when the player moves into or over the tile. Also see onload. TOP addpix("Filename") addpix("potion.png") Places the given picture on top of the current tile. It is recommended to use a tile with transparent areas; otherwise, pix would give the same power with better performance. The same restrictions as the pix command apply. TOP addoverpix("Filename") addoverpix("tree.png") Identical to addpix, only it will be placed over the player. The same restrictions as the pix command apply. TOP addskill("String") addskill("Rage") Use skill("give", "String") instead. Gives the player the specified skill. Returns 1 on success, or 0 on failure. (Either through the player already having the skill, or the skill not existing.) Use Rage, Sneak Away, Dismember, Frenzy, or a skill defined in skills.txt. TOP dropped("item_name") dropped("cow") Place in the map a item in the dropped mode, independent of the player and manually. TOP attack("String") attack("Ant") attack("random", "level4.txt") Attack either a random monster from the map Mapname, or the monster given with String. Returns 1 if the player won, 0 if the player ran, or ends the script and calls endgame.txt if the player loses. TOP damage_monster() damage_monster() damage_monster(stat("attack")) damage_monster(5) Only works in battle. In battle, it attacks the opposing monster, asking the player to select a monster if needed, either with the power of the currently held weapon (as if the player hit the "attack" button in-battle), or at a specified (Command) power. Returns 1 if the attack went through, or 0 if the player cancelled/no enemy exists to attack. It differs from hurt_monster in that it is not reduced by armor. TOP delpix("Filename")) delpix("items/light_healing_potion.png") Removes the given picture from the tile. Returns 1 if the picture existed, and 0 if the picture did not. TOP dialog("String") dialog("This message will pop up.") This displays a message in a dialog box. Useful when giving a lot of information to a user, or when dealing with story information. This command can use ~Variable~ embedded variables. TOP die() die() Die. This kills the player, and calls endgame.txt. Automatically called upon hp reaching 0. TOP end() end() End processing the script. Note that this not only ends processing the script, but when attached to an item or something for sale in a store, prevents the item from being destroyed on use/paid for. TOP equip("String", "String")) equip("has", "dagger") equip("in_slot", "boots") Adjust the equipment of the player. The first string can be "in_slot", "has", "take", or "give". If "in_slot", the second string can be "weapon", "armor", "shield", "helmet", "gloves", or "boots", and will return the name of the the item currently in that slot (or "" if empty). Otherwise, the second string is the name of the item to adjust. "has" returns 1 if the item is being worn, or 0 otherwise. "take" attempts to remove the item in question from the equipment, destroying it. It returns 1 on success, and 0 on failure (item was not being worn). "give" will place the given item in the equipment (destroying the previous item in that slot). Assuming the item is appropriate, it will always return 1. TOP fade(number_of_effect) fade(4) Show a fade effect, and other effects. The fade action have 26 modes: fade(0) = From the center to the left and right fade(1) = From the left and right to the center fade(2) = From the left to the right fade(3) = From the right to the left fade(4) = Down fade(5) = Up fade(6) = Down and up fade(7) = Center down and up fade(8) = To the center fade(9) = Cross fade(10) = Red cross fade(11) = Horizontal fade(12) = Vertical fade(13) = Squares fade(14) = Coloured fade(15) = Coloured 2 fade(16) = Totalblack fade(17) = Totalwhite fade(18) = Totalred fade(19) = Totalgreen fade(20) = Totalblue fade(21) = Totalpurple fade(22) = Blink fade(23) = Coloured Blink fade(24) = Morning fade(25) = Evening TOP find("String", "String") find("light healing potion", "a") find("gold", 30) Asks the player if they want to pick up the item. Returns 1 if the item was picked up, or 0 if it failed. The item either needs to be defined in items.txt, or be gold. If gold, list the amount of gold. Otherwise, list either a or an as the second argument. (It is used in the dialog "You found STRING2 STRING1.") Example:
pix("grass.png") if(var("gold_1"), "=", 0) addpix("items/gold.png") endif walk(1) Action if(var("gold_1"), "=", 0) if(find("gold", 5), "=", 1) set("gold_1", "=", 1) endif endif TOP gamestat("String") gamestat("loc") gamestat("difficulty") gamestat("gamename") Return the value of per-game variables. possible values for String: loc, difficulty, gamename, x, y, newx, newy, mapname. Loc returns either "battle", "inventory", "main", or "shop" depending on the current location of the player. As some script commands do not work except in battle, this can be used to prevent errors. Difficulty returns 0 (easy), 1 (normal), or 2 (hard), and can be used to create difficulty levels outside of battles. (Difficulty levels within battles are created automatically.) Gamename will return the name of the game, as given by variables.txt, and displayed in the titlebar. x, y, and mapname returns the player's current position, as would be used by the move command. newx and newy are different from x and y in that they return the location the player is moving to when moving, instead of the player's current location. TOP generic_dialog("String", "String",...) generic_dialog("Attack?", "no.png", "yes.png") generic_dialog("Action?", "attack.png", "run.png", "skill.png") Creates a dialog with the text of the first argument, and a line of buttons as specified in the rest of the arguments. The text argument understands ~Variable~ embedded variables, and \n newlines. The button arguments must be the filename of a button in module name/images/buttons, with a _sel version of the button also existing. There is a limit of 999 buttons, though the screen width also limits this. This function returns an int, starting at 0. TOP give("String", number or "string") give("maxhp", 5) give("gold", rng(9, 9)) give("name", "Frank") Adjust stats; possible values for String: name, hp, ep, maxhp, maxep, attack, defense, adj_maxhp, adj_maxep, adj_attack, adj_defense, gold, exp, skillpoints. Note that Number can be either positive or negative. The exception is name, which must be a string. However, ~Variable~ variables work with name. The difference between (eg) attack and adj_attack is that attack is permanent, while adj_attack only lasts until the end of battle. TOP hero("Filename minus .png extension") hero("people/hero_w") Give a specific picture to the hero. While any picture can be used (that would work for pix()) it is recommended to use one of the hero_n (s, e, w) pictures. This lasts until the player moves. Filenames are relative to images/tiles/ TOP hurt(Number) hurt(10) hurt(rng(5, 5)) Injure the player for Number or Action points, reduced by armor. TOP hurt_monster(Number) hurt_monster() hurt_monster(stat("attack")) Only works in battle. In battle, it attacks the opposing monster, asking the player to select a monster if needed, either with the power of the currently held weapon (as if the player hit the "attack" button in-battle), or at a specified (Command) power. Returns 1 if the attack went through, or 0 if the player cancelled/no enemy exists to attack. It differs from damage_monster in that it is reduced by armor. TOP if(Action1, "Comparison", Action2) .. else .. endif if(rng(4, 5), ">", 2) attack("random", "level1.txt") else info("A narrow escape") give("exp", 5) endif
if(Action1, "Comparison", Action2) Action3 else Action4 endif Performs Action1 and Action2, (These can be any actions, though some are more useful than others) then compares them. (either use =, <, >, <=, >=, or !=) If the comparison is true, then perform Action3. Otherwise, perform Action4. Attack, Item, Rng, Question, Var, and Take are useful for the 1st/2nd actions. Note that actions 3 and 4 can actually be any number of commands, that beginning whitespace is ignored, the "else" portion does not need to be given, and If commands can be stacked indefinitely. (They should only be limited by Python's maximum stack size) For actions that may kill the player, (eg: Hurt, give("hp", -5) simply follow the action with others, and don't bother with If, as death ends the script anyway. For Attack, success is defined by destroying the monster, failure by running away. Death simply ends the script. (And calls endgame.txt) Note that if(12345) is equivalent to if(12345, "==", 1) TOP info("String") info("String ~variable~") info("Hi there!") set("rand_num", "=", rng(5, 5)) info("Your random number is ~rand_num~") Put the given line into the message scroller. Note that if a line contains ~Variable~, it will be replaced by the value of the variable. TOP inv("String1", "String2") inv("take", "key") inv("give", "sword") Performs various actions with the inventory. String1 can be "has", "take", "give", "use", "type", "quality", "price", "value", "description", "picturename", "hp_bonus", "ep_bonus", "attack_bonus", or "defense_bonus". If "has", inv() returns 1 if the player has the item in the inventory. If "take", inv() attempts to remove (destroy) an inventory item, returning 1 on success, and 0 on failure. If "give", inv() attempts to give the player an item, returning 1 on success, and 0 on failure (full inventory). If "use", the effect of that item is performed. (This does not require the item to be in the inventory, and does not use it up if it is.) The rest of the possibilities returns the respective property for the item. In all cases, String2 gives the item to adjust. TOP inv_spot(Number) inv_spot(5) Returns the name of the item in the given location in the inventory. Number must be between 0 and 27. Returns "" if there is nothing in the given spot. TOP is_equipped("String") is_equipped("Dagger") Obsolete. Use equip("has", "String") instead. Checks to see if the given item is being worn, and, if so, returns 1. Otherwise returns 0. TOP item("String") item("light healing potion") Obsolete: use inv("give", "String") instead. Give the player the item specified. (case-insensitive) Fails (returns 0 instead of 1) if the inventory is full, so use with if to prevent trapping the player in an un-win-able state. TOP lose() lose() Lose the game. Note that this does not call endgame.txt, differing it from die. Use die whenever possible; use lose only in endgame.txt. TOP mapspot("String", Number, Number, "String") mapspot("map.txt", 4, 3, "walk") mapspot("map2.txt", 9, 13, "num_of_addpix") Returns stats for the given tile. First 3 arguments specify a tile using mapname, x, y coords. The last argument gives the variable to return. This can be walk, pix, num_of_dropped, num_of_addpix, num_of_addoverpix, wall_n, wall_s, wall_w, wall_e, within_bounds, y_bound, or x_bound. walk, and wall_* return either 0 or 1, with the same meaning as the respective function. Pix returns a string, as accepted by pix(). The num_of_* variables return the size of the array in question. They are less useful, but included for completeness. within_bounds returns 1 if the xy coords given exists in the given map, or 0 otherwise. Finally, *_bound returns the size of the given map in the given direction. With this variable, the xy coords are useless. TOP mapstat("String", "String") mapstat("addmonster", "Ant") mapstat("delmonster", "Ant") mapstat("hero_bg", "_raft") mapstat("hero_bg", "") mapstat("battle_bg", "underground.png") Adjust stats for the map. Allowed options for the first string are addmonster, delmonster, hero_bg, battle_bg and change_titlebar. The options for the second string are the same as the options for the relevant command mapstat enhances, with the addition that hero_bg works with an empty string. TOP monster_give_stat(Monster_Sel, "Stat_Name", Number) monster_give_stat(monster_select(), "attack", -5) monster_give_stat("all", "defense", 1) Adjusts the stats of one or more monsters. Monster_Sel is either a number, or "all". If a number, the command applies to the given monster in the group. If "all", the effect will be applied to all monsters in the battle. Stat_Name is either name, hp, maxhp, attack, defense, gold, or exp. If "name", Command is a string, not a command, but ~~ embedded variables will work. Otherwise, if Stat_Name is any of the other strings, the given stat will be increased (or decreased) by the given amount. TOP monster_stat(Monster_Sel, "Stat_Name") monster_stat("select", "attack") Returns the stats of a monster. Monster_Sel is a number. (such as monster_select() returns) The "all" option does not work for this command. The command applies to the given monster in the group. Stat_Name is either name, hp, maxhp, attack, or defense. Only usable in battle. TOP monster_select() monster_select() Lets the player select a monster (if only one monster exists, returns the only attackable monster). monster_select returns -1 if the user cancelled, or a number suitable for monster_stat or any other command that uses Monster_Sel. Only usable in battle. TOP move("mapname", x, y, "after_move_command") move("r-town.txt", 4, 6) move("z-home.txt", 4, 6, "fade(5)") Move the player to the given location. mapname is the complete filename of the map, (subdirectories do not work yet) and x and y are the xy coordinates inside the map, after_move_command is a command to do after move the player, it is a script action between '"' quotes. TOP move_hero(x, y) move_hero(1, 0) Will make the player automatically move to north in the map Used to make the player move to somewhere in te current map, walking normally. Not teleport. This is useful to refresh the hero tile when normal refresh() not work. TOP Onload Onload Switch to defining the onload scripting, which is called when the player enters the map. Also see the action command. The tile starts in onload mode, so this command gives no extra power, but can help convenience. TOP pass() pass() Do nothing. Only useful with If. TOP pix("Filename") pix("rock.png") Change the picture to the given file. Only .png is supported, and the file must be in the images/tiles directory. One of these in the onload section of a tile is highly recommended. Note that subdirectories are supported. TOP printvars() printvars() Used for debugging purposes. Prints out all the current variables to the console. Not pretty, but gives the needed information. TOP question("String") question("Leave this area?") This creates a dialog box with a body of String and yes/no buttons. Use with the If command. Yes returns 1, and No returns 0. This command can use ~Variable~ embedded variables. TOP refresh("String") refresh() refresh("onload") Refresh the screen. This is useful if you want to move the player *then* show a dialog box. You can use the arguments: all Refresh all the game screen hero Refresh only the hero onload Read the onload of the map battle Refresh the battle screen TOP rng(Number1, Number2) rng(4, 9) This creates a random number between 1 and Number2. (ie, if Number2 is 3, the possible values are 1, 2, or 3.) The number is then compared with Number1. If Number1 is higher or equal, the random number is returned. Otherwise, 0 is returned. Note that the probability of >0 returning can be expressed as the fraction Number1/Number2. ie, rng(3, 4) will return True 3/4ths of the time. Also note that rng(5, 5) will return a random number between 1 and 5, which can be used in the give and hurt commands. Finally, note that rng(4, 5) will give a random number between 0 and 4. TOP run("mapname", x, y) run("town.txt", 4, 6) This command runs the tile defined. TOP save_var("varname") save_var("times_entered") Save a variable in saved_vars list, to be loaded when the player load the game. If the variable exists, it will save the variable and return its content. TOP set("String", "Operation", Number/String) set("have_entered", "=", "yes") set("num_attacked", "+" 1) Create a variable and save a value in it. Use the var command to compare. Is useful for one-time actions. Use either -, +, *, /, %, ^, or = as the Operation (%=modulus, ^=exponent). The binary operators adjust the current value of the variable using the new number given. For example, set("varname", "/", 5) will take the current value of varname, divide it by 5, and store the result in varname. Strings only work when using the = operator; otherwise, a number must be used. Finally, set("varname", 12345) is equivalent to set("varname", "=", 12345) TOP skill("Switch", "String") skill("give", "Rage") skill("has", "Cringe") Performs various actions with skills. Switch can be "has", "take", "give", or "use". If "has", skill() returns 1 if the player has the skill, or 0 otherwise. If "take", skill() attempts to remove a skill, returning 1 on success, and 0 on failure. (Failure is if the player didn't know the skill in the first place.) If "give", skill() attempts to give the player a skill, returning 1 on success, and 0 on failure (skill already known). If "use", the skill is used. This only works in battle, does not cost the player any ep, and does not require the skill to be known. In all cases, String gives the skill to adjust. Use Rage, Sneak Away, Dismember, Frenzy, or a skill defined in skills.txt. TOP stat("String") stat("maxhp") Returns the value of the stat String. Possible values for String: hp, ep, maxhp, maxep, attack, defense, adj_maxhp, adj_maxep, adj_attack, adj_defense, gold, exp, level, skillpoints, name, direction. Note that attack (for example) give the base attack value, before any equipment or battle bonuses, while adj_attack returns the modified attack value, as used in battle. Direction will return the direction of the player, "n", "s", "e" or "w". TOP store("String") store("Weapons Store") Enter a store. Check shops.txt for the possible values. TOP take("String") take("Key") Obsolete: use inv("take", "String") instead. Remove an item from the inventory. When used with If, can implement keys and the like. Returns 0 on failure, 1 on success. TOP var("String") var("have_entered") Returns the current value of String, or 0 if String is unset. Use with If. TOP walk(Number) walk(1) Set the ability for the player to walk on it. The only values accepted are 1 (can walk) and 0 (cannot walk) TOP wall_Direction(Number) wall_n(1) wall_s(1) wall_e(1) wall_w(1) In the case where you have a tile with a wall (with a walk value of 1) and the tile on the other side of the wall has a walk value of 1, to prevent the hero from walking through the wall, you must specify a wall value. So if the tile has a wall to the north, you would specify this with "wall_n(1)". It is not necessary to specify a lack of walls since all wall values default to 0. (Though resetting a wall to 0 does work.) It is also unnecessary (although harmless) to specify a wall when the tile on the other side of the wall is not walkable. The only values accepted are 1 (wall in this direction) and 0 (no wall in this direction). TOP win() win() Call wingame.txt. TOP between(value, minimum, maximum) set("stat", rng(31, 30) if(between(var("stat"), 1, 10), "=", 1) info("between 1 and 10") endif if(between(var("stat"), 11, 20), "=", 1) info("between 11 and 20") endif if(between(var("stat"), 21, 30), "=", 1) info("between 21 and 30") endif Return the number 1 if the value is higher than minimum, and lower than maximum, or return 0 if not. TOP string("text", "text in the text box", max_lenght_of_the_text_box) set("what_was_writed", string("Please write something", "WRITE HERE", 20)) info("~what_was_writed~") Put a text box to the player write a text. TOP gamedays() gamedays() Return the days passed in the game. TOP days() days() Return the actual day number. TOP steps() steps() Return the number of steps of the player. TOP month() month() Return the curent month. TOP years() years() Return the current year. TOP daystatus() daystatus() Return the day status (day, night, rain or tornado) TOP addday("what_you_want_to_add") addday("day") Add time to the game, but WITHOUT manipulating the timers. Where is writed what_you_want_to_add, you can write the options below: "day" "day24" "week" "month" "year" "five_years" "decade" "century" "millenium" TOP rmday("what_you_want_to_remove") rmday("decade") Remove time to the game, but WITHOUT manipulating the timers. Where is writed what_you_want_to_remove, you can write the options below: "day" "day24" "week" "month" "year" "five_years" "decade" "century" "millenium" TOP calendar() calendar() Return the calendar in string format. You can use info(calendar()) to see the calendar. TOP play_game_bgm("/sound_folder/sound_name.ogg") play_game_bgm("/sounds/day.ogg") Play a background music. TOP play_game_sfx("/sound_folder/sound_name.ogg") play_game_bgm("/sounds/day.ogg") Play a sound. TOP change_std_sound("status", "/sound_folder/sound_name.ogg") dropped("cow") Change the sound to play when the day status change. Where is writed status, you can write: "day" "night" "rain" "tornado" Example: change_std_sound("day", "/sounds/rain.png") TOP volume("channel", value) volume("sfx", 3) volume("bgm", string("Set the volume, 1 to 10", "8", 2)) Change the sounds volume of a given channel, the channels available are "bgm" and "sfx", and the value is a integer from 0 to 10. TOP sound_stop("effect") sound_stop("fade") sound_stop("all") Stop the sound or make other effect. Effects available: "all" Stop all sounds "pause_all" Pause all sounds "unpause_all" Resume all sounds "fade_all" Fade all sounds until stop "bgm" Stop bgm channel "sfx" Stop sound effects channel "pause_bgm" Pause bgm "unpause_bgm" Resume bgm "pause_sfx" Pause sfx "unpause_sfx" Resume sfx "fade_bgm" Fade bgm sound until stop "fade_sfx" Fade sfx sounds until stop TOP character("image_name") character("ME.png") dialog("I want more!") Show a actor image, like a face. If you want to show the character image, I recommend to show a dialog after that, or the picture may disapear *very* quicly. TOP save_permission() save_permission() Toggle the permission to save the game, the first time it is called, will disable the saving function, and in the second time, will enable. TOP actor_attribute("name_of_actor", "attribute") actor_attribute("phantom", "picture") Return any actor attribute. TOP relation("name_of_actor", "op", value) relation("phantom", "+", 3) Change the actor relation attribute. Where is writed op, you can write "=", "-" or "+". TOP status_mapname("d-map_name") status_mapname("d-map_name.txt") *OBSOLETE*Return the name of the map in the current day status, with the correct prefix. To move to maps that have various status (-d, -n, -r, -t) with only one line of code, use this: move(status_mapname("d-map_name"), 1, 2) "d-map_name" is the name of the map, "1" is the x location and "2" is the y location numbers TOP day_to_night(day_value, night_value) day_to_night(60, 40) Modify the duration of the day and the night. TOP gift("name_of_actor", gift_value) gift("Lisa", 5) Give a gift to one actor, if it is the birthday of this actor, the relation change is duplicated.This function will ask for the player to give a item to the actor, if the player have the actor-liked or actor-disliked item. TOP talk("name_of_actor") talk("Heitor") Talk to a actor, ever before the gift() function (if you will use it too). The talk() function will take the actor and the game variables, and will show the actor talking. TOP cassino(game_type, difficulty, reward) cassino(1, 2, 23) Make a mini-game like billiard or poker easily. Game types: 1 for power required game 2 for smart required game 3 for resistance required game TOP Game difficulty is any number value, and reward is a amount of gold. item_change("name_of_item", "attribute", value) dropped("cow") If you want to modify a item attribute, use this. In "attribute", write "time", "time2" or "resistance". The time and time2 is the attribute that control the time until the item grow or give another. Negative numbers will work in value. If the "name_of_item" is vegetal, will modify all vegetals items. If the "name_of_item" is animal, will modify all animals items. If the "name_of_item" is all, will modify all items. TOP item_attribute("name_of_item", "attribute") item_attribute("name_of_item", "attribute") To get the item attribute you use this action TOP water("mode", x, y) water("normal", 3, 3) Will give water to the items that need it.The "mode" must be replaced by "normal", "all", or "reset". "normal will take the x and y position values to take the item in that position and water it, "all" will water all items and "reset" will reset the water of the items. TOP food("mode", x, y) food("all", 0, 0) Will give food to the items that need it.The "mode" must be replaced by "normal", "all", or "reset". "normal will take the x and y position values to take the item in that position and feed it, "all" will feed all items and "reset" will reset the food of the items. TOP script("name_of_file.txt", "name_of_map.txt", x, y) script("radio.txt") script("radio.txt", "z-map.txt", 4, 4) Will execute another script file in the game module. "name_of_the_file.txt" Name of the TP-1 script file to execute "name_of_the_map.txt" Name of the map you want to execute the script, if you dont define it, the current map is used. x, y XY coordinates to execute the script, if you dont define it, the current position is used. TOP mapspot_change("name_of_map.txt", x, y, "attribute", "new_value") mapspot_change("z-map.txt", 3, 10, "walk", 0) Used to change a map tile, with this function and some timers you can make animated tiles. "name_of_map.txt" Name of the map you want to change one tile. x, y Tile coordinates. "attribute" Tile attribute to change, can be pix, walk, wall_n, wall_e, wall_s or wall_w. "new_value" New value of the tile attribute. You can use it to make animated tiles, see the example in the TEMPLATE module. TOP change_actor("name_of_actor", "attribute", "value") change_actor("Jones", "likes", "liquor") The change_actor function will modify a actor attribute, like "talk_normal" or "angry_picture"; Usage : change_actor("name_of_actor", "attribute", "value") The value must be a string The attributes to change : "nickname" "talk_birthday" "happy_picture" "normal_picture" "sad_picture" "angry_picture" "max_relation_picture " "badday_picture" "tornado_picture" "rain_picture" "spr_day_picture" "spr_night_picture" "sum_day_picture" "sum_night_picture" "aut_day_picture" "aut_night_picture" "win_day_picture" "win_night_picture" "likes" "dislikes" "talk_thanks" "talk_nothanks" "talk_enough" "talk_enemy" "talk_normal" "talk_friend" "talk_great_friend" "talk_max_relation" "talk_tornado" "talk_rain" "talk_badday" "talk_spring_day" "talk_spring_night" "talk_summer_day" "talk_summer_night" "talk_autumm_day" "talk_autumm_night" "talk_winter_day" "talk_winter_night" To show an attribute of an actor; info(actor_attribute("name_of_actor", "attribute")) TOP show_image("image_directory_and_name.png", 4, 67, 500, "yes") show_image("underground/rock.png", 4, 67) Show a image from the images directory. 4 is the x coordinate in the screen 67 is the y coordinate in the screen 500 is the duration of the image "yes" is the effect of the image, if it is "yes", the image will be repetedly added, if "no", the image will be added one time. The image will disappear when the map screen is refreshed (player move, duration out) TOP show_image("image_directory_and_name.png", 4, 67, 500, "yes") word("some_string", "back_color_name", "text_color_name", x, y) Show a simple text in the screen. "some_string" is the text to show "back_color_name" is the backgroun color, like "black" "text_color_name" is the text color, like "white" x and y is the coordinates of the text. The size is automatically configured TOP Timers Timers tutorial The TP-1 RPG engine support timed actions, but use with care. The timed actions is a action that is executed after a given time. The module timer.py will memorize and compute the timed action in a list of timers (each timer is one timed action) TOP timer("name_of_timer", time, "trigger", "action") timer("timer1", 120, "active", "info(/-Timed action-/)") Add a timer. -- "name_of_timer" Is the name of the timer you are creating, must be unique. -- time An amount of time (1/10 seconds, 50 = 5 seconds) to execute the action. -- "trigger" A info that will disable, enable, repeat or execute one time only: ---- Triggers : "disabled" : The timer action will not be executed until this trigger is changed to a valid trigger "active" : The timer action will be executed and repeated "active-norepeat" : The timer action will be executed but not repeated ---- Move dependent triggers These triggers are "walk-depend-active" and "walk-depend-active-norepeat". It is used because some actions return errors when called by the timer with others triggers. And for timers that is activated only after the player move. Some actions that works ONLY with move dependent triggers : fade dialog generic_dialog die -- "action" The name of the action to execute, like "info". REMEMBER, dont use " inner the action, use /-, to work properly. Example : NORMAL COMAND : "info("Hello") TIMER COMMAND : info(/-Hello-/) -- Examples :
timer("timer1", 500, "activated", "relation(/-phantom-/, /-+-/, 1)")
TOP
timer_manipulation("timer_name", "timer_attribute", "operation", "value")timer("timer2", 500, "activated-norepeat", "info(/-phantom-/)") timer_manipulation("timer1", "trigger", "=", "disabled") Change a timer attribute. timer_name is the name of the timer you want to modify timer_attribute is the attribute of the timer you want to get or modify operation is what you want to do in the timer_attribute The available operations is "return"(return the attribute value), "="(set the attribute value to the given value) and "+"(add time to the time attribute). value is the value you want to use with the operand Example 1 :
timer_manipulation("timer1", "time", "=", "20")
timer_manipulation("timer1", "trigger", "=", "disabled") set("timer_time", timer_manipulation("timer1", "time", "return", "0")) info("~timer_time~") Each timer must be created one time, or the game will create various timers with the same name. And you can enable\disable it anytime. Example 2 :
if(var("timer_created"), "=", 0)
clock()info("Creating timer") timer("timer", 30, "active", "info", "The timer still active") set("timer_created", 1) endif if(var("timer"), "=", 1) info("The timer will be disabled") timer_manipulation("timer", "trigger", "=", "disabled") set("timer", 0) endif if(var("timer"), "=", 0) info("The timer will be enabled") timer_manipulation("timer", "trigger", "=", "active") set("timer", 1) endif clock() Get the time of the game. To see it, use info(clock()). TOP wait(wait_time_in_1/10_secs) wait(50) Make the player and actions below to wait, 10 = 1 second. NOTE : A lot of timers will slow down your game speed. TOP party_add("name") party_add("Jasmin") party_player("Jasmin") Add a actor to the party. You must add the party member before call it. TOP party_rm("name") party_rm("Jasmin") Remove a party member. TOP party_take("name", attribute) party_take("Heitor", "status") Take the value of a attribute of a party member The party member attribute may be: name hp ep maxhp maxep attack defense exp level skillpoints status battle_picture party_mod("name", "attribute", "op", value) party_mod("Jasmin", "maxhp", "+", 5) Modify one attribute of a party member. TOP Where is writed "op", you must write "+", "-" or "=". TOP The party member attribute may be: hp ep maxhp maxep attack defense exp level skillpoints status battle_picture TOP party_player("name") party_player("Jasmin") party_player("player") Used to change the current player character with the party member. To back to the original character you can use the name "player". TOP language("language_name", 323) language(current_language("take"), 323) Take a translation line from a language file. In the "language_name" you can write the language you want, or a command, like current_language("take") it will return the current language. Where is writed 323, you can write the line in the language file to take. Useful to translate the game. TOP current_language("mode") current_language("take") It take or change the current language of the game. If "take", will return the current language name, if "change", will change the current language, example ; current_language("change", "english") TOP python(command) python("print /-Python working...-/) Execute a command in the python interpreter. Use it to avoid modify the code of the engine, and crash it. And to execute a python code in the current game. Use it with caution. Read about python programming language. TOP pausetime() pausetime() Pause/unpause the time of the game. If its is paused, the game will not add steps and so not change the days. It not stop the main timer. TOP emergency_shutdown() emergency_shutdown() Action to kill all game processes, but the abusive use of this make the game unstable. TOP Advanced To use the action module functions in another code file use: action.run_command(g.xgrid, g.ygrid, g.zgrid, "die()") Where is writed die(), you can put another function with the arguments. To use the tradutor in the code just write g.tradutor.take_lang(g.default_lang, 3), where 3 is the number of the translation line - 1. To fill the screen with a color use g.screen.fill(g.colors["black"]) To fill the screen with a image use g.screen.blit(g.backgrounds["new_game.png"], (0, 0)) To refresh the screen with new elements use pygame.display.flip() When debugging, run the game from the command line. All errors are sent that direction. To create your own module, create a directory in modules, called whatever you want. (Make it fairly descriptive, though.) Include the needed files (copy-paste from another module would be the easy way to do this, though note that the save/ directory is unneeded) and everything should work. Note that subdirectories in the tiles/ directory will work. When drawing buttons, it is possible to change some widths and heights. Make sure the buttons form a rectangle after assembly, and you should be fine. This file may not be entirely accurate. Check action.py in the code directory for the code behind this file. Tell me about any documentation errors found. (The most functions are named script_*, where * is the name of the function in question.) Relationship The actor relation will decrease if the player dont talk to this actor until next day. Relationship: Under 0 ; Enemy Between 0 and 300 ; Normal Between 300 and 600 ; Friend Between 600 and 1000 ; Great friend Above 1000 ; Max relation Creating a fighting actor If the actor is a enemy, you may create a fight with this code : if(actor_attribute("angry_actor", "relation"), "<", 0) set("phantom_fight", generic_dialog("C.. c'mon bastard !", "yes.png", "no.png")) if(var("phantom_fight"), "=", 0) attack("angry_actor") endif endif But remember, you must create a monster of that actor. [Top] Player additional variables The player have 5 additional variables to be used during the game, you can use them to control and save/load more features in the game; var1, var2, var3, var4 and var5. All in integer number format. And the player have the strvar(string format), status(string format) and gametime(integer format) The gametime is refreshed if the player save the game, its value is equal main_clock value. To get the value of one of these variables : stat("var1) To modify the value of one of these variables : give("var1", 5) Working player To use random numbers to make actions that use random, like mining or fishing, use: set("mining", "=", rng(101, 100)) Random number between 1 and 100 if(var("mining"), "<", 20) item("stones") give("ep", -30) endif Or if you want to make a more complex code: to make a action like hunting or fishing, that requires a item, have waiting times and make a monster attack: set("bait", inv("has", "bait for bears")) if(var("bait"), "=", 1) set("attack", "=", rng(101, 100)) if(var("attack"), ">=", 20) fade(18) set("attack", "=", rng(101, 100)) endif if(var("attack"), ">=", 20) fade(18) set("attack", "=", rng(101, 100)) endif if(var("attack"), ">=", 20) fade(18) set("attack", "=", rng(101, 100)) endif if(var("attack"), ">", 20) set("feed", generic_dialog("A bear is near", "yes.png", "no.png")) if(var("feed"), "=", 0) inv("take", "bait for bears") attack("cave bear") endif endif endif To show the number : info("~mining~") TOP Item code The "items" folder is useful in the map editor, because the tiles will be added with the item code : if(var("item_name_map_name.txt_0"), "=", 0) addpix("items/item_name.png") endif Action if(var("item_name_map_name.txt_0"), "=", 0) if(find("item_name", "1"), "=", 1) set("item_name_map_name.txt_0", "=", 1) delpix("items/item_name.png") endif endif But the items can use any tile image of any folder, and various items can use the same image. Then, a more complex code : set("mush", inv("has", "psilocybe cubensis")) if(var("psilocybe_cubensis_z-forest_e3.txt_0"), "=", 0) if(var("mush"), "!=", 1) addpix("vegetables/mushroom.png") endif endif if(var("mush"), "=", 1) delpix("vegetables/mushroom.png") endif Action set("mush", inv("has", "psilocybe cubensis")) if(var("psilocybe_cubensis_z-forest_e3.txt_0"), "=", 0) if(var("mush"), "!=", 1) if(find("psilocybe cubensis", "1"), "=", 1) delpix("vegetables/mushroom.png") set("psilocybe_cubensis_z-forest_e3.txt_0", 1) endif endif endif The lines above create a item that will be added in the map if the map variable is 0 and if the player dont have the item in the inventory. The map variable "psilocybe_cubensis_z-forest_e3.txt_0" will be reseted after the player leave the forest section. This code is from the Tropycal Paradise game. TOP Removing effects of time If you want to remove the time effects (day, night, rain and tornado) easily, follow these steps : 1 Make all the maps with the prefix 'z-' in the name. 2 Make the musics and sounds of the time effects silent, and the status icons transparent. 3 In the directory modules/default/data, open the file 'settings.txt' and write : timeeffects="no" Done. The game now dont have any time effects (day, night, rain and tornado) [Top] Game icon The icon image can be changed in the folder directory modules/default/images/buttons, the name of the icon image is 'icon.png', replace it with the image you want with the same name. TOP TP-1 Contributors Felipe Ruiz Peixoto Amanda Ruiz Peixoto TOP Dragon Hunt developers DeBray Bailey Evil Mr Henry Allison Marles George Tuosto Phil Bordelon Lukas Sabota TOP |