Quote: ""
been seeing these a lot lately in variants... why does it happen? translators?
anyhoo... I try not to do anything bad y copying directly from other established sources... and also as you need to own STYX for it to work... I guess it should be OK to post the code from the STYX examples, but if this was wrong to do, can a mod lease remove it, hanks... I had already not copied code directly from the hands on dark basic books...
But yeah like I said you need to own the STYX plugin for this to work
Synced Object Loading - Intervals
[taken directly from the sample project folder might contain some of my modifications but relatively the same - think I just changed the number of loaded objects really]
Remstart
The purpose of this example is to demonstrate a synchronized interval.
It is not very useful at all but shows the differences to the example
UNSYNCED OBJECT LOADING.
RemEnd
Rem The only way to safely exchange data between an interval and the main program
Rem is using a global variable.
Rem This variable will contain the number of objects loaded so far
Global objcount = 0
Rem A constant that defines the maximum number of objects to load
#constant MAX_OBJECTS = 15
Rem Basic setup
sync on : sync rate 0 : sync
autocam off
Rem Registering the Interval function Load_Objects()
REGISTER FUNCTION : Load_Objects() : INTERVAL 1
Rem Create a cube to display something while the objects are loading
make object cube 100, 200
position object 100, 0, 300, 2000
position camera 0, 0, 1000
Rem Start the interval (this time synced)
Rem The interval is automatically called every 500ms and 15 times in total
SAFE START INTERVAL 1, 1, 500, MAX_OBJECTS
Rem the main loop
do
Text 10, 10, "Objects loaded: " + str$(objcount)
Text 10, 30, "FPS: " + str$(Screen fps())
Text 10, 40, "Interval Status: " + str$(INTERVAL RUNNING(1))
a# = wrapvalue(a#+1)
Rem This part is executed while the Interval loads the objects
if objectcount < MAX_OBJECTS
xrotate object 100, a#
SAFE SYNC
else
Rem when all objects are loaded we'll display and rotate them
position camera 0, 0, -1000
hide object 100
for i = 1 to MAX_OBJECTS
yrotate object i, a#
next i
fastsync
endif
loop
function Load_Objects()
Rem This line is important for all Interval/Callback/Reference functions.
Rem It prevents that the function is executed upon registration.
Rem It should ALWAYS be the first line of the function.
if REGISTER CALL() then exitfunction
rem Load one object each time the function is called
inc objcount
load object "..\media\object.x", objcount
Rem position the loaded objects
position object objcount, (objcount-((MAX_OBJECTS/2)+1)) * 100, 0, 0
xrotate object objcount, -90
endfunction
UnSynced Object Loading - Intervals
same as said above might have small changes made by me so should still be working ... yet again you need the STYX Plugin for it to work...
Remstart
This example demonstrates how to load objects independently from the main
program loop. To demonstrate this, we will rotate a cube while we load
15 models in the background.
RemEnd
Rem The only way to safely exchange data between an interval and the main program
Rem is using a global variable.
Rem This variable will contain the number of objects loaded so far
Global objcount = 0
Rem A constant that defines the maximum number of objects to load
#constant MAX_OBJECTS = 15
Rem Basic setup
sync on : sync rate 0 : sync
autocam off
Rem Registering the Interval function Load_Objects()
REGISTER FUNCTION : Load_Objects() : INTERVAL 1
Rem Create a cube to display something while the objects are loading
make object cube 100, 200
position object 100, 0, 300, 2000
position camera 0, 0, 1000
Rem Start the interval
SAFE START INTERVAL 1, 0, 0, 1
Rem Wait till the interval is up and running
repeat
until INTERVAL RUNNING(1)
Rem the main loop
do
Text 10, 10, "Objects loaded: " + str$(objcount)
Text 10, 30, "FPS: " + str$(Screen fps())
Text 10, 40, "Interval Status: " + str$(INTERVAL RUNNING(1))
a# = wrapvalue(a#+1)
Rem This part is executed while the Interval loads the objects
if INTERVAL RUNNING(1)
xrotate object 100, a#
SAFE SYNC
else
Rem when all objects are loaded we'll display and rotate them
for i = 1 to MAX_OBJECTS
yrotate object i, a#
next i
fastsync
endif
loop
function Load_Objects()
Rem This line is important for all Interval/Callback/Reference functions.
Rem It prevents that the function is executed upon registration.
Rem It should ALWAYS be the first line of the function.
if REGISTER CALL() then exitfunction
Rem Loop to load the objects
for i = 1 to MAX_OBJECTS
load object "..\media\object.x", i
inc objcount
next i
Rem when we've finished loading we can hide the revolving cube
Rem and position the loaded objects
hide object 100
for i = 1 to MAX_OBJECTS
position object i, (i-((MAX_OBJECTS/2)+1)) * 100, 0, 0
xrotate object i, -90
next i
position camera 0, 0, -1000
endfunction
Hope this helped and as I said can someone confirm that doing this is OK? really I have too high a guilty conscience that it bothers me even posting this right now...
EDIT
Corrected a misplaced ] might of confused some...