YesNoOk
avatar

Concept/study. Get more out of vars. (Read 703 times)

Started by ink, June 12, 2019, 05:16:19 am
Share this topic:

ink

Concept/study. Get more out of vars.
New #1  June 12, 2019, 05:16:19 am
  • ****
  • inktrebuchet
    • USA
    • s236.photobucket.com/albums/ff271/inktrebuchet/?
Like the title suggests, the goal for this piece of code was to save vars usage. Here I've put together the base for a buffer system, it uses 3 vars to buffer 11 basic button/direction inputs. I can't think of too many uses for this but I'm posting it so it's available to anyone looking to get more out of vars. Be sure to check the "Notes" section and here's a clip of DisplayToClipboard in action. https://i.imgur.com/hRA0vLZ.mp4

Also, since you're here to get more out of vars, you may want to check out http://mugenguild.com/forum/msg.1482141 too.

Thanks to JustNoPoint and Jesuszilla for answering any questions I had about buffer systems.

This is a helper that uses keyctrl.
Code:
;==========================================================================
;[Info]
;author = "Inktrebuchet"
;versiondate = 6/11/2018                 
;goal = do as much as possible with each var
;
;==========================================================================
;                Notes
;==========================================================================
;JustNoPoint had an idea, then I tried to make it.
;
;This is a proof of concept. For an actual buffer system check these out:
; http://mugenguild.com/forum/msg.2331601
; http://mugenguild.com/forum/msg.2366951
;
;Each variable uses up to 5 slots and is described in "Helper Var Usage" section.
;Buffer time can be set in the "Config Section" below.
;To set direction and button buffer times separately, search "Config" using ctrl+f.
;
;Base examples of trigger use:
;
;;Command "a" was pressed. Reference "Helper Var Usage" section for more info.
;trigger1 = ((helper(33336666),var(3) - ((helper(33336666),var(3)/100000000) * 100000000))/1000000)
;
;==========================================================================
;                Helper Var Usage
;==========================================================================
; numhelper(33336666) Variable usage:
; This is a record of the variables that are used
;
;var(0) :
; Buff.time =   (var(0) / 100000000)
; Back =        ((var(0) - ((var(0)/100000000) * 100000000))/1000000)
; Down =        ((var(0) - ((var(0)/1000000) * 1000000))/10000)
; Fwd =         ((var(0) - ((var(0)/10000) * 10000))/100)
; Up =          ((var(0) - ((var(0)/100) * 100))/1)
;;var(2) :
; Buff.time =   (var(2) / 100000000)
; X =           ((var(2) - ((var(2)/100000000) * 100000000))/1000000)
; Y =           ((var(2) - ((var(2)/1000000) * 1000000))/10000)
; Z =           ((var(2) - ((var(2)/10000) * 10000))/100)
; Start =       ((var(2) - ((var(2)/100) * 100))/1)
;;var(3) :
; Buff.time =   (var(3) / 100000000)
; A =           ((var(3) - ((var(3)/100000000) * 100000000))/1000000)
; B =           ((var(3) - ((var(3)/1000000) * 1000000))/10000)
; C =           ((var(3) - ((var(3)/10000) * 10000))/100)
;
;==========================================================================
[statedef 33336666]
ctrl = 0

;==========================================================================
;                Config Section
;==========================================================================
Anim = 9741                                          ;Blank anim

[State Config Time]
Type = varset
trigger1 = !time && !var(0)
var(0) = 20                                          ;Buffer time, this value should be set between 1 and 21

;==========================================================================
[state 33333333, Clipboard]
type = DisplayToClipboard
trigger1 = 1
text = "D.time=%d| %d %d %d %d "
params = (var(0) / 100000000), ((var(0) - ((var(0)/100000000) * 100000000))/1000000), ((var(0) - ((var(0)/1000000) * 1000000))/10000), ((var(0) - ((var(0)/10000) * 10000))/100), ((var(0) - ((var(0)/100) * 100))/1)

[state 33333333, Clipboard]
type = AppendToClipboard
trigger1 = 1
text = "XYZS.time=%d| %d %d %d %d "
params = (var(2) / 100000000), ((var(2) - ((var(2)/100000000) * 100000000))/1000000), ((var(2) - ((var(2)/1000000) * 1000000))/10000), ((var(2) - ((var(2)/10000) * 10000))/100), ((var(2) - ((var(2)/100) * 100))/1)

