|Dirk Peeters (Unknown)||20.10.2015 19:35|
i'm trying to create a coroutine but it seems to do the coroutine.yield() true c.
i was reading a workaround that uses require("scriptName") to have the yield run from inside the module.
nothing seems to work.
require() alway's returns a nil value, and when i print the path to the file its correct.
it also not work when i give the complete path c:/......./.../../coroutine.lua
what is the workflow for having a coroutine to work inside the Giants engine?
assume the file is called coroutine.lua
co = coroutine.create(silocheck);
check = 0;
-- first set
check = 1;
-- second set
check = 2;
-- final step
check = 3;
-- do stuff
check = 0;
if something then
coroutine.resume(co); -- start the coroutine
if check == 1 then
coroutine.resume(co); -- resume to step 2
|D. Ecker (Decker_MMIV)||27.10.2015 09:22|
|I would advice you to NOT attempt using LUA coroutines and yield() in mods for the Farming Simulator game-engine.
Try to solve whatever you are attempting to do, by using a 'finite state machine' pattern (look it up on Google), and then use your mod's default 'update()' or 'updateTick()' methods, as they are called by the game-engine continuously.
Examples of such a 'finite state machine' pattern, can somewhat indirectly be seen in GIANTS' scripts:
- study/understand the usage of the constants: Baler.UNLOADING_...
- study/understand the usage of the constants: BaleWrapper.STATE_... & BaleWrapper.CHANGE_...
and there are more to find.
Also it is imperative to avoid usage of any sleep() or wait() functions in a game-engine, as that would result in sluggish/bad game performance (i.e. cause "lag"). - When you ask about "coroutines", it tells me that you might be thinking of having several other 'execution threads', possibly due to your execution-flow-methods have not been split into smaller parts (e.g. "states").
|Dirk Peeters (Unknown)||31.10.2015 01:55|
yes i was looking into it but i did not use it, i want to do something for the breeding and i also used states in my new version, but the project touk a weard turn due to a problem of syncing and i used my 2013 sync script that solves my problem. as a result i fixed my 2013 script. We running tests on it now, for the moment all seems to be working the same on 2015 as in 2013.
i was thinking implementing timers but i need to go true the tutors and churchclock again as i overlook something. but yes the AnimalMod is working fine, the breeding and syncing works great buy/sell load/unload all 3 animaltypes.
and like i alway's want it to be, by using the ingame triggers no extra triggers needed only a cattletrailer to load them. on map side you only need to add the fillTypes to the tip- siloTriggers
tested on a modmap as standalone zip and one from inside the samplemodmap.lua both work the same.
i upgrade my cattletrailer to 2015 as the others do not match the size of the game or have errors.
the only thing i see is the saving part that needs to be modified for 2015, but i have a workaround for the moment.
maby end of the week i post a video on fs-uk and youtube of the mod.
Note: Log in to post. Create a new account here.