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

[制作教程] DoubleX RMVXA Variable Pointers Tutorial

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    前天 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    4471

    主题

    864

    回帖

    2万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

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

    灌水之王

    发表于 前天 15:09 | 显示全部楼层 |阅读模式
    This topic aims to aid users understand how to fully utilize that script. It assumes you've:

    1. Basic pointer, script call and game variable knowledge

    2. Little scripting proficiency

    But you still might gain something if you don't meet the above assumptions.

    Symbols

    Spoiler1. <|-|>

    - Reads from/writes to(binary, left to right)

    2. |>-|>

    - Points to without chaining(binary, left to right)

    3. |>=|>

    - Points to with chaining(binary, left to right)

    4. =|>

    - Effectively means(binary, left to right)

    5. <|=|>

    - Is effectively the same as(binary, left to right)



    Rules

    Spoiler1. a |>=|> a <|=|> a |>-|> a

    2. a |>=|> b <|-|> b <|=|> a |>-|> b =|> a <|-|> b

    3. a |>=|> b |>-|> c =|>  a |>-|> c && b |>-|> c

    4. (c must be different from a)  a |>=|> b |>=|> c =|> a |>=|> c && b |>=|> c

    5. a |>=|> b |>=|> a =|> a |>=|> a && b |>=|> b



    Theorems

    Spoiler1. a |>=|> b |>=|> c |>=|> b =|> a <|-|> b && b <|-|> b && c <|-|> c

    Proof:

    a |>=|> b |>=|> c |>=|> b =|> a |>=|> b && b |>=|> c |>=|> b (Rule 4)

                                         =|> a |>=|> b && b |>=|> b && c |>=|> c (Rule 5)

                                         =|> a |>=|> b && b |>-|> b && c |>-|> c (Rule 1)

                                         =|> a |>-|> b && b |>-|> b && c |>-|> c (Rule 3)

                                         =|> a <|-|> b && b <|-|> b && c <|-|> c (Rule 2)



    Applications

    Spoiler1. Doubly circular linked list

    From Theorem 1:

    - a1 |>=|> a2 |>=|> a3 |>=|> ... |>=|> an |>=|> ai =|> a1 <|-|> ai

    What a1 reads from/writes to can be controlled by controlling what an points to without changing any other pointer record, making implementing doubly circular linked lists feasible.

    To be more effective, efficient and simple, always keep track of the ids of the variable being the 1st, last and currently pointed elements respectively(currently pointed means being actually read from/written to).

    In the below setup, head_var_id, cur_var_id and tail_var_id keeps track of the ids of the variable being the 1st, last and currently pointed elements respectively.

    a) Setting up the list

    - Use this script call:

    cur_var_id = head_var_id(list_length - 1).times { |index|  $game_variables.var_pointers[cur_var_id] = [var_id_list[index], true]  cur_var_id = $game_variables.var_pointers[cur_var_id][0]}tail_var_id = cur_var_id$game_variables.var_pointers[tail_var_id] = [head_var_id, true]



    b ) Accessing the currently pointed element

    - Use this script call:

    Spoiler$game_variables[head_var_id] # Using $game_variables[cur_var_id] also works



    c) Pointing to the next i element

    - Use this script call:

    Spoiler$game_variables.var_pointers[tail_var_id][0] = head_var_idi.times { cur_var_id = $game_variables.var_pointers[cur_var_id][0] }$game_variables.var_pointers[tail_var_id][0] = cur_var_id



    d) Pointing to the previous i element

    - Use this script call:

    Spoiler$game_variables.var_pointers[tail_var_id][0] = head_var_idi.times { cur_var_id = $game_variables.var_pointers.index([cur_var_id, true]) }$game_variables.var_pointers[tail_var_id][0] = cur_var_id



    e) Adding a new element as the next element of the currently pointed element

    - Use this script call:

    Spoilernext_var_id = $game_variables.var_pointers[cur_var_id][0]$game_variables.var_pointers[cur_var_id][0] = new_var_id$game_variables.var_pointers[new_var_id] = [next_var_id, true]



    f) Removing the next element of the currently pointed element

    - Use this script call:

    Spoilerold_var_id = $game_variables.var_pointers[cur_var_id][0]next_var_id = $game_variables.var_pointers[old_var_id][0]$game_variables.var_pointers[cur_var_id][0] = next_var_id$game_variables.var_pointers[old_var_id][0] = 0



    g) Adding an element as the new 1st element of the list

    - Use this script call:

    Spoiler$game_variables.var_pointers[new_var_id] = [head_var_id, true]head_var_id = new_var_id$game_variables.var_pointers[tail_var_id][0] = head_var_id



    h) Adding an element as the new last element of the list

    - Use this script call:

    Spoiler$game_variables.var_pointers[tail_var_id] = [new_var_id, true]tail_var_id = new_var_id$game_variables.var_pointers[tail_var_id][0] = head_var_id



    i) Removing the 1st element of the list

    - Use this script call:

    Spoilernew_head_var_id = $game_variables.var_pointers[head_var_id][0]$game_variables.var_pointers[head_var_id][0] = 0head_var_id = new_head_var_id$game_variables.var_pointers[tail_var_id][0] = head_var_id



    j) Removing the last element of the list

    - Use this script call:

    Spoilernew_tail_var_id = $game_variables.var_pointers.index([tail_var_id, true])$game_variables.var_pointers[tail_var_id][0] = 0tail_var_id = new_tail_var_id$game_variables.var_pointers[tail_var_id][0] = head_var_id



    k) Shifting the 1st and last element of the list to their next i elements:

    - Use this script call:

    Spoiler$game_variables.var_pointers[tail_var_id][0] = head_var_idi.times { tail_var_id = $game_variables.var_pointers[tail_var_id][0] }head_var_id = $game_variables.var_pointers[tail_var_id][0]



    l) Shifting the 1st and last element of the list to their previous i elements:

    - Use this script call:

    Spoiler                 Code:        
    1. $game_variables.var_pointers[tail_var_id][0] = head_var_idi.times { tail_var_id = $game_variables.var_pointers.index([tail_var_id, true]) }head_var_id = $game_variables.var_pointers[tail_var_id][0]
    复制代码








    本贴来自国际rpgmaker官方论坛作者:DoubleX处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/doublex-rmvxa-variable-pointers-tutorial.40730/
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-7-14 17:56 , Processed in 0.087016 second(s), 55 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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