[state 33333333, Clipboard]
type = AppendToClipboard
trigger1 = 1
text = "ABC.time=%d| %d %d %d\nBy Inktrebuchet"
params = (var(3) / 100000000), ((var(3) - ((var(3)/100000000) * 100000000))/1000000), ((var(3) - ((var(3)/1000000) * 1000000))/10000), ((var(3) - ((var(3)/10000) * 10000))/100)

;==========================================================================
;                Buffer Directions
;==========================================================================
[State Timer Set Part 2]
Type = null
trigger1 = var(0) < 100000000
trigger1 = var(0) := var(0) * 100000000
trigger2 = var(0) = 0
trigger2 = var(0) := 100000000

[State Count Down]
type = null
Trigger1 = var(0) - ((var(0)/100) * 100) = [1, 98]
Trigger1 = var(0) := var(0) - 1

[State Count Down]
type = null
Trigger1 = var(0) - ((var(0)/10000) * 10000) = [99, 9998]
Trigger1 = var(0) := var(0) - 100

[state count them down]
type = null
Trigger1 = var(0) - ((var(0)/1000000) * 1000000) = [9999, 999998]
Trigger1 = var(0) := var(0) - 10000

[State Count Down]
type = null
Trigger1 = var(0) - ((var(0)/100000000) * 100000000) = [999999, 99999998]
Trigger1 = var(0) := var(0) - 1000000

;----------------------------------------------------------
[State Up]
Type = null
Trigger1 = command = "holdup"
Trigger1 = var(0) - ((var(0)/100) * 100) <= (1 * (floor(var(0) / 100000000)))
Trigger1 = Var(0) := var(0) + ((1 * (floor(var(0) / 100000000))) - (var(0) - ((var(0)/100) * 100)))

[State Fwd]
Type = null
trigger1 = enemynear,Pos X - Pos X >= 0 && command = "holdback" || enemynear,Pos X - Pos X < 0 && command = "holdfwd"
;Trigger1 = command = "holdfwd"
Trigger1 = var(0) - ((var(0)/10000) * 10000) <= (100 * (floor(var(0) / 100000000)))
Trigger1 = Var(0) := var(0) + ((100 * (floor(var(0) / 100000000))) - (var(0) - ((floor(var(0)/10000) * 10000) + (var(0) - ((var(0)/100) * 100)))))

[State Down]
Type = null
Trigger1 = command = "holddown"
Trigger1 = var(0) - ((var(0)/1000000) * 1000000) <= (10000 * (floor(var(0) / 100000000)))
Trigger1 = Var(0) := var(0) + ((10000 * (floor(var(0) / 100000000))) - (var(0) - ((floor(var(0)/1000000) * 1000000) + (var(0) - ((var(0)/10000) * 10000)))))

[State Back]
Type = null
trigger1 = enemynear,Pos X - Pos X >= 0 && command = "holdfwd" || enemynear,Pos X - Pos X < 0 && command = "holdback"
;Trigger1 = command = "holdback"
Trigger1 = var(0) - ((var(0)/100000000) * 100000000) <= (1000000 * (floor(var(0) / 100000000)))
Trigger1 = Var(0) := var(0) + ((1000000 * (floor(var(0) / 100000000))) - (var(0) - ((floor(var(0)/100000000) * 100000000) + (var(0) - ((var(0)/1000000) * 1000000)))))

;==========================================================================
;                Buffer X Y Z Start
;==========================================================================
[State Timer Set Part 1]
Type = null
trigger1 = time = 0
trigger1 = var(2) = 0
trigger1 = var(2) := var(0)  ;Config buffer time for ABCX is the same as directions by default. if changed, this value should be set between 1 and 21

[State Timer Set Part 2]
Type = null
trigger1 = var(2) < 100000000
trigger1 = var(2) := var(2) * 100000000
trigger2 = var(2) = 0
trigger2 = var(2) := 100000000

[State Count Down Start]
type = null
Trigger1 = var(2) - ((var(2)/100) * 100) = [1, 98]
Trigger1 = var(2) := var(2) - 1

[State Count Down Z]
type = null
Trigger1 = var(2) - ((var(2)/10000) * 10000) = [99, 9998]
Trigger1 = var(2) := var(2) - 100

[State Count Down Y]
type = null
Trigger1 = var(2) - ((var(2)/1000000) * 1000000) = [9999, 999998]
Trigger1 = var(2) := var(2) - 10000

