Alright, so I'm trying to make a Windmill sync. It is supposed to be somewhat like the Zanzibar fan, where you can get on top of it, though this one has seats to take you around.
I have made it a device_machine, set as "gears"; rotating fully every 80 seconds (slowly enough so that you don't fall off your seat, since there are no sticky surfaces; the collision keeps you inside.)
The problem right now, though, is syncing it.
I wasn't sure how to start, so I asked Kirby for help, and he gave me this script:
(global short player_count 0) ;;Store Player Count
(global boolean is_host false) ;;Stores whether player is host
(script continuous resync
(sleep_until (< (unit_get_health sync_biped) 1) 1) ;;Waits until the sync_biped is hurt
(device_set_position_immediate device 0) ;;Resets windmill
(device_set_position device 1) ;;Starts it moving
(object_create_anew sync_biped) ;;Remakes Sync biped
)
(script continuous host_only
(sleep_until is_host 1) ;;Doesnt run if not host
(sleep_until (!= player_count player_spawn_count) 1) ;;Wait until the player count changes
(if (< player_count player_spawn_count) (object_teleport biped_crusher crush_flag)) ;;If the player count increased, resync
(set player_count player_spawn_count) ;;Track current player count
)
(script startup host_testing
(sleep 5)
(set is_host (!= (unit_get_health biped_crusher) -1)) ;;See whose hosting the server
(if (not is_host) (sleep -1 host_only)) ;;If the player isnt host, kill the other host_only script
)
When I tested it, the script crushed the biped successfully for the host; though after that, it didn't crush the biped anymore; hence the windmill didn't sync.
I switched the "player_spawn_count" to "(list_count (players))" to see if the logic was fine, and surely enough, it crushed the biped when a player spawned.
The problem there is: that it restarts the windmill every time you respawn - which is why Kirby used the player_spawn_count instead.
I've tried to modify it and even change the script to solve the problem, but I haven't come any closer than syncing the windmill every fifth of a rotation at the expense of small jerks every now and then.
So I was wondering if anyone could explain why the script isn't working for player_spawn_count.