Hi, guys this is some code i found here in the forums and altered a bit to improve it.
What it does is that it add ingame comand prompt a.k.a. console in game so it make possible debuging easier and faster interacting.
I`m sure pretty much everything should work with this from examples i wrote here like making simple primitives to loading of whole levels.The way it was writen at first it wasn`t able to do much, complicated tasks like
make object sphere 1,10,40,40 for example was nearly impossible to do and just any comand with few arguments.It was using "cases" now just check the comand
I`m sorry that i forget where i exactly downloaded the first version of the code.If someone recognize it as his work should inform me so his name can be added here.
The snippet uses cloggy`s dll because there is some text drawed with it`s function, but not all and not completely nessecery.You can rewrite if you want so it uses native dbpro text only.But my advise is to get the dll, and you can change the text in the code where it`s not used to it.It`s much faster compared to native text comands :
http://www.dbdepot.co.uk/
sync on
sync rate 0
set display mode 1280,1024,32
set window position 0,0
backdrop on
d3d_init
d3d_font 1,"arial",12,0,0,1
cls
set text font "arial"
set text size 14
global console as integer
global dim console$(20)
console = 0
global dim KeyHold(256)
global dim LastKeyHold(256)
global fps as boolean
dim comand$(10)
do
if fps = 1
text screen width ()/2,20,str$(screen fps())
endif
UpdateKeyHold()
REM Runs the console if the console is open reguler controls are diabled.
if console = 1
Show_Console()
else
endif
if keyhit(41)=1
if console = 1
console = 0
else
console = 1
endif
console$(20)=""
endif
sync
comand$(1) = console$(20)
loop
function UpdateKeyHold()
for t=0 to 256
LastKeyHold(t) = KeyHold(t)
next t
for t=0 to 256
KeyHold(t) = Keystate(t)
next t
endfunction
function KeyHit(t)
retval=0
if not LastKeyHold(t)
if KeyHold(t)
retval=1
endif
endif
endfunction retval
function Show_Console()
new$=entry$()
for n=1 to len(new$)
if asc(mid$(new$,n))=8
console$(20)=left$(console$(20),len(console$(20))-1)
else
if mid$(new$,n)="`"
else
console$(20)=console$(20)+mid$(new$,n)
endif
endif
next n
clear entry buffer
Enter_Console()
if keyhit(28)=1
Console_Command()
console$(20)=""
for c = 1 to 10
comand$(c) = ""
NEXT
endif
d3d_starttext
for n = 1 to 20
d3d_text 1,15,n*15,0,console$(n)
next n
d3d_text 1,13,300,2,">"
d3d_endtext
endfunction
function Enter_Console()
if keyhit(28)=1
for n = 1 to 19
console$(n) = console$(n+1)
next n
endif
endfunction
function Console_Command()
Split String console$(20)," "
Count=Split count()
for attribute = 1 to Count
comand$(attribute)=get split word$(attribute)
next attribute
if comand$(1) = "exit"
if val(comand$(2)) = 1
end
endif
endif
if comand$(1) = "cube"
if val(comand$(2)) > 0
if object exist( val(comand$(2)) ) = 0
make object cube val(comand$(2)),val(comand$(3))
console$(19) = console$(19)+" "+"Object "+comand$(2)+" created, Size: "+comand$(3)
console$(20) = ""
else
console$(19) = console$(19)+" "+"Object "+comand$(2)+" allready exist!"
console$(20) = ""
endif
else
console$(19) = console$(19)+" "+"Object "+comand$(2)+" can not be created!"
console$(20) = ""
endif
endif
if comand$(1) = "sphere"
if val(comand$(2)) > 0
if object exist( val(comand$(2)) ) = 0
make object sphere val(comand$(2)),val(comand$(3)),1+val(comand$(4)),1+val(comand$(5))
console$(19) = console$(19)+" "+"Object "+comand$(2)+" created, Size: "+comand$(3)+" Rows: "+comand$(4)+" Columns: "+comand$(4)
console$(20) = ""
else
console$(19) = console$(19)+" "+"Object "+comand$(2)+" allready exist!"
console$(20) = ""
endif
else
console$(19) = console$(19)+" "+"Object "+comand$(2)+" can not be created!"
console$(20) = ""
endif
ENDIF
if comand$(1) = "delete_object"
if val(comand$(2)) > 0
if object exist( val(comand$(2)) ) = 1
delete object val(comand$(2))
console$(19) = console$(19)+" "+"Object "+comand$(2)+" deleted!"
console$(20) = ""
else
console$(19) = console$(19)+" "+"Object "+comand$(2)+" does not exist!"
console$(20) = ""
endif
else
console$(19) = console$(19)+" "+"Object "+comand$(2)+" does not exist!"
console$(20) = ""
endif
ENDIF
if comand$(1) = "rotate_object"
if val(comand$(2)) > 0
if object exist( val(comand$(2)) ) = 1
rotate object val(comand$(2)),val(comand$(3)),val(comand$(4)),val(comand$(5))
console$(19) = console$(19)+" "+"Object "+comand$(2)+" rotated!"+" Angle X:"+comand$(3)+" Angle Y:"+comand$(4)+" Angle Z:"+comand$(5)
console$(20) = ""
else
console$(19) = console$(19)+" "+"Object "+comand$(2)+" does not exist!!"
console$(20) = ""
endif
else
console$(19) = console$(19)+" "+"Object "+comand$(2)+" does not exist!"
console$(20) = ""
endif
ENDIF
if comand$(1) = "fps"
if val(comand$(2)) = 1
fps = 1
endif
if val(comand$(2)) = 0
fps = 0
endif
ENDIF
endfunction
Comandlist:
exit 1 - exit application
cube Num Size - make object cube with desired number and size
sphere Num Size Row Column - make object sphere with desired values for size row and column
delete_object Num - delete desired object
rotate_object Num XANG YANG ZANG - rotate desired object at specified angle values
fps 1 - shows fps
fps 0 - hide fps
All commands related to object manipulation trigger errors if the operation can not be executed with the reason for this.
There is much room for anything you want to add here, i can update with /help when i get time for this but now i can`t do it.
I almost forget to mention that if you need more than 10 arguments you need to touch comand$ array so it can get more values.
Where there is a will, there is a way.
I often edit my posts, that`s who i am