[State Count Down X]
type = null
Trigger1 = var(2) - ((var(2)/100000000) * 100000000) = [999999, 99999998]
Trigger1 = var(2) := var(2) - 1000000

;----------------------------------------------------------
[State Start]
Type = null
Trigger1 = command = "start"
Trigger1 = var(2) - ((var(2)/100) * 100) <= (1 * (floor(var(2) / 100000000)))
Trigger1 = var(2) := var(2) + ((1 * (floor(var(2) / 100000000))) - (var(2) - ((var(2)/100) * 100)))

[State Z]
Type = null
Trigger1 = command = "z"
Trigger1 = var(2) - ((var(2)/10000) * 10000) <= (100 * (floor(var(2) / 100000000)))
Trigger1 = var(2) := var(2) + ((100 * (floor(var(2) / 100000000))) - (var(2) - ((floor(var(2)/10000) * 10000)   + (var(2) - ((var(2)/100) * 100)))))

[State Y]
Type = null
Trigger1 = command = "y"
Trigger1 = var(2) - ((var(2)/1000000) * 1000000) <= (10000 * (floor(var(2) / 100000000)))
Trigger1 = var(2) := var(2) + ((10000 * (floor(var(2) / 100000000))) - (var(2) - ((floor(var(2)/1000000) * 1000000)   + (var(2) - ((var(2)/10000) * 10000)))))

[State X]
Type = null
Trigger1 = command = "x"
Trigger1 = var(2) - ((var(2)/100000000) * 100000000) <= (1000000 * (floor(var(2) / 100000000)))
Trigger1 = var(2) := var(2) + ((1000000 * (floor(var(2) / 100000000))) - (var(2) - ((floor(var(2)/100000000) * 100000000) + (var(2) - ((var(2)/1000000) * 1000000)))))

;==========================================================================
;                Buffer A B C
;==========================================================================
[State Timer Set Part 1]
Type = null
trigger1 = time = 0
trigger1 = var(3) = 0
trigger1 = var(3) := var(0) ;Config buffer time for ABCX is the same as directions by default. if changed, this value should be set between 1 and 21

[State Timer Set Part 2]
Type = null
trigger1 = var(3) < 100000000
trigger1 = var(3) := var(3) * 100000000
trigger2 = var(3) = 0
trigger2 = var(3) := 100000000

[State Count Down C]
type = null
Trigger1 = var(3) - ((var(3)/10000) * 10000) = [99, 9998]
Trigger1 = var(3) := var(3) - 100

[State Count Down B]
type = null
Trigger1 = var(3) - ((var(3)/1000000) * 1000000) = [9999, 999998]
Trigger1 = var(3) := var(3) - 10000

[State Count Down A]
type = null
Trigger1 = var(3) - ((var(3)/100000000) * 100000000) = [999999, 99999998]
Trigger1 = var(3) := var(3) - 1000000

;----------------------------------------------------------
[State C]
Type = null
Trigger1 = command = "c"
Trigger1 = var(3) - ((var(3)/10000) * 10000) <= (100 * (floor(var(3) / 100000000)))
Trigger1 = var(3) := var(3) + ((100 * (floor(var(3) / 100000000))) - (var(3) - ((floor(var(3)/10000) * 10000) + (var(3) - ((var(3)/100) * 100)))))

[State B]
Type = null
Trigger1 = command = "b"
Trigger1 = var(3) - ((var(3)/1000000) * 1000000) <= (10000 * (floor(var(3) / 100000000)))
Trigger1 = var(3) := var(3) + ((10000 * (floor(var(3) / 100000000))) - (var(3) - ((floor(var(3)/1000000) * 1000000) + (var(3) - ((var(3)/10000) * 10000)))))

[State A]
Type = null
Trigger1 = command = "a"
Trigger1 = var(3) - ((var(3)/100000000) * 100000000) <= (1000000 * (floor(var(3) / 100000000)))
Trigger1 = var(3) := var(3) + ((1000000 * (floor(var(3) / 100000000))) - (var(3) - ((floor(var(3)/100000000) * 100000000) + (var(3) - ((var(3)/1000000) * 1000000)))))

;----------------------------------------------------------
[State BindToRoot]
type = BindToRoot
trigger1 = 1
time = 1
pos = 0,-2
ignorehitpause = 1

;==========================================================================

Last Edit: June 12, 2019, 08:31:58 am by ink