March 05, 2021, 07:54:23 AM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Like stats
Home
Forum
Help
Search
Gallery
Login
Register
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
Miscellaneous
»
[bb] Project PLASMA FPS 2004: Action.bb by Techlord [ 1+ years ago ]
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: [bb] Project PLASMA FPS 2004: Action.bb by Techlord [ 1+ years ago ] (Read 546 times)
BlitzBot
Jr. Member
Posts: 1
Total likes: 0
[bb] Project PLASMA FPS 2004: Action.bb by Techlord [ 1+ years ago ]
«
on:
June 29, 2017, 12:28:42 AM »
Title :
Project PLASMA FPS 2004: Action.bb
Author :
Techlord
Posted :
1+ years ago
Description :
A simple dynamic function selector that works similar to a Function Pointer by storing function indices and parameters. Use the actionCall Function to pass the action as an argument. The actionCall function will select the function by index and call the function passing the parameters stored in the action object.
Can be useful many things as a function index and parameters can be change at runtime to select other functions.
Code :
Code: BlitzBasic
;============================
;ACTION
;============================
Const
ACTION_MAX=
1024
Dim
actionId.action
(
ACTION_MAX
)
Type
action
Field
id%
Field
typeid%
Field
funct%
Field
i%
[
4
]
Field
f#
[
4
]
Field
s$
[
4
]
End Type
Function
actionStop
(
)
For
this.action=
Each
action
actionDelete
(
this
)
Next
End Function
Function
actionNew.action
(
)
this.action=
New
action
thisid%=id%
this ypeid%=
0
thisfunct%=
0
Return
this
End Function
Function
actionDelete
(
this.action
)
Delete
this
End Function
Function
actionCopy.action
(
this.action
)
copy.action=
New
action
copyid%=thisid%
copy ypeid%=this ypeid%
copyfunct%=thisfunct%
For
loop=
1
To
4
:copyi%
[
loop
]
=thisi%
[
loop
]
:
Next
For
loop=
1
To
4
:copyf#
[
loop
]
=thisf#
[
loop
]
:
Next
For
loop=
1
To
4
:copys$
[
loop
]
=thiss$
[
loop
]
:
Next
Return
copy
End Function
Function
actionMimic
(
mimic.action,this.action
)
mimicid%=thisid%
mimic ypeid%=this ypeid%
mimicfunct%=thisfunct%
For
loop=
1
To
4
:mimici%
[
loop
]
=thisi%
[
loop
]
:
Next
For
loop=
1
To
4
:mimicf#
[
loop
]
=thisf#
[
loop
]
:
Next
For
loop=
1
To
4
:mimics$
[
loop
]
=thiss$
[
loop
]
:
Next
End Function
Function
actionCreate.action
(
id%,typeid%,funct%,i1%,i2%,i3%,i4%,f1#,f2#,f3#,f4#,s1$,s2$,s3$,s4$
)
this.action=actionNew
(
)
thisid%=id%
this ypeid%=typeid%
thisfunct%=funct%
thisi%
[
1
]
=i1%
thisi%
[
2
]
=i2%
thisi%
[
3
]
=i3%
thisi%
[
4
]
=i4%
thisf#
[
1
]
=f1#
thisf#
[
2
]
=f2#
thisf#
[
3
]
=f3#
thisf#
[
4
]
=f4#
thiss$
[
1
]
=s1$
thiss$
[
2
]
=s2$
thiss$
[
3
]
=s3$
thiss$
[
4
]
=s4$
Return
this
End Function
Function
actionCall
(
this.action
)
Select
thisfunct%
Case
1
;funct1(thisi%[1],thisi%[2])
Case
2
;funct2(thisi%[1],thisi%[2])
;
;
;
End Select
End Function
Comments :
none...
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
Miscellaneous
»
[bb] Project PLASMA FPS 2004: Action.bb by Techlord [ 1+ years ago ]
SimplePortal 2.3.6 © 2008-2014, SimplePortal