设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 62|回复: 0

[制作教程] console.log() is the best script!

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    慵懒
    3 天前
  • 签到天数: 207 天

    连续签到: 1 天

    [LV.7]常住居民III

    3646

    主题

    862

    回帖

    2万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    21262
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    25800

    灌水之王

    发表于 前天 13:38 | 显示全部楼层 |阅读模式
    Hello! 



                                            I'm pretty new here.  I just wanted to point out to other newbies the most useful newbie thing I've learned:


                                            The console is essential for:[/SIZE]


                                            1) writing code.


                                            2) debugging code


                                            3) play-testing any game.


                                            You can get to the console anytime while playing by pressing f8.
                                            For now, I suggest you look at it in a Battle Test...


                                            (Click on game database, then on troops, then at the top right there's the battle test button that let's you do pretend battles)


                                            Then press f8 and there's the console.


                                            You should see a > cursor where you can type things.


                                            Type:      console.log($


                                            At this point you'll see a little drop down list.


                                            Some of the things on the list will begin $data; like $dataItems   or  $dataMonsters... these are permanent things in your database.


                                            Other things will begin $game -- like $gameParty or $gameTroop or $gameVariables... these are things going on in your current game-- like who's in your party right now, and who are the monsters that you're fighting right now.


                                            But for now, just go with.   console.log($gameTroop)   And press enter.  And don't forget to add the ")"  


                                            You'll see something that looks like nonsense.

                            >Game_Troop {_inBattle: true, _interpreter: Game_Interpreter, _troopId: 1, _eventFlags: Object, _enemies: Array[4]…}                
    Click to expand...


                                            Now click on that line somewhere with your mouse...


                                            And you'll get something like this:

                            Game_Troop {_inBattle: true, _interpreter: Game_Interpreter, _troopId: 1, _eventFlags: Object, _enemies: Array[4]…}


                                                            >_aiKnownElementRates: Object


                                                            >_enemies: Array[4]


                                                            >_eventFlags: Object


                                                            _inBattle: true


                                                            >_interpreter: Game_Interpreter


                                                            >_namesCount: Object


                                                            _troopId: 1


                                                            _turnCount: 0


                                                            __proto__: Game_Troop                
    Click to expand...


                                            Which still looks like nonsense....


                                            But you'll notice a couple things--


                                            _troopId: is the Id of the troop you're fighting.


                                            _TurnCount is what turn it is.


                                            Go ahead on click where it says  >enemies: Array[]


                                            And again you'll get a drop down...

                            0: Game_Enemy


                                                            1: Game_Enemy


                                                            2: Game_Enemy                
    Click to expand...


                                            .


                                            These are the enemies you're fighting right now.


                                            Go ahead and click on one.

                            Game_Enemy


                                                            _actionState: "waiting"


                                                            _actions: Array[1]


                                                            _animations: Array[0]


                                                            _buffTurns: Array[8]


                                                            _buffs: Array[8]


                                                            _classId: 0


                                                            _cooldownTurns: Object_damagePopup: Array[0]


                                                            _effectType: null_enemyId: 8


                                                            _hidden: false


                                                            _hp: 100


                                                            _lastTargetIndex: 0


                                                            _letter: " A"


                                                            _level: 1....                
    Click to expand...


                                            And boom, a whole lot of details!!!  Including all the stats, and states, and everything!


                                            Next, you can also skip the above steps if you type something like this:

                            console.log($gameTroop._enemies[0]._hp)                
    Click to expand...


                                            Basically, each time you want to dig deeper, just add a period, and then type in the next part.


                                            (By the way, if you hit the up arrow, on an empty console box, you'll see the last thing you just typed.  Which is makes the whole typing thing go a lot faster!)


                                            "Okay.. neat... but what do I do with this?"  I hear you say.


                                            Well for one thing you can see some data that aren't visible to the player, like the monster MP.  


                                            (also any $gameVariables, $gameSwitches, other variables, arrays, plugins, invisible states, etc. etc..  ie. anything funky you do behind the scenes.)


                                            So if in your game, you hit a switch but you need to know if that switch is actually hit, this will tell you.


                                            It's also a great first step to writing code, because now you know the names of all the variables!  
                                            Anything you write in your console, you can also write in an event script.  And anything you write in an event script, can also be written in the console.  They both just execute code.


                                            So for example if you type in the console (or an event script):

                            $gameTroop._enemies[0]._hp=5                
    Click to expand...


                                            The first enemy will suddenly have 5 hp.  Which is great if your sitting around punching an enemy and you want to get to the next part.


                                            If you combine this with the most basic java script knowledge-- if(){}... for(){}.. you'll be able to do whatever you want!


                                            So for example, maybe you could add that to a common event script that runs every round, and now you get to know how much life your enemies have every round.[/SIZE]

                            for(var i = 0; i< $gameTroop._enemies.length; i++)  {


                                                            console.log($gameTroop._enemies._hp)


                                                            }                
    Click to expand...


     


                                            Now during a play-test you don't have to wait to the end of the battle to see how you're doing.


                                            In other words-- with a tiny bit of scripting skill-- you can give yourself a sort of God Mode, allowing you to test everything in the game without having to slog through the whole game.


    本贴来自国际rpgmaker官方论坛作者:Internetomancer处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/console-log-is-the-best-script.57848/

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-7-10 02:59 , Processed in 0.065939 second(s), 58 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表